piral-cli 0.14.27-beta.4290 → 0.14.28-beta.4363

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": "piral-cli",
3
- "version": "0.14.27-beta.4290",
3
+ "version": "0.14.28-beta.4363",
4
4
  "description": "The standard CLI for creating and building a Piral instance or a Pilet.",
5
5
  "keywords": [
6
6
  "portal",
@@ -79,5 +79,5 @@
79
79
  "typescript": "^4.0.2",
80
80
  "yargs": "^15.4.1"
81
81
  },
82
- "gitHead": "82fec640a46c17aa9ae03dcf2c8ac3895bbabfcb"
82
+ "gitHead": "d9425ff60676c2a1ae73f1d5c13527c58242badd"
83
83
  }
package/src/commands.ts CHANGED
@@ -271,9 +271,11 @@ const allCommands: Array<ToolCommand<any>> = [
271
271
  .boolean('install')
272
272
  .describe('install', 'Already performs the installation of its npm dependencies.')
273
273
  .default('install', apps.newPiralDefaults.install)
274
+ .alias('install', 'package-install')
274
275
  .string('registry')
275
276
  .describe('registry', 'Sets the package registry to use for resolving the dependencies.')
276
277
  .default('registry', apps.newPiralDefaults.registry)
278
+ .alias('registry', 'package-registry')
277
279
  .number('log-level')
278
280
  .describe('log-level', 'Sets the log level to use (1-5).')
279
281
  .default('log-level', apps.newPiralDefaults.logLevel)
@@ -283,6 +285,7 @@ const allCommands: Array<ToolCommand<any>> = [
283
285
  'Sets the tag or version of the package to install. By default, this uses the version of the CLI.',
284
286
  )
285
287
  .default('tag', apps.newPiralDefaults.version)
288
+ .alias('tag', 'piral-version')
286
289
  .choices('force-overwrite', forceOverwriteKeys)
287
290
  .describe('force-overwrite', 'Determines if files should be overwritten by the installation.')
288
291
  .default('force-overwrite', keyOfForceOverwrite(apps.newPiralDefaults.forceOverwrite))
@@ -344,6 +347,7 @@ const allCommands: Array<ToolCommand<any>> = [
344
347
  .boolean('install')
345
348
  .describe('install', 'Already performs the update of its npm dependencies.')
346
349
  .default('install', apps.upgradePiralDefaults.install)
350
+ .alias('install', 'package-install')
347
351
  .choices('npm-client', clientTypeKeys)
348
352
  .describe('npm-client', 'Sets the npm client to be used when upgrading.')
349
353
  .default('npm-client', apps.upgradePiralDefaults.npmClient)
@@ -604,6 +608,7 @@ const allCommands: Array<ToolCommand<any>> = [
604
608
  .choices('mode', publishModeKeys)
605
609
  .describe('mode', 'Sets the authorization mode to use.')
606
610
  .default('mode', apps.publishPiletDefaults.mode)
611
+ .alias('mode', 'auth-mode')
607
612
  .choices('bundler', availableBundlers)
608
613
  .describe('bundler', 'Sets the bundler to use.')
609
614
  .default('bundler', availableBundlers[0])
@@ -658,9 +663,11 @@ const allCommands: Array<ToolCommand<any>> = [
658
663
  .string('registry')
659
664
  .describe('registry', 'Sets the package registry to use for resolving the specified Piral app.')
660
665
  .default('registry', apps.newPiletDefaults.registry)
666
+ .alias('registry', 'package-registry')
661
667
  .boolean('install')
662
668
  .describe('install', 'Already performs the installation of its npm dependencies.')
663
669
  .default('install', apps.newPiletDefaults.install)
670
+ .alias('install', 'package-install')
664
671
  .choices('force-overwrite', forceOverwriteKeys)
665
672
  .describe('force-overwrite', 'Determines if files should be overwritten by the scaffolding.')
666
673
  .default('force-overwrite', keyOfForceOverwrite(apps.newPiletDefaults.forceOverwrite))
@@ -723,6 +730,7 @@ const allCommands: Array<ToolCommand<any>> = [
723
730
  .boolean('install')
724
731
  .describe('install', 'Already performs the update of its npm dependencies.')
725
732
  .default('install', apps.upgradePiletDefaults.install)
733
+ .alias('install', 'package-install')
726
734
  .choices('force-overwrite', forceOverwriteKeys)
727
735
  .describe('force-overwrite', 'Determines if files should be overwritten by the upgrading process.')
728
736
  .default('force-overwrite', keyOfForceOverwrite(apps.upgradePiletDefaults.forceOverwrite))
package/src/common/npm.ts CHANGED
@@ -3,7 +3,7 @@ import { createReadStream, existsSync } from 'fs';
3
3
  import { log, fail } from './log';
4
4
  import { clients, detectClients, isWrapperClient } from './clients';
5
5
  import { config } from './config';
6
- import { legacyCoreExternals, frameworkLibs } from './constants';
6
+ import { legacyCoreExternals, frameworkLibs, defaultRegistry } from './constants';
7
7
  import { inspectPackage } from './inspect';
8
8
  import { readJson, checkExists } from './io';
9
9
  import { clientTypeKeys } from '../helpers';
@@ -125,6 +125,22 @@ export function installNpmDependencies(client: NpmClientType, target = '.'): Pro
125
125
  return installDependencies(target);
126
126
  }
127
127
 
128
+ export async function installNpmPackageFromOptionalRegistry(
129
+ packageRef: string,
130
+ target = '.',
131
+ registry: string,
132
+ ): Promise<void> {
133
+ try {
134
+ await installNpmPackage('npm', packageRef, target, '--registry', registry);
135
+ } catch (e) {
136
+ if (registry === defaultRegistry) {
137
+ throw e;
138
+ }
139
+
140
+ await installNpmPackage('npm', packageRef, target, '--registry', defaultRegistry);
141
+ }
142
+ }
143
+
128
144
  export async function installNpmPackage(
129
145
  client: NpmClientType,
130
146
  packageRef: string,
@@ -1,5 +1,5 @@
1
1
  import { join, dirname, resolve, basename, isAbsolute } from 'path';
2
- import { installNpmPackage } from './npm';
2
+ import { installNpmPackageFromOptionalRegistry } from './npm';
3
3
  import { ForceOverwrite, SourceLanguage } from './enums';
4
4
  import { createDirectory, createFileIfNotExists, updateExistingJson } from './io';
5
5
  import { log, fail } from './log';
@@ -40,7 +40,7 @@ async function getTemplateFiles(
40
40
  templatePackageName = `${templatePackageName}@latest`;
41
41
  }
42
42
 
43
- await installNpmPackage('npm', templatePackageName, __dirname, '--registry', registry);
43
+ await installNpmPackageFromOptionalRegistry(templatePackageName, __dirname, registry);
44
44
  }
45
45
 
46
46
  const templateRunner = getTemplatePackage(templatePackageName);