Skip to content

Commit 52766d3

Browse files
Piotr Oleśpiotr-oles
authored andcommitted
feat: 🎸 drop monorepo support and add semantic-release instead
BREAKING CHANGE: 🧨 dropped monorepo support (in favor of semantic-release) - removed structure-sub-library generator
1 parent b293920 commit 52766d3

23 files changed

Lines changed: 1013 additions & 1042 deletions

File tree

‎generators/config-doc/index.ts‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export = class ConfigDocGenerator extends Generator {
88
// we have to add --ignoreCompilerErrors because of https://github.com/facebook/jest/issues/8218
99
this.traits.extendPackageJson({
1010
scripts: {
11-
doc: this.traits.execEachPackage(
12-
"typedoc --out doc --mode file --ignoreCompilerErrors src"
13-
)
11+
doc: "typedoc --out doc --mode file --ignoreCompilerErrors src"
1412
},
1513
devDependencies: {
1614
typedoc: "^0.14.2"
@@ -19,12 +17,7 @@ export = class ConfigDocGenerator extends Generator {
1917
}
2018

2119
public writing() {
22-
this.traits.addGitIgnoreEntries(
23-
[
24-
"### TypeDoc",
25-
this.traits.usesLerna() ? "/packages/**/doc" : "/doc"
26-
].join("\n")
27-
);
20+
this.traits.addGitIgnoreEntries(["### TypeDoc", "/doc"].join("\n"));
2821
}
2922

3023
public install() {

‎generators/config-lint/index.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ export = class ConfigLintGenerator extends Generator {
1414
build:
1515
scripts.build || 'echo "Error: no build script specified" && exit 1',
1616
lint: "tslint --project tsconfig.json",
17-
format: this.traits.execEachPackage('prettier --write "src/**/*"'),
17+
format: 'prettier --write "src/**/*"',
1818
precommit: "lint-staged && yarn build && yarn test",
19-
commit: "yarn exec git-cz"
19+
commit: "./node_modules/.bin/git-cz"
2020
},
2121
devDependencies: {
2222
"@commitlint/config-conventional": "^7.5.0",
2323
commitlint: "^7.5.2",
2424
"git-cz": "^3.0.1",
25-
husky: "^1.3.1",
25+
husky: "^2.3.0",
2626
"lint-staged": "^8.1.0",
2727
prettier: "^1.15.3",
2828
tslint: "^5.12.0",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import chalk from "chalk";
2+
import Generator from "yeoman-generator";
3+
import traits from "../../traits";
4+
5+
export = class ConfigReleaseGenerator extends Generator {
6+
public traits = traits(this);
7+
8+
public configuring() {
9+
this.traits.extendPackageJson({
10+
scripts: {
11+
"semantic-release": "semantic-release"
12+
},
13+
release: {
14+
branches: [
15+
"master",
16+
{
17+
name: "beta",
18+
prerelease: true
19+
},
20+
{
21+
name: "alpha",
22+
prerelease: true
23+
}
24+
]
25+
},
26+
devDependencies: {
27+
"semantic-release": "^16.0.0-beta.18"
28+
}
29+
});
30+
this.traits.addReadmeBadges([
31+
"[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)"
32+
]);
33+
}
34+
35+
public install() {
36+
this.yarnInstall();
37+
}
38+
39+
public end() {
40+
this.log(
41+
`To finish release setup, please install semantic-release-cli (${chalk.green(
42+
"npm install -g semantic-release-cli"
43+
)}) ` +
44+
`and then run ${chalk.green(
45+
"semantic-release-cli setup"
46+
)} command. Probably it will override your semantic-release version ` +
47+
`- please discard this change when committing.`
48+
);
49+
}
50+
};

‎generators/config-rollup/index.ts‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,16 @@ export = class ConfigRollupGenerator extends Generator {
88
const packageJson = this.traits.readPackageJson();
99

1010
this.traits.extendPackageJson({
11-
main:
12-
!packageJson.main && !this.traits.usesLerna()
13-
? "lib/index.js"
14-
: packageJson.main,
15-
module:
16-
!packageJson.module && !this.traits.usesLerna()
17-
? "lib/index.es.js"
18-
: packageJson.module,
11+
main: !packageJson.main ? "lib/index.js" : packageJson.main,
12+
module: !packageJson.module ? "lib/index.es.js" : packageJson.module,
1913
scripts: {
20-
build: this.traits.usesLerna()
21-
? "lerna exec -- rollup -c --config ../../rollup.config.js"
22-
: "rollup -c"
14+
build: "rollup -c"
2315
},
2416
devDependencies: {
2517
rollup: "^1.0.2",
2618
"rollup-plugin-cleaner": "^0.2.0",
2719
"rollup-plugin-sourcemaps": "^0.4.2",
28-
"rollup-plugin-typescript2": "^0.20.1"
20+
"rollup-plugin-typescript2": "^0.21.1"
2921
}
3022
});
3123
}
@@ -36,11 +28,7 @@ export = class ConfigRollupGenerator extends Generator {
3628
this.destinationPath("rollup.config.js")
3729
);
3830
this.traits.addGitIgnoreEntries(
39-
[
40-
"### Rollup",
41-
this.traits.usesLerna() ? "/packages/**/lib" : "/lib",
42-
".rpt2_cache"
43-
].join("\n")
31+
["### Rollup", "/lib", ".rpt2_cache"].join("\n")
4432
);
4533
}
4634

‎generators/library/index.ts‎

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as path from "path";
21
import Generator from "yeoman-generator";
32
import traits from "../../traits";
43

@@ -19,88 +18,17 @@ export = class LibraryGenerator extends Generator {
1918
this.composeWith(require.resolve("../config-lint"), {});
2019
this.composeWith(require.resolve("../config-doc"), {});
2120
this.composeWith(require.resolve("../config-rollup"), {});
22-
}
23-
24-
public async prompting() {
25-
const questions: Generator.Questions = [
26-
{
27-
type: "list",
28-
name: "structure",
29-
message: "Library structure",
30-
choices: [
31-
{
32-
name: "Single package repository",
33-
value: "single"
34-
},
35-
{
36-
name: "Multi package repository (monorepo)",
37-
value: "multi"
38-
}
39-
]
40-
}
41-
];
42-
43-
this.answers = (await this.prompt(questions)) as Answers;
44-
}
45-
46-
public configuring() {
47-
switch (this.answers.structure) {
48-
case "single":
49-
this.traits.extendPackageJson({
50-
scripts: {
51-
release: "standard-version",
52-
publish: "yarn publish"
53-
},
54-
devDependencies: {
55-
"standard-version": "^5.0.2"
56-
}
57-
});
58-
break;
59-
60-
case "multi":
61-
this.fs.copyTpl(
62-
this.templatePath("multi/lerna.json"),
63-
this.destinationPath("lerna.json"),
64-
{
65-
...this.answers,
66-
...this.config.getAll()
67-
}
68-
);
69-
70-
this.traits.extendPackageJson({
71-
private: true,
72-
scripts: {
73-
release: "lerna bootstrap && lerna version",
74-
publish: "lerna publish from-git"
75-
},
76-
workspaces: ["packages/*"],
77-
devDependencies: {
78-
lerna: "^3.11.0"
79-
}
80-
});
81-
82-
break;
83-
}
21+
this.composeWith(require.resolve("../config-release"), {});
8422
}
8523

8624
public writing() {
87-
switch (this.answers.structure) {
88-
case "single":
89-
["src/index.ts", "test/index.spec.ts"].forEach(file => {
90-
this.fs.copyTpl(
91-
this.templatePath(path.join("single", file)),
92-
this.destinationPath(file),
93-
{
94-
...this.answers,
95-
...this.config.getAll()
96-
}
97-
);
98-
});
99-
break;
100-
101-
case "multi":
102-
break;
103-
}
25+
["src/index.ts", "test/index.spec.ts"].forEach(file => {
26+
this.fs.copyTpl(
27+
this.templatePath(file),
28+
this.destinationPath(file),
29+
this.config.getAll()
30+
);
31+
});
10432
}
10533

10634
public install() {

‎generators/library/templates/multi/lerna.json‎

Lines changed: 0 additions & 14 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

‎generators/package/templates/.travis.yml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: node_js
22
node_js:
33
- 10
44
- 8
5-
- 6
65

76
install:
87
- yarn install --frozen-lockfile
@@ -13,9 +12,10 @@ script:
1312
- yarn lint
1413

1514
deploy:
16-
- provider: script
17-
script: yarn run publish --dry-run
18-
skip_cleanup: true
19-
on:
20-
node: 10
21-
branch: master
15+
provider: script
16+
skip_cleanup: true
17+
script:
18+
- yarn exec semantic-release
19+
on:
20+
all_branches: true
21+
node_js: 10

‎generators/package/templates/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
This package is available as an [npm package](https://www.npmjs.com/package/<%= name %>).
1313

1414
```
15-
npm install <%= name %>
15+
npm install --save <%= name %>
1616
```
1717

1818
## Usage

0 commit comments

Comments
 (0)