create-zephyr-apps 0.0.7 → 0.0.8
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/.github/workflows/pull_request.yml +56 -0
- package/.vscode/settings.json +75 -0
- package/biome.json +37 -0
- package/dist/index.cjs +132 -107
- package/dist/index.mjs +130 -105
- package/dist/package/utils/constants.d.ts +1 -1
- package/dist/package/utils/end.d.ts +1 -1
- package/package/index.ts +176 -112
- package/package/utils/constants.ts +64 -58
- package/package/utils/end.ts +14 -27
- package/package/utils/types.ts +1 -1
- package/package.json +33 -20
- package/rslib.config.ts +36 -37
- package/tsconfig.json +1 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: pull_request
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
workflow_dispatch:
|
|
6
|
+
inputs:
|
|
7
|
+
branch:
|
|
8
|
+
description: "Branch to run workflow on"
|
|
9
|
+
required: true
|
|
10
|
+
default: "main"
|
|
11
|
+
|
|
12
|
+
env:
|
|
13
|
+
NX_BRANCH: ${{ github.event.number || github.ref_name }}
|
|
14
|
+
NODE_VERSION: 18
|
|
15
|
+
|
|
16
|
+
concurrency:
|
|
17
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
18
|
+
cancel-in-progress: true
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
cache:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
with:
|
|
26
|
+
fetch-depth: 0
|
|
27
|
+
- uses: pnpm/action-setup@v4
|
|
28
|
+
|
|
29
|
+
- name: Setup Node.js
|
|
30
|
+
uses: actions/setup-node@v3
|
|
31
|
+
with:
|
|
32
|
+
node-version-file: ".nvmrc"
|
|
33
|
+
cache: "pnpm"
|
|
34
|
+
- run: pnpm i --frozen-lockfile
|
|
35
|
+
|
|
36
|
+
lint:
|
|
37
|
+
needs: cache
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
with:
|
|
42
|
+
fetch-depth: 0
|
|
43
|
+
- uses: nrwl/nx-set-shas@v4
|
|
44
|
+
- uses: pnpm/action-setup@v4
|
|
45
|
+
|
|
46
|
+
- name: Setup Node.js
|
|
47
|
+
uses: actions/setup-node@v3
|
|
48
|
+
with:
|
|
49
|
+
node-version-file: ".nvmrc"
|
|
50
|
+
cache: "pnpm"
|
|
51
|
+
|
|
52
|
+
- name: Install dependencies
|
|
53
|
+
run: pnpm i --frozen-lockfile
|
|
54
|
+
|
|
55
|
+
- name: Lint
|
|
56
|
+
run: pnpm lint
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files.associations": {
|
|
3
|
+
".code-workspace": "jsonc",
|
|
4
|
+
".stylelintrc": "jsonc",
|
|
5
|
+
"stylelintrc": "jsonc",
|
|
6
|
+
"README": "markdown"
|
|
7
|
+
},
|
|
8
|
+
"search.useIgnoreFiles": true,
|
|
9
|
+
"search.exclude": {
|
|
10
|
+
"**/dist": true,
|
|
11
|
+
"**/*.log": true,
|
|
12
|
+
"**/*.pid": true,
|
|
13
|
+
"**/.git": true,
|
|
14
|
+
"**/node_modules": true
|
|
15
|
+
},
|
|
16
|
+
"files.eol": "\n",
|
|
17
|
+
"files.trimTrailingWhitespace": true,
|
|
18
|
+
"files.insertFinalNewline": true,
|
|
19
|
+
//
|
|
20
|
+
"javascript.validate.enable": false,
|
|
21
|
+
"typescript.validate.enable": true,
|
|
22
|
+
"css.validate": false,
|
|
23
|
+
"[css]": {
|
|
24
|
+
"editor.formatOnType": true,
|
|
25
|
+
"editor.formatOnPaste": true,
|
|
26
|
+
"editor.formatOnSave": true
|
|
27
|
+
},
|
|
28
|
+
"editor.codeActionsOnSave": {
|
|
29
|
+
"quickfix.biome": "explicit"
|
|
30
|
+
},
|
|
31
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
32
|
+
"editor.formatOnSave": true,
|
|
33
|
+
"[typescript]": {
|
|
34
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
35
|
+
"editor.codeActionsOnSave": {
|
|
36
|
+
"quickfix.biome": "explicit",
|
|
37
|
+
"source.organizeImports": "never",
|
|
38
|
+
"source.organizeImports.biome": "explicit"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"[typescriptreact]": {
|
|
42
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
43
|
+
"editor.codeActionsOnSave": {
|
|
44
|
+
"quickfix.biome": "explicit",
|
|
45
|
+
"source.organizeImports": "never",
|
|
46
|
+
"source.organizeImports.biome": "explicit"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"[json]": {
|
|
50
|
+
"editor.defaultFormatter": "biomejs.biome"
|
|
51
|
+
},
|
|
52
|
+
"[jsonc]": {
|
|
53
|
+
"editor.defaultFormatter": "biomejs.biome"
|
|
54
|
+
},
|
|
55
|
+
"[javascriptreact]": {
|
|
56
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
57
|
+
"editor.codeActionsOnSave": {
|
|
58
|
+
"quickfix.biome": "explicit",
|
|
59
|
+
"source.organizeImports": "never",
|
|
60
|
+
"source.organizeImports.biome": "explicit"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"[javascript]": {
|
|
64
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
65
|
+
"editor.codeActionsOnSave": {
|
|
66
|
+
"quickfix.biome": "explicit",
|
|
67
|
+
"source.organizeImports": "never",
|
|
68
|
+
"source.organizeImports.biome": "explicit"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
72
|
+
"[github-actions-workflow]": {
|
|
73
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
74
|
+
}
|
|
75
|
+
}
|
package/biome.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"defaultBranch": "main",
|
|
6
|
+
"clientKind": "git",
|
|
7
|
+
"useIgnoreFile": true
|
|
8
|
+
},
|
|
9
|
+
"formatter": {
|
|
10
|
+
"enabled": true,
|
|
11
|
+
"indentStyle": "space"
|
|
12
|
+
},
|
|
13
|
+
"javascript": {
|
|
14
|
+
"formatter": {
|
|
15
|
+
"quoteStyle": "single",
|
|
16
|
+
"arrowParentheses": "asNeeded",
|
|
17
|
+
"jsxQuoteStyle": "double",
|
|
18
|
+
"lineWidth": 80
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"linter": {
|
|
22
|
+
"enabled": true,
|
|
23
|
+
"rules": {
|
|
24
|
+
"recommended": true,
|
|
25
|
+
"suspicious": {
|
|
26
|
+
"noDuplicateFontNames": "off"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"organizeImports": {
|
|
31
|
+
"enabled": true
|
|
32
|
+
},
|
|
33
|
+
"files": {
|
|
34
|
+
"ignoreUnknown": true,
|
|
35
|
+
"ignore": [".vscode/**/*", "node_modules/**/*", "dist/**/*"]
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -28,53 +28,15 @@ var __webpack_require__ = {};
|
|
|
28
28
|
};
|
|
29
29
|
})();
|
|
30
30
|
var __webpack_exports__ = {};
|
|
31
|
-
const promises_namespaceObject = require("node:timers/promises");
|
|
32
31
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
32
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
33
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
34
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
35
|
+
const promises_namespaceObject = require("node:timers/promises");
|
|
36
|
+
const prompts_namespaceObject = require("@clack/prompts");
|
|
33
37
|
const external_chalk_namespaceObject = require("chalk");
|
|
34
38
|
var external_chalk_default = /*#__PURE__*/ __webpack_require__.n(external_chalk_namespaceObject);
|
|
35
|
-
const
|
|
36
|
-
const prompts_namespaceObject = require("@clack/prompts");
|
|
37
|
-
function end_note({ project }) {
|
|
38
|
-
try {
|
|
39
|
-
(0, external_child_process_namespaceObject.exec)("git config user.name", (err, stdout, stderr)=>{
|
|
40
|
-
const user_name = stdout.toString().trim();
|
|
41
|
-
const repo_name = project.path.split('/').pop();
|
|
42
|
-
let next_steps;
|
|
43
|
-
next_steps = 'web' === project.type ? [
|
|
44
|
-
`cd ${repo_name}`,
|
|
45
|
-
"pnpm install",
|
|
46
|
-
"rm -rf .git",
|
|
47
|
-
"git init",
|
|
48
|
-
`git remote add origin https://github.com/${user_name.length >= 1 ? user_name : 'YourUsername'}/${repo_name}.git`,
|
|
49
|
-
"git add .",
|
|
50
|
-
'git commit -m "Initial commit"',
|
|
51
|
-
"pnpm run build"
|
|
52
|
-
] : [
|
|
53
|
-
`cd ${repo_name}`,
|
|
54
|
-
"pnpm install",
|
|
55
|
-
"rm -rf .git",
|
|
56
|
-
"git init",
|
|
57
|
-
external_chalk_default().magenta(`git remote add origin https://github.com/${user_name.length >= 1 ? user_name : 'YourUsername'}/${repo_name}.git`),
|
|
58
|
-
"git add .",
|
|
59
|
-
'git commit -m "Initial commit"',
|
|
60
|
-
"ZC=1 pnpm run start",
|
|
61
|
-
`\n--------------------------------\n`,
|
|
62
|
-
"Make your first commit and link it to the remote repository!",
|
|
63
|
-
`Read more about how Module Federation works with Zephyr and why steps above are required: ${external_chalk_default().underline(external_chalk_default().cyan('https://docs.zephyr-cloud.io/how-to/mf-guide'))}`
|
|
64
|
-
];
|
|
65
|
-
(0, prompts_namespaceObject.note)(external_chalk_default().cyan(next_steps.join('\n')), 'Next steps.');
|
|
66
|
-
});
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error(error);
|
|
69
|
-
} finally{
|
|
70
|
-
const end_notes = [
|
|
71
|
-
`Discord: ${external_chalk_default().underline(external_chalk_default().cyan('https://zephyr-cloud.io/discord'))}`,
|
|
72
|
-
`Documentation: ${'web' === project.type ? external_chalk_default().underline(external_chalk_default().cyan('https://docs.zephyr-cloud.io/recipes')) : external_chalk_default().underline(external_chalk_default().cyan('https://docs.zephyr-cloud.io/recipes/repack-mf'))}`,
|
|
73
|
-
`Open an issue: ${external_chalk_default().underline(external_chalk_default().cyan('https://github.com/ZephyrCloudIO/create-zephyr-apps/issues'))}`
|
|
74
|
-
];
|
|
75
|
-
(0, prompts_namespaceObject.note)(Object.values(end_notes).join('\n'), 'Problems?');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
39
|
+
const external_tempy_namespaceObject = require("tempy");
|
|
78
40
|
const TEMPLATES = {
|
|
79
41
|
'rspack-project': {
|
|
80
42
|
label: 'React + Rspack',
|
|
@@ -132,10 +94,69 @@ const TEMPLATES = {
|
|
|
132
94
|
framework: 'react'
|
|
133
95
|
}
|
|
134
96
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
97
|
+
function end_note({ project }) {
|
|
98
|
+
try {
|
|
99
|
+
(0, external_node_child_process_namespaceObject.exec)('git config user.name', (err, stdout, stderr)=>{
|
|
100
|
+
const user_name = stdout.toString().trim();
|
|
101
|
+
const repo_name = project.path.split('/').pop();
|
|
102
|
+
let next_steps;
|
|
103
|
+
next_steps = 'web' === project.type ? [
|
|
104
|
+
`cd ${repo_name}`,
|
|
105
|
+
'pnpm install',
|
|
106
|
+
'pnpm run build'
|
|
107
|
+
] : [
|
|
108
|
+
`cd ${repo_name}`,
|
|
109
|
+
'pnpm install',
|
|
110
|
+
external_chalk_default().magenta(`git remote add origin https://github.com/${user_name.length >= 1 ? user_name : 'YourUsername'}/${repo_name}.git`),
|
|
111
|
+
'ZC=1 pnpm run start',
|
|
112
|
+
'\n--------------------------------\n',
|
|
113
|
+
'Make sure to commit and add a remote to the remote repository!',
|
|
114
|
+
`Read more about how Module Federation works with Zephyr: ${external_chalk_default().underline(external_chalk_default().cyan('https://docs.zephyr-cloud.io/how-to/mf-guide'))}`
|
|
115
|
+
];
|
|
116
|
+
(0, prompts_namespaceObject.note)(external_chalk_default().cyan(next_steps.join('\n')), 'Next steps.');
|
|
117
|
+
});
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error(error);
|
|
120
|
+
} finally{
|
|
121
|
+
const end_notes = [
|
|
122
|
+
`Discord: ${external_chalk_default().underline(external_chalk_default().cyan('https://zephyr-cloud.io/discord'))}`,
|
|
123
|
+
`Documentation: ${'web' === project.type ? external_chalk_default().underline(external_chalk_default().cyan('https://docs.zephyr-cloud.io/recipes')) : external_chalk_default().underline(external_chalk_default().cyan('https://docs.zephyr-cloud.io/recipes/repack-mf'))}`,
|
|
124
|
+
`Open an issue: ${external_chalk_default().underline(external_chalk_default().cyan('https://github.com/ZephyrCloudIO/create-zephyr-apps/issues'))}`
|
|
125
|
+
];
|
|
126
|
+
(0, prompts_namespaceObject.note)(Object.values(end_notes).join('\n'), 'Problems?');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function runCmd(cmd, cwd) {
|
|
130
|
+
return new Promise((resolve, reject)=>{
|
|
131
|
+
(0, external_node_child_process_namespaceObject.exec)(cmd, {
|
|
132
|
+
cwd
|
|
133
|
+
}, (err, stdout, stderr)=>{
|
|
134
|
+
if (err) {
|
|
135
|
+
console.error(`Error executing command: ${cmd}`, err);
|
|
136
|
+
reject(err);
|
|
137
|
+
} else resolve();
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async function initializeGit(projectPath) {
|
|
142
|
+
const shouldInit = await (0, prompts_namespaceObject.confirm)({
|
|
143
|
+
message: 'Would you like to initialize a new Git repository?',
|
|
144
|
+
initialValue: true
|
|
145
|
+
});
|
|
146
|
+
if ((0, prompts_namespaceObject.isCancel)(shouldInit)) {
|
|
147
|
+
(0, prompts_namespaceObject.cancel)('Operation cancelled');
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
|
150
|
+
if (shouldInit) {
|
|
151
|
+
await runCmd('git init', projectPath);
|
|
152
|
+
await runCmd('git config user.email "zephyrbot@zephyr-cloud.io"', projectPath);
|
|
153
|
+
await runCmd('git config user.name "Zephyr Bot"', projectPath);
|
|
154
|
+
await runCmd('git add .', projectPath);
|
|
155
|
+
await runCmd('git commit -m "Initial commit from Zephyr"', projectPath);
|
|
156
|
+
await runCmd('git config --unset user.email', projectPath);
|
|
157
|
+
await runCmd('git config --unset user.name', projectPath);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
139
160
|
async function main() {
|
|
140
161
|
console.clear();
|
|
141
162
|
await (0, promises_namespaceObject.setTimeout)(1000);
|
|
@@ -198,65 +219,69 @@ async function main() {
|
|
|
198
219
|
const project_path = project.path.replace('./', '').trim();
|
|
199
220
|
const s = (0, prompts_namespaceObject.spinner)();
|
|
200
221
|
s.start(external_chalk_default().cyan(`Creating project in ${project_path}`));
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
222
|
+
const outputPath = external_node_path_default().join(process.cwd(), project.path);
|
|
223
|
+
try {
|
|
224
|
+
if ('web' === project.type) await new Promise((resolve, reject)=>{
|
|
225
|
+
(0, external_node_child_process_namespaceObject.exec)(command_web, async (err)=>{
|
|
226
|
+
if (err) {
|
|
227
|
+
s.stop(external_chalk_default().bgRed(external_chalk_default().black(`Error cloning repository to ${project_path}...`)));
|
|
228
|
+
return reject(err);
|
|
229
|
+
}
|
|
230
|
+
const clonedPath = external_node_path_default().join(temp_dir, 'examples', project.templates);
|
|
231
|
+
try {
|
|
232
|
+
await external_node_fs_namespaceObject.promises.rm(external_node_path_default().join(clonedPath, '.git'), {
|
|
233
|
+
recursive: true,
|
|
234
|
+
force: true
|
|
235
|
+
});
|
|
236
|
+
await external_node_fs_namespaceObject.promises.cp(clonedPath, outputPath, {
|
|
237
|
+
recursive: true,
|
|
238
|
+
force: true
|
|
239
|
+
});
|
|
240
|
+
s.stop(external_chalk_default().green(`Project successfully created at ${external_chalk_default().underline(project_path)}`));
|
|
241
|
+
resolve();
|
|
242
|
+
} catch (copyErr) {
|
|
243
|
+
s.stop(external_chalk_default().bgRed(external_chalk_default().black(`Error copying template to ${project_path}...`)));
|
|
244
|
+
reject(copyErr);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
else if ('react-native' === project.type) await new Promise((resolve, reject)=>{
|
|
249
|
+
(0, external_node_child_process_namespaceObject.exec)(command_react_native, async (err)=>{
|
|
250
|
+
if (err) {
|
|
251
|
+
s.stop(external_chalk_default().bgRed(external_chalk_default().black(`Error cloning repository to ${project_path}...`)));
|
|
252
|
+
return reject(err);
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
await external_node_fs_namespaceObject.promises.rm(external_node_path_default().join(temp_dir, '.git'), {
|
|
256
|
+
recursive: true,
|
|
257
|
+
force: true
|
|
258
|
+
});
|
|
259
|
+
await external_node_fs_namespaceObject.promises.cp(temp_dir, outputPath, {
|
|
260
|
+
recursive: true,
|
|
261
|
+
force: true
|
|
262
|
+
});
|
|
263
|
+
s.stop(external_chalk_default().green(`Project successfully created at ${external_chalk_default().underline(project_path)}`));
|
|
264
|
+
resolve();
|
|
265
|
+
} catch (copyErr) {
|
|
266
|
+
s.stop(external_chalk_default().bgRed(external_chalk_default().black(`Error copying files to ${project_path}...`)));
|
|
267
|
+
reject(copyErr);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
await initializeGit(outputPath);
|
|
272
|
+
(0, prompts_namespaceObject.note)('Git repository and initial commit created successfully!');
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.error(error);
|
|
275
|
+
process.exit(2);
|
|
276
|
+
} finally{
|
|
277
|
+
await external_node_fs_namespaceObject.promises.rm(temp_dir, {
|
|
278
|
+
recursive: true,
|
|
279
|
+
force: true
|
|
280
|
+
});
|
|
281
|
+
end_note({
|
|
282
|
+
project
|
|
283
|
+
});
|
|
284
|
+
}
|
|
260
285
|
}
|
|
261
286
|
main().catch(console.error);
|
|
262
287
|
var __webpack_export_target__ = exports;
|