create-module-federation 0.0.0-next-20250306125957 → 0.0.0-next-20250310022208

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.
Files changed (2) hide show
  1. package/dist/index.js +44 -52
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -98,8 +98,8 @@ const packageDir = __WEBPACK_EXTERNAL_MODULE_path__["default"].resolve(create_di
98
98
  const OTHER_TYPE = {
99
99
  zephyr: {
100
100
  label: 'zephyr',
101
- command: 'npm create zephyr@latest',
102
- hint: 'npm create zephyr@latest'
101
+ packageName: 'zephyr-apps@latest',
102
+ hint: 'create zephyr-apps@latest'
103
103
  }
104
104
  };
105
105
  function upperFirst(str) {
@@ -119,8 +119,7 @@ function logHelpMessage(name, templates) {
119
119
  --override override files in target directory
120
120
 
121
121
  Templates:
122
-
123
- ${templates.join(', ')}
122
+ ${templates.filter((t)=>!t.startsWith('zephyr')).join(', ')}
124
123
  `);
125
124
  }
126
125
  function pkgFromUserAgent(userAgent) {
@@ -190,6 +189,27 @@ function getTemplateName({ projectType, roleType, framework }, args) {
190
189
  function getTemplateDir(templateName) {
191
190
  return `templates/${templateName}/`;
192
191
  }
192
+ async function getProjectType(template) {
193
+ if (!template) return checkCancel(await (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select)({
194
+ message: 'Please select the type of project you want to create:',
195
+ options: [
196
+ {
197
+ value: "app",
198
+ label: 'Application'
199
+ },
200
+ {
201
+ value: "lib",
202
+ label: 'Lib'
203
+ },
204
+ {
205
+ value: "zephyr",
206
+ label: 'Zephyr Powered (Learn more at https://zephyr-cloud.io)'
207
+ }
208
+ ]
209
+ }));
210
+ if (template.includes('lib')) return "lib";
211
+ return "app";
212
+ }
193
213
  async function forgeTemplate({ projectType, argv, templateParameters, distFolder }) {
194
214
  let framework = 'modern';
195
215
  let roleType = "provider";
@@ -247,32 +267,11 @@ async function forgeTemplate({ projectType, argv, templateParameters, distFolder
247
267
  };
248
268
  const templateDir = getTemplateDir(templateName);
249
269
  let commonTemplateDir = '';
250
- commonTemplateDir = "lib" === projectType ? 'templates/lib-common/' : `templates/${framework}-common/`;
251
- await renderTemplate(commonTemplateDir);
270
+ if ("lib" === projectType) commonTemplateDir = 'templates/lib-common/';
271
+ else if ('app' === projectType) commonTemplateDir = `templates/${framework}-common/`;
272
+ if (commonTemplateDir) await renderTemplate(commonTemplateDir);
252
273
  await renderTemplate(templateDir);
253
274
  }
254
- async function getProjectType(template) {
255
- if (!template) return checkCancel(await (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select)({
256
- message: 'Please select the type of project you want to create:',
257
- options: [
258
- {
259
- value: "app",
260
- label: 'Application'
261
- },
262
- {
263
- value: "lib",
264
- label: 'Lib'
265
- },
266
- {
267
- value: "other",
268
- label: 'Other'
269
- }
270
- ]
271
- }));
272
- if (template.startsWith('create-')) return "other";
273
- if (template.includes('lib')) return "lib";
274
- return "app";
275
- }
276
275
  async function create({ name, templates }) {
277
276
  const argv = (0, __WEBPACK_EXTERNAL_MODULE_minimist__["default"])(process.argv.slice(2), {
278
277
  alias: {
@@ -293,6 +292,22 @@ async function create({ name, templates }) {
293
292
  const pkgInfo = pkgFromUserAgent(process.env['npm_config_user_agent']);
294
293
  const pkgManager = pkgInfo ? pkgInfo.name : 'npm';
295
294
  const mfVersion = "0.10.0";
295
+ argv.template = templates.includes(argv.template || '') ? argv.template : void 0;
296
+ const projectType = await getProjectType(argv.template);
297
+ if ("zephyr" === projectType) {
298
+ const zephyrPackage = OTHER_TYPE['zephyr'].packageName;
299
+ const zephyrCommand = `${pkgManager} create ${zephyrPackage}`;
300
+ (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.note)(`Running: ${zephyrCommand}`, 'Launching Zephyr setup');
301
+ (0, __WEBPACK_EXTERNAL_MODULE_child_process__.spawnSync)(pkgManager, [
302
+ 'create',
303
+ zephyrPackage
304
+ ], {
305
+ stdio: 'inherit',
306
+ shell: true
307
+ });
308
+ (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.outro)('Done.');
309
+ return;
310
+ }
296
311
  const mfName = argv.name || checkCancel(await (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.text)({
297
312
  message: 'Please input Module Federation name:',
298
313
  placeholder: 'mf_project_name',
@@ -319,28 +334,6 @@ async function create({ name, templates }) {
319
334
  }));
320
335
  if ('no' === option) cancelAndExit();
321
336
  }
322
- argv.template = templates.includes(argv.template || '') ? argv.template : void 0;
323
- const projectType = await getProjectType(argv.template);
324
- if ("other" === projectType) {
325
- const otherOptions = Object.keys(OTHER_TYPE).map((key)=>({
326
- value: key,
327
- label: OTHER_TYPE[key].label,
328
- hint: OTHER_TYPE[key].hint
329
- }));
330
- const otherProjectKey = checkCancel(await (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select)({
331
- message: 'Please select the type of template you want to create:',
332
- options: otherOptions
333
- }));
334
- const { command } = OTHER_TYPE[otherProjectKey];
335
- const commandWithManager = command.replace(/^npm create /, `${pkgManager} create `);
336
- const npmParams = 'npm' === pkgManager && pkgInfo?.version && parseInt(pkgInfo.version.split('.')[0], 10) < 7 ? ' --' : '';
337
- const realCommand = `${commandWithManager}${npmParams} -d ${distFolder} -n ${mfName}${argv.override ? ' --override' : ''}`;
338
- const [cmd, ...cmdArgs] = realCommand.split(' ');
339
- const { status } = (0, __WEBPACK_EXTERNAL_MODULE_child_process__.spawnSync)(cmd, cmdArgs, {
340
- stdio: 'inherit'
341
- });
342
- process.exit(status ?? 0);
343
- }
344
337
  await forgeTemplate({
345
338
  projectType,
346
339
  argv,
@@ -364,8 +357,7 @@ const TEMPLATES = [
364
357
  'rslib',
365
358
  'rslib-storybook',
366
359
  'consumer-modern',
367
- 'consumer-rsbuild',
368
- 'create-zephyr'
360
+ 'consumer-rsbuild'
369
361
  ];
370
362
  create({
371
363
  name: 'Module Federation',
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Create a new Module Federation project",
4
4
  "public": true,
5
5
  "sideEffects": false,
6
- "version": "0.0.0-next-20250306125957",
6
+ "version": "0.0.0-next-20250310022208",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",