@open-mova/cli 0.1.9 → 0.1.10

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/README.md CHANGED
@@ -159,8 +159,6 @@ mova cap open ios
159
159
  mova create mi-aplicacion
160
160
  cd mi-aplicacion
161
161
  npm install
162
- npm --prefix packages/core install
163
- npm --prefix packages/core run build
164
162
  npm --prefix mfs/home install
165
163
  mova start
166
164
  ```
@@ -1,2 +1,2 @@
1
1
  export type MicrofrontendProfile = 'minimal' | 'demo';
2
- export declare function configureDownloadedMicrofrontend(destination: string, applicationRoot: string, name: string, port: number, profile: MicrofrontendProfile): void;
2
+ export declare function configureDownloadedMicrofrontend(destination: string, name: string, port: number, profile: MicrofrontendProfile): void;
@@ -1,7 +1,7 @@
1
- import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
- import { join, relative } from 'node:path';
1
+ import { readFileSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
3
  import { toDisplayName, toRemoteName } from '../utils/names.js';
4
- export function configureDownloadedMicrofrontend(destination, applicationRoot, name, port, profile) {
4
+ export function configureDownloadedMicrofrontend(destination, name, port, profile) {
5
5
  const projectName = `mova-mf-${name}`;
6
6
  const packagePath = join(destination, 'package.json');
7
7
  const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
@@ -14,11 +14,7 @@ export function configureDownloadedMicrofrontend(destination, applicationRoot, n
14
14
  writeFileSync(join(destination, 'src/app/app.config.ts'), minimalAppConfig());
15
15
  }
16
16
  else {
17
- const core = join(applicationRoot, 'packages/core');
18
- if (!existsSync(core)) {
19
- throw new Error('El perfil demo requiere packages/core en la aplicación.');
20
- }
21
- packageJson.dependencies['@open-mova/core'] = `file:${relative(destination, core)}`;
17
+ packageJson.dependencies['@open-mova/core'] = '^0.1.9';
22
18
  }
23
19
  writeFileSync(packagePath, `${JSON.stringify(packageJson, null, 2)}\n`);
24
20
  const angularPath = join(destination, 'angular.json');
@@ -16,7 +16,7 @@ export function createMicrofrontend(applicationRoot, configuration, options) {
16
16
  let template;
17
17
  try {
18
18
  template = downloadTaggedProject('open-mova-mf-template', destination, options.templateVersion);
19
- configureDownloadedMicrofrontend(destination, applicationRoot, name, port, profile);
19
+ configureDownloadedMicrofrontend(destination, name, port, profile);
20
20
  }
21
21
  catch (error) {
22
22
  rmSync(destination, { recursive: true, force: true });
@@ -6,5 +6,5 @@ export interface ShellVersion {
6
6
  }
7
7
  export declare function listShellVersions(): string[];
8
8
  export declare function downloadShell(destination: string, requestedVersion?: string): ShellVersion;
9
- export declare function downloadTaggedProject(project: 'open-mova-shell' | 'open-mova-mf-template' | 'open-mova-core', destination: string, requestedVersion?: string): ShellVersion;
9
+ export declare function downloadTaggedProject(project: 'open-mova-shell' | 'open-mova-mf-template', destination: string, requestedVersion?: string): ShellVersion;
10
10
  export declare function configureDownloadedShell(destination: string, applicationName: string, includesStarterMicrofrontend: boolean): void;
@@ -4,6 +4,7 @@ import { basename, join } from 'node:path';
4
4
  import { tmpdir } from 'node:os';
5
5
  export const SHELL_REPOSITORY = 'https://github.com/rgarciadelongoria/open-mova.git';
6
6
  const VERSION_PATTERN = /^v(\d+)\.(\d+)\.(\d+)$/;
7
+ const PUBLISHED_CORE_VERSION = '^0.1.9';
7
8
  const EXCLUDED_ENTRIES = new Set([
8
9
  '.git',
9
10
  '.angular',
@@ -44,9 +45,7 @@ export function downloadTaggedProject(project, destination, requestedVersion) {
44
45
  '--branch', version, SHELL_REPOSITORY, checkout,
45
46
  ]);
46
47
  const source = join(checkout, project);
47
- const requiredFiles = project === 'open-mova-core'
48
- ? ['package.json', 'src/index.ts']
49
- : ['package.json', 'angular.json', 'src/main.ts'];
48
+ const requiredFiles = ['package.json', 'angular.json', 'src/main.ts'];
50
49
  for (const requiredFile of requiredFiles) {
51
50
  if (!existsSync(join(source, requiredFile))) {
52
51
  throw new Error(`El tag ${version} no contiene ${project}: falta ${requiredFile}.`);
@@ -74,14 +73,12 @@ export function configureDownloadedShell(destination, applicationName, includesS
74
73
  packageJson.version = '0.1.0';
75
74
  packageJson.private = true;
76
75
  if (packageJson.dependencies?.['@open-mova/core']) {
77
- packageJson.dependencies['@open-mova/core'] = 'file:packages/core';
78
- }
79
- writeFileSync(packagePath, `${JSON.stringify(packageJson, null, 2)}\n`);
80
- if (packageJson.dependencies?.['@open-mova/core']) {
81
- // Las rutas file: cambian al copiar la shell fuera del monorepo.
76
+ // También permite crear apps desde tags anteriores a la publicación en npm.
77
+ packageJson.dependencies['@open-mova/core'] = PUBLISHED_CORE_VERSION;
82
78
  rmSync(packageLockPath, { force: true });
83
79
  }
84
- else if (existsSync(packageLockPath)) {
80
+ writeFileSync(packagePath, `${JSON.stringify(packageJson, null, 2)}\n`);
81
+ if (existsSync(packageLockPath)) {
85
82
  const packageLock = JSON.parse(readFileSync(packageLockPath, 'utf8'));
86
83
  packageLock.name = applicationName;
87
84
  packageLock.version = packageJson.version;
@@ -104,16 +101,13 @@ export function configureDownloadedShell(destination, applicationName, includesS
104
101
  writeFileSync(capacitorPath, customizedConfig);
105
102
  }
106
103
  writeFileSync(join(destination, '.nvmrc'), '22\n');
107
- const usesCore = Boolean(packageJson.dependencies?.['@open-mova/core']);
108
- const coreSteps = 'npm --prefix packages/core install\nnpm --prefix packages/core run build\n';
109
- const librarySteps = usesCore || includesStarterMicrofrontend ? coreSteps : '';
110
- const installSteps = `${librarySteps}npm install\n` +
104
+ const installSteps = 'npm install\n' +
111
105
  (includesStarterMicrofrontend ? 'npm --prefix mfs/home install\n' : '');
112
106
  const runSteps = includesStarterMicrofrontend
113
107
  ? 'Inicia `npm --prefix mfs/home start` y `npm start` en dos terminales. Abre `http://localhost:4200/home/inicio`.\n'
114
108
  : 'Registra primero un MF con `mova mf create nombre` y después ejecuta `mova start`.\n';
115
109
  writeFileSync(join(destination, 'README.md'), `# ${applicationName}\n\nAplicación creada con Open Mova. \`mova.config.json\` registra la shell y los microfrontales remotos.\n\n` +
116
- `Instala y compila las dependencias locales en este orden:\n\n` +
110
+ `Instala las dependencias de cada proyecto:\n\n` +
117
111
  `\`\`\`bash\n${installSteps}\`\`\`\n\n${runSteps}`);
118
112
  }
119
113
  function compareVersionsDescending(first, second) {
@@ -1,9 +1,9 @@
1
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, mkdtempSync, renameSync, rmSync } from 'node:fs';
2
2
  import { dirname, join, resolve } from 'node:path';
3
3
  import { createMicrofrontend } from '../application/microfrontend.js';
4
4
  import { addMicrofrontend, writeApplicationConfiguration, } from '../application/configuration.js';
5
5
  import { synchronizeShellConfiguration } from '../application/shell-configuration.js';
6
- import { configureDownloadedShell, downloadShell, downloadTaggedProject, } from '../application/shell-repository.js';
6
+ import { configureDownloadedShell, downloadShell, } from '../application/shell-repository.js';
7
7
  import { normalizeName } from '../utils/names.js';
8
8
  export function registerCreateCommand(program) {
9
9
  program
@@ -24,11 +24,6 @@ export function registerCreateCommand(program) {
24
24
  try {
25
25
  const shell = downloadShell(temporaryApplication, options.shellVersion);
26
26
  shellVersion = shell.version;
27
- const shellPackage = JSON.parse(readFileSync(join(temporaryApplication, 'package.json'), 'utf8'));
28
- const shellUsesCore = Boolean(shellPackage.dependencies?.['@open-mova/core']);
29
- if (shellUsesCore || !options.empty) {
30
- downloadTaggedProject('open-mova-core', join(temporaryApplication, 'packages/core'), shell.version);
31
- }
32
27
  configureDownloadedShell(temporaryApplication, applicationName, !options.empty);
33
28
  let configuration = {
34
29
  schemaVersion: 1,
@@ -58,10 +53,6 @@ export function registerCreateCommand(program) {
58
53
  console.log(`Aplicación creada en ${applicationRoot} con shell ${shellVersion}.`);
59
54
  console.log('Instala las dependencias antes de iniciar el desarrollo:');
60
55
  console.log(` cd ${applicationRoot}`);
61
- const createdWithCore = existsSync(join(applicationRoot, 'packages/core'));
62
- if (createdWithCore) {
63
- console.log(' npm --prefix packages/core install && npm --prefix packages/core run build');
64
- }
65
56
  console.log(' npm install');
66
57
  if (!options.empty) {
67
58
  console.log(' npm --prefix mfs/home install');
@@ -1,10 +1,9 @@
1
- import { existsSync } from 'node:fs';
2
1
  import { join } from 'node:path';
3
2
  import { createMicrofrontend, inspectExistingMicrofrontend } from '../application/microfrontend.js';
4
3
  import { addMicrofrontend, readApplicationConfiguration, requireApplicationRoot, writeApplicationConfiguration, } from '../application/configuration.js';
5
4
  import { synchronizeShellConfiguration } from '../application/shell-configuration.js';
6
5
  import { normalizeName } from '../utils/names.js';
7
- import { downloadTaggedProject, listShellVersions } from '../application/shell-repository.js';
6
+ import { listShellVersions } from '../application/shell-repository.js';
8
7
  export function registerMicrofrontendCommands(program) {
9
8
  const microfrontend = program
10
9
  .command('mf')
@@ -29,9 +28,6 @@ export function registerMicrofrontendCommands(program) {
29
28
  if (options.demo && configuration.shell?.version !== templateVersion) {
30
29
  throw new Error('El perfil demo debe usar el mismo tag que la shell para mantener compatible el contrato nativo.');
31
30
  }
32
- if (options.demo && !existsSync(join(applicationRoot, 'packages/core'))) {
33
- downloadTaggedProject('open-mova-core', join(applicationRoot, 'packages/core'), templateVersion);
34
- }
35
31
  const microfrontendConfiguration = createMicrofrontend(applicationRoot, configuration, {
36
32
  name: normalizedName,
37
33
  directory: options.directory ?? join('mfs', normalizedName),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mova/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "CLI para crear y mantener aplicaciones Open Mova",
5
5
  "license": "MIT",
6
6
  "author": "Open Mova contributors",