create-zephyr-apps 0.0.8 → 0.0.39
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/.eslintignore +3 -0
- package/README.md +7 -14
- package/dist/index.js +218 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +46 -0
- package/dist/templates.d.ts +10 -0
- package/dist/templates.js +71 -0
- package/dist/templates.js.map +1 -0
- package/package.json +28 -45
- package/.github/workflows/pull_request.yml +0 -56
- package/.nvmrc +0 -1
- package/.vscode/settings.json +0 -75
- package/biome.json +0 -37
- package/dist/index.cjs +0 -291
- package/dist/index.mjs +0 -255
- package/dist/package/utils/constants.d.ts +0 -63
- package/dist/package/utils/end.d.ts +0 -4
- package/dist/package/utils/types.d.ts +0 -24
- package/dist/rslib.config.d.ts +0 -2
- package/package/index.ts +0 -255
- package/package/utils/constants.ts +0 -74
- package/package/utils/end.ts +0 -43
- package/package/utils/types.ts +0 -32
- package/rslib.config.ts +0 -41
- package/tsconfig.json +0 -30
- /package/dist/{package/index.d.ts → index.d.ts} +0 -0
package/dist/index.cjs
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __webpack_require__ = {};
|
|
4
|
-
(()=>{
|
|
5
|
-
__webpack_require__.n = function(module) {
|
|
6
|
-
var getter = module && module.__esModule ? function() {
|
|
7
|
-
return module['default'];
|
|
8
|
-
} : function() {
|
|
9
|
-
return module;
|
|
10
|
-
};
|
|
11
|
-
__webpack_require__.d(getter, {
|
|
12
|
-
a: getter
|
|
13
|
-
});
|
|
14
|
-
return getter;
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
(()=>{
|
|
18
|
-
__webpack_require__.d = function(exports1, definition) {
|
|
19
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: definition[key]
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
})();
|
|
25
|
-
(()=>{
|
|
26
|
-
__webpack_require__.o = function(obj, prop) {
|
|
27
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
28
|
-
};
|
|
29
|
-
})();
|
|
30
|
-
var __webpack_exports__ = {};
|
|
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");
|
|
37
|
-
const external_chalk_namespaceObject = require("chalk");
|
|
38
|
-
var external_chalk_default = /*#__PURE__*/ __webpack_require__.n(external_chalk_namespaceObject);
|
|
39
|
-
const external_tempy_namespaceObject = require("tempy");
|
|
40
|
-
const TEMPLATES = {
|
|
41
|
-
'rspack-project': {
|
|
42
|
-
label: 'React + Rspack',
|
|
43
|
-
hint: 'A simple application build by Rspack.',
|
|
44
|
-
framework: 'react'
|
|
45
|
-
},
|
|
46
|
-
'react-vite-ts': {
|
|
47
|
-
label: 'A simple React application build by Vite',
|
|
48
|
-
hint: 'You will be building React app powered by Vite.',
|
|
49
|
-
framework: 'react'
|
|
50
|
-
},
|
|
51
|
-
'react-vite-mf': {
|
|
52
|
-
label: 'React + Vite + Webpack + Rspack',
|
|
53
|
-
hint: 'You will be building federated React apps powered by Vite, Webpack and Rspack.',
|
|
54
|
-
framework: 'react'
|
|
55
|
-
},
|
|
56
|
-
'angular-vite': {
|
|
57
|
-
label: 'Angular app with Vite',
|
|
58
|
-
hint: 'You will be building an Angular app powered by Vite.',
|
|
59
|
-
framework: 'angular'
|
|
60
|
-
},
|
|
61
|
-
'react-webpack-mf': {
|
|
62
|
-
label: 'React + Webpack',
|
|
63
|
-
hint: 'A React application with Module Federation, using Webpack as the bundler.',
|
|
64
|
-
framework: 'react'
|
|
65
|
-
},
|
|
66
|
-
'nx-rspack-mf': {
|
|
67
|
-
label: 'React + Nx + Rspack',
|
|
68
|
-
hint: 'A React application with Module Federation, using Nx as Monorepo manager and Rspack as the bundler.',
|
|
69
|
-
framework: 'react'
|
|
70
|
-
},
|
|
71
|
-
'nx-webpack-mf': {
|
|
72
|
-
label: 'React + Nx + Webpack',
|
|
73
|
-
hint: 'React applications with Module Federation, using Nx as Monorepo manager and Webpack as the bundler.',
|
|
74
|
-
framework: 'react'
|
|
75
|
-
},
|
|
76
|
-
'ng-nx': {
|
|
77
|
-
label: 'Angular app with Nx',
|
|
78
|
-
hint: 'An Angular application with Nx as Monorepo manager.',
|
|
79
|
-
framework: 'angular'
|
|
80
|
-
},
|
|
81
|
-
'qwik-1.5': {
|
|
82
|
-
label: 'Qwik + Vite',
|
|
83
|
-
hint: 'A Qwik v1.5 app using Vite as the bundler.',
|
|
84
|
-
framework: 'qwik'
|
|
85
|
-
},
|
|
86
|
-
'react-rspack-tractor-2.0': {
|
|
87
|
-
label: 'React + Rspack + Tractor 2.0',
|
|
88
|
-
hint: 'A React application using Rspack as the bundler and Tractor 2.0 as the module federation manager.',
|
|
89
|
-
framework: 'react'
|
|
90
|
-
},
|
|
91
|
-
'turbo-rspack-mf': {
|
|
92
|
-
label: 'Turbo + Rspack + Module Federation',
|
|
93
|
-
hint: 'A monorepo using Turborepo, React, and Rspack as the bundler.',
|
|
94
|
-
framework: 'react'
|
|
95
|
-
}
|
|
96
|
-
};
|
|
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
|
-
}
|
|
160
|
-
async function main() {
|
|
161
|
-
console.clear();
|
|
162
|
-
await (0, promises_namespaceObject.setTimeout)(1000);
|
|
163
|
-
(0, prompts_namespaceObject.updateSettings)({
|
|
164
|
-
aliases: {
|
|
165
|
-
w: 'up',
|
|
166
|
-
s: 'down',
|
|
167
|
-
a: 'left',
|
|
168
|
-
d: 'right'
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
(0, prompts_namespaceObject.note)('npx create-zephyr-apps@latest');
|
|
172
|
-
(0, prompts_namespaceObject.intro)(`${external_chalk_default().bgCyan(external_chalk_default().black(' Create federated applications with Zephyr '))}`);
|
|
173
|
-
const project = await (0, prompts_namespaceObject.group)({
|
|
174
|
-
path: ({ results })=>(0, prompts_namespaceObject.text)({
|
|
175
|
-
message: 'Where should we create your project?',
|
|
176
|
-
placeholder: './sparkling-solid',
|
|
177
|
-
validate: (value)=>{
|
|
178
|
-
if (!value) return 'Please enter a path.';
|
|
179
|
-
if ('.' !== value[0]) return 'Please enter a relative path.';
|
|
180
|
-
}
|
|
181
|
-
}),
|
|
182
|
-
type: ()=>(0, prompts_namespaceObject.select)({
|
|
183
|
-
message: 'What type of project you are creating?',
|
|
184
|
-
initialValue: 'web',
|
|
185
|
-
options: [
|
|
186
|
-
{
|
|
187
|
-
value: 'web',
|
|
188
|
-
label: 'Web',
|
|
189
|
-
hint: 'You will be choosing from a selection of templates provided by us.'
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
value: 'react-native',
|
|
193
|
-
label: 'React Native',
|
|
194
|
-
hint: 'This is a comprehensive example project provided by us. You will be building React Native powered by Re.Pack.'
|
|
195
|
-
}
|
|
196
|
-
]
|
|
197
|
-
}),
|
|
198
|
-
templates: ({ results })=>{
|
|
199
|
-
if ('web' === results.type) return (0, prompts_namespaceObject.select)({
|
|
200
|
-
message: 'Pick a template: ',
|
|
201
|
-
initialValue: 'react-rspack-mf',
|
|
202
|
-
maxItems: 5,
|
|
203
|
-
options: Object.keys(TEMPLATES).map((template)=>({
|
|
204
|
-
value: template,
|
|
205
|
-
label: external_chalk_default().cyan(TEMPLATES[template].label),
|
|
206
|
-
hint: TEMPLATES[template].hint
|
|
207
|
-
}))
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}, {
|
|
211
|
-
onCancel: ()=>{
|
|
212
|
-
(0, prompts_namespaceObject.cancel)('Operation cancelled.');
|
|
213
|
-
process.exit(0);
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
const temp_dir = external_tempy_namespaceObject.temporaryDirectory();
|
|
217
|
-
const command_web = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-examples.git -b main ${temp_dir}`;
|
|
218
|
-
const command_react_native = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-repack-example.git -b main ${temp_dir}`;
|
|
219
|
-
const project_path = project.path.replace('./', '').trim();
|
|
220
|
-
const s = (0, prompts_namespaceObject.spinner)();
|
|
221
|
-
s.start(external_chalk_default().cyan(`Creating project in ${project_path}`));
|
|
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
|
-
}
|
|
285
|
-
}
|
|
286
|
-
main().catch(console.error);
|
|
287
|
-
var __webpack_export_target__ = exports;
|
|
288
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
289
|
-
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
290
|
-
value: true
|
|
291
|
-
});
|
package/dist/index.mjs
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_timers_promises_aedbf14c__ from "node:timers/promises";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__ from "@clack/prompts";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_chalk__ from "chalk";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE_tempy__ from "tempy";
|
|
9
|
-
const TEMPLATES = {
|
|
10
|
-
'rspack-project': {
|
|
11
|
-
label: 'React + Rspack',
|
|
12
|
-
hint: 'A simple application build by Rspack.',
|
|
13
|
-
framework: 'react'
|
|
14
|
-
},
|
|
15
|
-
'react-vite-ts': {
|
|
16
|
-
label: 'A simple React application build by Vite',
|
|
17
|
-
hint: 'You will be building React app powered by Vite.',
|
|
18
|
-
framework: 'react'
|
|
19
|
-
},
|
|
20
|
-
'react-vite-mf': {
|
|
21
|
-
label: 'React + Vite + Webpack + Rspack',
|
|
22
|
-
hint: 'You will be building federated React apps powered by Vite, Webpack and Rspack.',
|
|
23
|
-
framework: 'react'
|
|
24
|
-
},
|
|
25
|
-
'angular-vite': {
|
|
26
|
-
label: 'Angular app with Vite',
|
|
27
|
-
hint: 'You will be building an Angular app powered by Vite.',
|
|
28
|
-
framework: 'angular'
|
|
29
|
-
},
|
|
30
|
-
'react-webpack-mf': {
|
|
31
|
-
label: 'React + Webpack',
|
|
32
|
-
hint: 'A React application with Module Federation, using Webpack as the bundler.',
|
|
33
|
-
framework: 'react'
|
|
34
|
-
},
|
|
35
|
-
'nx-rspack-mf': {
|
|
36
|
-
label: 'React + Nx + Rspack',
|
|
37
|
-
hint: 'A React application with Module Federation, using Nx as Monorepo manager and Rspack as the bundler.',
|
|
38
|
-
framework: 'react'
|
|
39
|
-
},
|
|
40
|
-
'nx-webpack-mf': {
|
|
41
|
-
label: 'React + Nx + Webpack',
|
|
42
|
-
hint: 'React applications with Module Federation, using Nx as Monorepo manager and Webpack as the bundler.',
|
|
43
|
-
framework: 'react'
|
|
44
|
-
},
|
|
45
|
-
'ng-nx': {
|
|
46
|
-
label: 'Angular app with Nx',
|
|
47
|
-
hint: 'An Angular application with Nx as Monorepo manager.',
|
|
48
|
-
framework: 'angular'
|
|
49
|
-
},
|
|
50
|
-
'qwik-1.5': {
|
|
51
|
-
label: 'Qwik + Vite',
|
|
52
|
-
hint: 'A Qwik v1.5 app using Vite as the bundler.',
|
|
53
|
-
framework: 'qwik'
|
|
54
|
-
},
|
|
55
|
-
'react-rspack-tractor-2.0': {
|
|
56
|
-
label: 'React + Rspack + Tractor 2.0',
|
|
57
|
-
hint: 'A React application using Rspack as the bundler and Tractor 2.0 as the module federation manager.',
|
|
58
|
-
framework: 'react'
|
|
59
|
-
},
|
|
60
|
-
'turbo-rspack-mf': {
|
|
61
|
-
label: 'Turbo + Rspack + Module Federation',
|
|
62
|
-
hint: 'A monorepo using Turborepo, React, and Rspack as the bundler.',
|
|
63
|
-
framework: 'react'
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
function end_note({ project }) {
|
|
67
|
-
try {
|
|
68
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.exec)('git config user.name', (err, stdout, stderr)=>{
|
|
69
|
-
const user_name = stdout.toString().trim();
|
|
70
|
-
const repo_name = project.path.split('/').pop();
|
|
71
|
-
let next_steps;
|
|
72
|
-
next_steps = 'web' === project.type ? [
|
|
73
|
-
`cd ${repo_name}`,
|
|
74
|
-
'pnpm install',
|
|
75
|
-
'pnpm run build'
|
|
76
|
-
] : [
|
|
77
|
-
`cd ${repo_name}`,
|
|
78
|
-
'pnpm install',
|
|
79
|
-
__WEBPACK_EXTERNAL_MODULE_chalk__["default"].magenta(`git remote add origin https://github.com/${user_name.length >= 1 ? user_name : 'YourUsername'}/${repo_name}.git`),
|
|
80
|
-
'ZC=1 pnpm run start',
|
|
81
|
-
'\n--------------------------------\n',
|
|
82
|
-
'Make sure to commit and add a remote to the remote repository!',
|
|
83
|
-
`Read more about how Module Federation works with Zephyr: ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('https://docs.zephyr-cloud.io/how-to/mf-guide'))}`
|
|
84
|
-
];
|
|
85
|
-
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.note)(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan(next_steps.join('\n')), 'Next steps.');
|
|
86
|
-
});
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error(error);
|
|
89
|
-
} finally{
|
|
90
|
-
const end_notes = [
|
|
91
|
-
`Discord: ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('https://zephyr-cloud.io/discord'))}`,
|
|
92
|
-
`Documentation: ${'web' === project.type ? __WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('https://docs.zephyr-cloud.io/recipes')) : __WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('https://docs.zephyr-cloud.io/recipes/repack-mf'))}`,
|
|
93
|
-
`Open an issue: ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('https://github.com/ZephyrCloudIO/create-zephyr-apps/issues'))}`
|
|
94
|
-
];
|
|
95
|
-
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.note)(Object.values(end_notes).join('\n'), 'Problems?');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function runCmd(cmd, cwd) {
|
|
99
|
-
return new Promise((resolve, reject)=>{
|
|
100
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.exec)(cmd, {
|
|
101
|
-
cwd
|
|
102
|
-
}, (err, stdout, stderr)=>{
|
|
103
|
-
if (err) {
|
|
104
|
-
console.error(`Error executing command: ${cmd}`, err);
|
|
105
|
-
reject(err);
|
|
106
|
-
} else resolve();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
async function initializeGit(projectPath) {
|
|
111
|
-
const shouldInit = await (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.confirm)({
|
|
112
|
-
message: 'Would you like to initialize a new Git repository?',
|
|
113
|
-
initialValue: true
|
|
114
|
-
});
|
|
115
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.isCancel)(shouldInit)) {
|
|
116
|
-
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.cancel)('Operation cancelled');
|
|
117
|
-
process.exit(0);
|
|
118
|
-
}
|
|
119
|
-
if (shouldInit) {
|
|
120
|
-
await runCmd('git init', projectPath);
|
|
121
|
-
await runCmd('git config user.email "zephyrbot@zephyr-cloud.io"', projectPath);
|
|
122
|
-
await runCmd('git config user.name "Zephyr Bot"', projectPath);
|
|
123
|
-
await runCmd('git add .', projectPath);
|
|
124
|
-
await runCmd('git commit -m "Initial commit from Zephyr"', projectPath);
|
|
125
|
-
await runCmd('git config --unset user.email', projectPath);
|
|
126
|
-
await runCmd('git config --unset user.name', projectPath);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async function main() {
|
|
130
|
-
console.clear();
|
|
131
|
-
await (0, __WEBPACK_EXTERNAL_MODULE_node_timers_promises_aedbf14c__.setTimeout)(1000);
|
|
132
|
-
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.updateSettings)({
|
|
133
|
-
aliases: {
|
|
134
|
-
w: 'up',
|
|
135
|
-
s: 'down',
|
|
136
|
-
a: 'left',
|
|
137
|
-
d: 'right'
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.note)('npx create-zephyr-apps@latest');
|
|
141
|
-
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.intro)(`${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgCyan(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(' Create federated applications with Zephyr '))}`);
|
|
142
|
-
const project = await (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.group)({
|
|
143
|
-
path: ({ results })=>(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.text)({
|
|
144
|
-
message: 'Where should we create your project?',
|
|
145
|
-
placeholder: './sparkling-solid',
|
|
146
|
-
validate: (value)=>{
|
|
147
|
-
if (!value) return 'Please enter a path.';
|
|
148
|
-
if ('.' !== value[0]) return 'Please enter a relative path.';
|
|
149
|
-
}
|
|
150
|
-
}),
|
|
151
|
-
type: ()=>(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select)({
|
|
152
|
-
message: 'What type of project you are creating?',
|
|
153
|
-
initialValue: 'web',
|
|
154
|
-
options: [
|
|
155
|
-
{
|
|
156
|
-
value: 'web',
|
|
157
|
-
label: 'Web',
|
|
158
|
-
hint: 'You will be choosing from a selection of templates provided by us.'
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
value: 'react-native',
|
|
162
|
-
label: 'React Native',
|
|
163
|
-
hint: 'This is a comprehensive example project provided by us. You will be building React Native powered by Re.Pack.'
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
}),
|
|
167
|
-
templates: ({ results })=>{
|
|
168
|
-
if ('web' === results.type) return (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select)({
|
|
169
|
-
message: 'Pick a template: ',
|
|
170
|
-
initialValue: 'react-rspack-mf',
|
|
171
|
-
maxItems: 5,
|
|
172
|
-
options: Object.keys(TEMPLATES).map((template)=>({
|
|
173
|
-
value: template,
|
|
174
|
-
label: __WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan(TEMPLATES[template].label),
|
|
175
|
-
hint: TEMPLATES[template].hint
|
|
176
|
-
}))
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}, {
|
|
180
|
-
onCancel: ()=>{
|
|
181
|
-
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.cancel)('Operation cancelled.');
|
|
182
|
-
process.exit(0);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
const temp_dir = __WEBPACK_EXTERNAL_MODULE_tempy__.temporaryDirectory();
|
|
186
|
-
const command_web = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-examples.git -b main ${temp_dir}`;
|
|
187
|
-
const command_react_native = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-repack-example.git -b main ${temp_dir}`;
|
|
188
|
-
const project_path = project.path.replace('./', '').trim();
|
|
189
|
-
const s = (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.spinner)();
|
|
190
|
-
s.start(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan(`Creating project in ${project_path}`));
|
|
191
|
-
const outputPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), project.path);
|
|
192
|
-
try {
|
|
193
|
-
if ('web' === project.type) await new Promise((resolve, reject)=>{
|
|
194
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.exec)(command_web, async (err)=>{
|
|
195
|
-
if (err) {
|
|
196
|
-
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgRed(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(`Error cloning repository to ${project_path}...`)));
|
|
197
|
-
return reject(err);
|
|
198
|
-
}
|
|
199
|
-
const clonedPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(temp_dir, 'examples', project.templates);
|
|
200
|
-
try {
|
|
201
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.rm(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(clonedPath, '.git'), {
|
|
202
|
-
recursive: true,
|
|
203
|
-
force: true
|
|
204
|
-
});
|
|
205
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.cp(clonedPath, outputPath, {
|
|
206
|
-
recursive: true,
|
|
207
|
-
force: true
|
|
208
|
-
});
|
|
209
|
-
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].green(`Project successfully created at ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(project_path)}`));
|
|
210
|
-
resolve();
|
|
211
|
-
} catch (copyErr) {
|
|
212
|
-
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgRed(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(`Error copying template to ${project_path}...`)));
|
|
213
|
-
reject(copyErr);
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
else if ('react-native' === project.type) await new Promise((resolve, reject)=>{
|
|
218
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.exec)(command_react_native, async (err)=>{
|
|
219
|
-
if (err) {
|
|
220
|
-
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgRed(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(`Error cloning repository to ${project_path}...`)));
|
|
221
|
-
return reject(err);
|
|
222
|
-
}
|
|
223
|
-
try {
|
|
224
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.rm(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(temp_dir, '.git'), {
|
|
225
|
-
recursive: true,
|
|
226
|
-
force: true
|
|
227
|
-
});
|
|
228
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.cp(temp_dir, outputPath, {
|
|
229
|
-
recursive: true,
|
|
230
|
-
force: true
|
|
231
|
-
});
|
|
232
|
-
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].green(`Project successfully created at ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(project_path)}`));
|
|
233
|
-
resolve();
|
|
234
|
-
} catch (copyErr) {
|
|
235
|
-
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgRed(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(`Error copying files to ${project_path}...`)));
|
|
236
|
-
reject(copyErr);
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
await initializeGit(outputPath);
|
|
241
|
-
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.note)('Git repository and initial commit created successfully!');
|
|
242
|
-
} catch (error) {
|
|
243
|
-
console.error(error);
|
|
244
|
-
process.exit(2);
|
|
245
|
-
} finally{
|
|
246
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.rm(temp_dir, {
|
|
247
|
-
recursive: true,
|
|
248
|
-
force: true
|
|
249
|
-
});
|
|
250
|
-
end_note({
|
|
251
|
-
project
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
main().catch(console.error);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
declare const REPO_OWNER = "ZephyrCloudIO";
|
|
2
|
-
declare const REPO_NAME = "zephyr-examples";
|
|
3
|
-
declare const REPACK_REPO = "zephyr-repack-example";
|
|
4
|
-
declare const BASE_REPO = "ZephyrCloudIO/zephyr-examples";
|
|
5
|
-
declare const REPACK_REPO_PATH = "ZephyrCloudIO/zephyr-repack-example";
|
|
6
|
-
declare const TEMPLATES: {
|
|
7
|
-
'rspack-project': {
|
|
8
|
-
label: string;
|
|
9
|
-
hint: string;
|
|
10
|
-
framework: string;
|
|
11
|
-
};
|
|
12
|
-
'react-vite-ts': {
|
|
13
|
-
label: string;
|
|
14
|
-
hint: string;
|
|
15
|
-
framework: string;
|
|
16
|
-
};
|
|
17
|
-
'react-vite-mf': {
|
|
18
|
-
label: string;
|
|
19
|
-
hint: string;
|
|
20
|
-
framework: string;
|
|
21
|
-
};
|
|
22
|
-
'angular-vite': {
|
|
23
|
-
label: string;
|
|
24
|
-
hint: string;
|
|
25
|
-
framework: string;
|
|
26
|
-
};
|
|
27
|
-
'react-webpack-mf': {
|
|
28
|
-
label: string;
|
|
29
|
-
hint: string;
|
|
30
|
-
framework: string;
|
|
31
|
-
};
|
|
32
|
-
'nx-rspack-mf': {
|
|
33
|
-
label: string;
|
|
34
|
-
hint: string;
|
|
35
|
-
framework: string;
|
|
36
|
-
};
|
|
37
|
-
'nx-webpack-mf': {
|
|
38
|
-
label: string;
|
|
39
|
-
hint: string;
|
|
40
|
-
framework: string;
|
|
41
|
-
};
|
|
42
|
-
'ng-nx': {
|
|
43
|
-
label: string;
|
|
44
|
-
hint: string;
|
|
45
|
-
framework: string;
|
|
46
|
-
};
|
|
47
|
-
'qwik-1.5': {
|
|
48
|
-
label: string;
|
|
49
|
-
hint: string;
|
|
50
|
-
framework: string;
|
|
51
|
-
};
|
|
52
|
-
'react-rspack-tractor-2.0': {
|
|
53
|
-
label: string;
|
|
54
|
-
hint: string;
|
|
55
|
-
framework: string;
|
|
56
|
-
};
|
|
57
|
-
'turbo-rspack-mf': {
|
|
58
|
-
label: string;
|
|
59
|
-
hint: string;
|
|
60
|
-
framework: string;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
export { REPO_OWNER, REPO_NAME, REPACK_REPO, BASE_REPO, REPACK_REPO_PATH, TEMPLATES, };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface GithubTreeItem {
|
|
2
|
-
path: string;
|
|
3
|
-
type: 'tree' | 'blob';
|
|
4
|
-
}
|
|
5
|
-
export interface ExampleMetadata {
|
|
6
|
-
name: string;
|
|
7
|
-
description: string;
|
|
8
|
-
path: string;
|
|
9
|
-
}
|
|
10
|
-
export interface WebCreationOptions {
|
|
11
|
-
path: string;
|
|
12
|
-
template: string;
|
|
13
|
-
framework: string;
|
|
14
|
-
}
|
|
15
|
-
export interface ReactNativeCreationOptions {
|
|
16
|
-
path: string;
|
|
17
|
-
}
|
|
18
|
-
export interface CLIOptions {
|
|
19
|
-
path: string;
|
|
20
|
-
type: 'web' | 'react-native';
|
|
21
|
-
/** At the moment, if users opt for web they will only be asked for a template without host name and remote_name */
|
|
22
|
-
templates: string | undefined;
|
|
23
|
-
install: boolean;
|
|
24
|
-
}
|
package/dist/rslib.config.d.ts
DELETED