Skip to content

Commit

Permalink
Add option for the release-script (#759)
Browse files Browse the repository at this point in the history
Co-authored-by: AlCalzone <[email protected]>
  • Loading branch information
UncleSamSwiss and AlCalzone authored May 19, 2021
1 parent 7255280 commit 3c3218c
Show file tree
Hide file tree
Showing 27 changed files with 346 additions and 30 deletions.
1 change: 1 addition & 0 deletions .github/create_templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const baseAnswers = {
ci: "gh-actions",
dependabot: "yes",
license: "MIT License" as any,
releaseScript: "yes",
} as Answers;

const adapterAnswers: Answers = {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* (AlCalzone) The template index no longer changes order when switching between Linux and Windows (#753)
* (AlCalzone) Enable TypeScript sourcemaps (#755) · [Migration guide](docs/updates/20210515_sourcemaps.md)
* (AlCalzone) Add Node 16 to test suite, drop Node 10 (#756) · [Migration guide](docs/updates/20210515_test_node_16.md)
* (UncleSamSwiss) Add option for release script (#759) · [Migration guide](docs/updates/20210519_release_script.md)

## 1.33.0 (2021-04-05)
* (AlCalzone) The generated `io-package.json` files are now validated with the official JSON schema during tests (#711)
Expand Down
46 changes: 46 additions & 0 deletions docs/updates/20210519_release_script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Support for release-script

If you wish to add the release-script to your project, please follow these steps (taken from the [official documentation](https://github.com/AlCalzone/release-script/blob/master/README.md#installation)):

## Installation

1. Add this module to your `devDependencies`:

```bash
npm i -D @alcalzone/release-script
```

2. Add a new `npm` script in `package.json`:

```json
"scripts": {
... other scripts ...
"release": "release-script"
}
```

3. Add a placeholder to `README.md` (for your own convenience)

```md
## Changelog
<!--
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
```

or `CHANGELOG.md` if you prefer to have a separate changelog (notice that there is one less `#`):

```md
# Changelog
<!--
Placeholder for the next version (at the beginning of the line):
## **WORK IN PROGRESS**
-->
```

## More information

For further information, check the [official documentation](https://github.com/AlCalzone/release-script#release-script).
14 changes: 14 additions & 0 deletions src/lib/core/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,19 @@ export const questionGroups: QuestionGroup[] = [
: null,
].filter((f) => !!f) as string[],
}),
{
type: "select",
name: "releaseScript",
label: "Release Script",
message:
"Would you like to automate new releases with one simple command?",
initial: "yes",
choices: ["yes", "no"],
migrate: async (ctx) =>
ctx.hasDevDependency("@alcalzone/release-script")
? "yes"
: "no",
},

{
condition: { name: "features", contains: "adapter" },
Expand Down Expand Up @@ -890,6 +903,7 @@ export interface Answers {
type: string;
adminReact?: "yes" | "no";
tabReact?: "yes" | "no";
releaseScript?: "yes" | "no";
indentation?: "Tab" | "Space (4)";
quotes?: "single" | "double";
es6class?: "yes" | "no";
Expand Down
22 changes: 19 additions & 3 deletions templates/README.md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export = (answers => {
const autoInitGit = answers.gitCommit === "yes";
const useTravis = answers.ci === "travis";
const useGithubActions = answers.ci === "gh-actions";
const useReleaseScript = answers.releaseScript === "yes";
const useDependabot = answers.dependabot === "yes";

const npmScripts: Record<string, string> = {};
Expand Down Expand Up @@ -53,6 +54,9 @@ export = (answers => {
if (useESLint) {
npmScripts["lint"] = "Runs \`ESLint\` to check your code for formatting errors and potential bugs.";
}
if (useReleaseScript) {
npmScripts["release"] = "Creates a new release, see [`@alcalzone/release-script`](https://github.com/AlCalzone/release-script#usage) for more details.";
}

const adapterNameLowerCase = answers.adapterName.toLowerCase();
const template = `
Expand Down Expand Up @@ -136,7 +140,15 @@ ${useGithubActions ? `Since you have chosen GitHub Actions as your CI service, y
enable automatic releases on npm whenever you push a new git tag that matches the form
\`v<major>.<minor>.<patch>\`. The necessary steps are described in \`.github/workflows/test-and-release.yml\`.
`: ""}To get your ${isAdapter ? "adapter" : "widget"} released in ioBroker, please refer to the documentation
`: ""}${useReleaseScript ? `Since you installed the release script, you can create a new
release simply by calling:
\`\`\`bash
npm run release
\`\`\`
Additional command line options for the release script are explained in the
[release-script documentation](https://github.com/AlCalzone/release-script#command-line).
` : ""}To get your ${isAdapter ? "adapter" : "widget"} released in ioBroker, please refer to the documentation
of [ioBroker.repositories](https://github.com/ioBroker/ioBroker.repositories#requirements-for-adapter-to-get-added-to-the-latest-repository).
Expand All @@ -158,8 +170,12 @@ For later updates, the above procedure is not necessary. Just do the following:
1. Execute \`iobroker upload ${adapterNameLowerCase}\` on the ioBroker host
## Changelog
### 0.0.1
${useReleaseScript ? `<!--
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
` : ""}
### ${useReleaseScript ? "**WORK IN PROGRESS**" : "0.0.1"}
* (${answers.authorName}) initial release
## License
Expand Down
4 changes: 4 additions & 0 deletions templates/package.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const templateFunction: TemplateFunction = async answers => {
const useESLint = answers.tools && answers.tools.indexOf("ESLint") > -1;
const usePrettier = answers.tools && answers.tools.indexOf("Prettier") > -1;
const useNyc = answers.tools && answers.tools.indexOf("code coverage") > -1;
const useReleaseScript = answers.releaseScript === "yes";
const useDevcontainer = !!answers.tools?.includes("devcontainer");

const dependencyPromises = ([] as string[])
Expand Down Expand Up @@ -108,6 +109,7 @@ const templateFunction: TemplateFunction = async answers => {
"prettier",
] : [])
.concat(useNyc ? ["nyc"] : [])
.concat(useReleaseScript ? ["@alcalzone/release-script"] : [])
.sort()
.map((dep) => (async () => `"${getPackageName(dep)}": "${await fetchPackageReferenceVersion(dep)}"`))
.map(task => downloadLimiter(task))
Expand Down Expand Up @@ -180,6 +182,8 @@ const templateFunction: TemplateFunction = async answers => {
"test:package": "mocha test/package --exit",
"test": "npm run test:package",
`) : ""}
${useReleaseScript ? `
"release": "release-script",` : ""}
},
${useNyc ? `"nyc": {
"include": [
Expand Down
6 changes: 3 additions & 3 deletions test/baselines/TS_Prettier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"axios": "^0.21.1",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"language": "JavaScript",
"adminReact": "no",
"tabReact": "no",
"releaseScript": "no",
"tools": [
"ESLint",
"type checking"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"language": "JavaScript",
"adminReact": "no",
"tabReact": "no",
"releaseScript": "no",
"tools": [
"ESLint",
"type checking"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
Expand Down
1 change: 1 addition & 0 deletions test/baselines/adapter_JS_React/.create-adapter.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"language": "JavaScript",
"adminReact": "yes",
"tabReact": "no",
"releaseScript": "no",
"tools": [
"ESLint"
],
Expand Down
4 changes: 2 additions & 2 deletions test/baselines/adapter_JS_React/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@iobroker/adapter-core": "^2.4.0"
},
"devDependencies": {
"@babel/cli": "^7.13.16",
"@babel/core": "^7.14.2",
"@babel/cli": "^7.14.3",
"@babel/core": "^7.14.3",
"@iobroker/adapter-react": "1.6.15",
"@iobroker/testing": "^2.4.4",
"@material-ui/core": "^4.11.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"language": "TypeScript",
"adminReact": "no",
"tabReact": "no",
"releaseScript": "no",
"tools": [
"ESLint"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"axios": "^0.21.1",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"language": "TypeScript",
"adminReact": "no",
"tabReact": "no",
"releaseScript": "no",
"tools": [
"ESLint"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"axios": "^0.21.1",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
1 change: 1 addition & 0 deletions test/baselines/adapter_TS_React/.create-adapter.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"language": "TypeScript",
"adminReact": "yes",
"tabReact": "no",
"releaseScript": "no",
"tools": [
"ESLint"
],
Expand Down
10 changes: 5 additions & 5 deletions test/baselines/adapter_TS_React/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@iobroker/adapter-core": "^2.4.0"
},
"devDependencies": {
"@babel/cli": "^7.13.16",
"@babel/core": "^7.14.2",
"@babel/cli": "^7.14.3",
"@babel/core": "^7.14.3",
"@babel/plugin-proposal-decorators": "^7.14.2",
"@babel/preset-env": "^7.14.2",
"@babel/preset-typescript": "^7.13.0",
Expand All @@ -34,14 +34,14 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/react-dom": "^16.9.13",
"@types/react": "^16.14.6",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"axios": "^0.21.1",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
6 changes: 3 additions & 3 deletions test/baselines/contributors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"axios": "^0.21.1",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
6 changes: 3 additions & 3 deletions test/baselines/git_SSH/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"axios": "^0.21.1",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
6 changes: 3 additions & 3 deletions test/baselines/keywords/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"@types/chai-as-promised": "^7.1.4",
"@types/gulp": "^4.0.8",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.45",
"@types/node": "^14.17.0",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.0",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"axios": "^0.21.1",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
Loading

0 comments on commit 3c3218c

Please sign in to comment.