@next-core/yo 1.1.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/yo",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Generator for next v3",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/yo",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@next-core/build-next-bricks": "^1.7.2",
|
|
28
|
+
"@next-core/build-next-libs": "^1.0.5",
|
|
28
29
|
"@next-core/element": "^1.0.6",
|
|
29
|
-
"@next-core/i18n": "^1.0.
|
|
30
|
+
"@next-core/i18n": "^1.0.21",
|
|
30
31
|
"@next-core/react-element": "^1.0.7",
|
|
31
32
|
"@next-core/test-next": "^1.0.6",
|
|
32
33
|
"@next-core/theme": "^1.1.1",
|
|
33
34
|
"react": "0.0.0-experimental-ee8509801-20230117"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "1277be9befefadd87cde69797a1786b69f242a4e"
|
|
36
37
|
}
|
package/src/plopfile.js
CHANGED
|
@@ -10,6 +10,7 @@ const validBrickName = /^[a-z][a-z0-9]*(-[a-z0-9]+)+$/;
|
|
|
10
10
|
|
|
11
11
|
const rootDir = process.cwd();
|
|
12
12
|
const bricksDir = path.join(rootDir, "bricks");
|
|
13
|
+
const sharedDir = path.join(rootDir, "shared");
|
|
13
14
|
|
|
14
15
|
const packageJson = JSON.parse(
|
|
15
16
|
await readFile(path.join(rootDir, "package.json"))
|
|
@@ -25,10 +26,17 @@ export default function (
|
|
|
25
26
|
const isOnGitHub = packageJson.homepage.includes("github.com");
|
|
26
27
|
const dependencies = {};
|
|
27
28
|
const devDependencies = {};
|
|
29
|
+
const libDevDependencies = {};
|
|
28
30
|
for (const [dep, version] of Object.entries(yoPackageJson.devDependencies)) {
|
|
29
31
|
switch (dep) {
|
|
30
|
-
case "@next-core/build-next-
|
|
32
|
+
case "@next-core/build-next-libs":
|
|
33
|
+
libDevDependencies[dep] = version;
|
|
34
|
+
break;
|
|
31
35
|
case "@next-core/test-next":
|
|
36
|
+
libDevDependencies[dep] = version;
|
|
37
|
+
// NOTE: Intentionally fallthrough
|
|
38
|
+
// eslint-disable-next-line no-fallthrough
|
|
39
|
+
case "@next-core/build-next-bricks":
|
|
32
40
|
devDependencies[dep] = version;
|
|
33
41
|
break;
|
|
34
42
|
default:
|
|
@@ -37,6 +45,7 @@ export default function (
|
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
plop.setPartial("scope", isOnGitHub ? "@next-bricks" : "@bricks");
|
|
48
|
+
plop.setPartial("libScope", isOnGitHub ? "@next-shared" : "@shared");
|
|
40
49
|
plop.setPartial("homepage", packageJson.homepage.replace(/\/$/, ""));
|
|
41
50
|
plop.setPartial(
|
|
42
51
|
"repository",
|
|
@@ -51,6 +60,10 @@ export default function (
|
|
|
51
60
|
"devDependencies",
|
|
52
61
|
getObjectPartialInPackageJson(devDependencies)
|
|
53
62
|
);
|
|
63
|
+
plop.setPartial(
|
|
64
|
+
"libDevDependencies",
|
|
65
|
+
getObjectPartialInPackageJson(libDevDependencies)
|
|
66
|
+
);
|
|
54
67
|
|
|
55
68
|
// create your generators here
|
|
56
69
|
plop.setGenerator("basics", {
|
|
@@ -73,6 +86,10 @@ export default function (
|
|
|
73
86
|
name: "Create a new brick package",
|
|
74
87
|
value: "bricks",
|
|
75
88
|
},
|
|
89
|
+
{
|
|
90
|
+
name: "Create a new shared library",
|
|
91
|
+
value: "shared",
|
|
92
|
+
},
|
|
76
93
|
],
|
|
77
94
|
},
|
|
78
95
|
{
|
|
@@ -117,6 +134,25 @@ export default function (
|
|
|
117
134
|
.sort();
|
|
118
135
|
},
|
|
119
136
|
},
|
|
137
|
+
{
|
|
138
|
+
type: "input",
|
|
139
|
+
name: "libName",
|
|
140
|
+
message: "Your library name:",
|
|
141
|
+
when(data) {
|
|
142
|
+
return data.type === "shared";
|
|
143
|
+
},
|
|
144
|
+
validate(value) {
|
|
145
|
+
if (!validPkgName.test(value)) {
|
|
146
|
+
return "Please enter a lower-kebab-case library name.";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (existsSync(path.join(sharedDir, value))) {
|
|
150
|
+
return `Library "${value}" exists, please enter another name.`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return true;
|
|
154
|
+
},
|
|
155
|
+
},
|
|
120
156
|
{
|
|
121
157
|
type: "input",
|
|
122
158
|
name: "brickName",
|
|
@@ -214,6 +250,15 @@ export default function (
|
|
|
214
250
|
templateFiles: "templates/bricks",
|
|
215
251
|
},
|
|
216
252
|
];
|
|
253
|
+
} else if (data.type === "shared") {
|
|
254
|
+
return [
|
|
255
|
+
{
|
|
256
|
+
type: "addMany",
|
|
257
|
+
destination: "shared/{{libName}}",
|
|
258
|
+
base: "templates/shared",
|
|
259
|
+
templateFiles: "templates/shared",
|
|
260
|
+
},
|
|
261
|
+
];
|
|
217
262
|
}
|
|
218
263
|
return [];
|
|
219
264
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{> libScope }}/{{libName}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"homepage": "{{> homepage }}/tree/master/shared/{{libName}}",
|
|
5
|
+
"repository": {{> repository }},
|
|
6
|
+
"license": "{{> license}}",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
"./types": {
|
|
14
|
+
"types": "./dist/types/types.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rimraf dist",
|
|
20
|
+
"prestart": "npm run clean",
|
|
21
|
+
"start": "concurrently -k -n types,main \"npm run start:types\" \"npm run start:main\"",
|
|
22
|
+
"start:main": "cross-env NODE_ENV=development build-next-libs --watch",
|
|
23
|
+
"start:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types --project tsconfig.build.json --watch",
|
|
24
|
+
"prebuild": "npm run clean",
|
|
25
|
+
"build": "npm run build:types && npm run build:main",
|
|
26
|
+
"build:main": "cross-env NODE_ENV=production build-next-libs",
|
|
27
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types --project tsconfig.build.json",
|
|
28
|
+
"test": "cross-env NODE_ENV='test' test-next",
|
|
29
|
+
"test:ci": "cross-env NODE_ENV='test' CI=true test-next"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {{> libDevDependencies }}
|
|
32
|
+
}
|
|
File without changes
|