piral-cli 0.14.24-beta.4163 → 0.14.24-beta.4168

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 (72) hide show
  1. package/lib/apps/new-pilet.js +5 -3
  2. package/lib/apps/new-pilet.js.map +1 -1
  3. package/lib/apps/new-piral.js +2 -2
  4. package/lib/apps/new-piral.js.map +1 -1
  5. package/lib/apps/publish-pilet.js +1 -1
  6. package/lib/apps/publish-pilet.js.map +1 -1
  7. package/lib/apps/publish-piral.js +1 -1
  8. package/lib/apps/publish-piral.js.map +1 -1
  9. package/lib/apps/upgrade-pilet.js +2 -2
  10. package/lib/apps/upgrade-pilet.js.map +1 -1
  11. package/lib/apps/upgrade-piral.js +1 -1
  12. package/lib/apps/upgrade-piral.js.map +1 -1
  13. package/lib/bundler.js +1 -1
  14. package/lib/bundler.js.map +1 -1
  15. package/lib/common/clients/lerna.d.ts +1 -0
  16. package/lib/common/clients/lerna.js +5 -1
  17. package/lib/common/clients/lerna.js.map +1 -1
  18. package/lib/common/clients/npm.d.ts +1 -0
  19. package/lib/common/clients/npm.js +5 -1
  20. package/lib/common/clients/npm.js.map +1 -1
  21. package/lib/common/clients/pnpm.d.ts +1 -0
  22. package/lib/common/clients/pnpm.js +5 -1
  23. package/lib/common/clients/pnpm.js.map +1 -1
  24. package/lib/common/clients/rush.d.ts +1 -0
  25. package/lib/common/clients/rush.js +30 -3
  26. package/lib/common/clients/rush.js.map +1 -1
  27. package/lib/common/clients/yarn.d.ts +1 -0
  28. package/lib/common/clients/yarn.js +5 -1
  29. package/lib/common/clients/yarn.js.map +1 -1
  30. package/lib/common/emulator.js +1 -1
  31. package/lib/common/emulator.js.map +1 -1
  32. package/lib/common/inspect.js +2 -1
  33. package/lib/common/inspect.js.map +1 -1
  34. package/lib/common/npm.d.ts +7 -6
  35. package/lib/common/npm.js +16 -11
  36. package/lib/common/npm.js.map +1 -1
  37. package/lib/common/pack.js +1 -1
  38. package/lib/common/pack.js.map +1 -1
  39. package/lib/common/package.d.ts +6 -6
  40. package/lib/common/package.js +10 -1
  41. package/lib/common/package.js.map +1 -1
  42. package/lib/common/scaffold.js +1 -1
  43. package/lib/common/scaffold.js.map +1 -1
  44. package/lib/external/index.js +1982 -92
  45. package/lib/injectors/pilet.js +2 -2
  46. package/lib/injectors/pilet.js.map +1 -1
  47. package/lib/types/internal.d.ts +9 -1
  48. package/package.json +4 -2
  49. package/src/apps/new-pilet.ts +9 -5
  50. package/src/apps/new-piral.ts +4 -4
  51. package/src/apps/publish-pilet.ts +2 -2
  52. package/src/apps/publish-piral.ts +2 -2
  53. package/src/apps/upgrade-pilet.ts +4 -4
  54. package/src/apps/upgrade-piral.ts +2 -2
  55. package/src/bundler.test.ts +1 -1
  56. package/src/bundler.ts +2 -2
  57. package/src/common/clients/lerna.ts +2 -0
  58. package/src/common/clients/npm.ts +2 -0
  59. package/src/common/clients/pnpm.ts +2 -0
  60. package/src/common/clients/rush.ts +40 -4
  61. package/src/common/clients/yarn.ts +2 -0
  62. package/src/common/emulator.ts +2 -2
  63. package/src/common/inspect.ts +2 -1
  64. package/src/common/npm.test.ts +26 -24
  65. package/src/common/npm.ts +11 -6
  66. package/src/common/pack.test.ts +1 -1
  67. package/src/common/pack.ts +2 -2
  68. package/src/common/package.ts +16 -7
  69. package/src/common/scaffold.ts +2 -2
  70. package/src/external/index.ts +2 -1
  71. package/src/injectors/pilet.ts +3 -3
  72. package/src/types/internal.ts +6 -1
@@ -12,7 +12,7 @@ import { isGitPackage, isLocalPackage, makeGitUrl, makeFilePath, makePiletExtern
12
12
  import { filesTar, filesOnceTar, declarationEntryExtensions, bundlerNames } from './constants';
13
13
  import { getHash, checkIsDirectory, matchFiles } from './io';
14
14
  import { readJson, copy, updateExistingJson, findFile, checkExists } from './io';
15
- import { Framework, FileInfo, PiletsInfo, TemplateFileLocation, SharedDependency } from '../types';
15
+ import { Framework, FileInfo, PiletsInfo, TemplateFileLocation, SharedDependency, PackageData } from '../types';
16
16
 
17
17
  function appendBundler(devDependencies: Record<string, string>, bundler: string, version: string) {
18
18
  if (bundler && bundler !== 'none') {
@@ -159,7 +159,7 @@ function findPackage(pck: string | Array<string>, baseDir: string) {
159
159
  return undefined;
160
160
  }
161
161
 
162
- export function readPiralPackage(root: string, name: string) {
162
+ export function readPiralPackage(root: string, name: string): Promise<PackageData> {
163
163
  log('generalDebug_0003', `Reading the piral package in "${root}" ...`);
164
164
  const path = getPiralPath(root, name);
165
165
  return readJson(path, 'package.json');
@@ -319,10 +319,19 @@ function isTemplateFileLocation(item: string | TemplateFileLocation): item is Te
319
319
  return typeof item === 'object';
320
320
  }
321
321
 
322
+ function tryFindPackageVersion(packageName: string): string {
323
+ try {
324
+ const { version } = require(`${packageName}/package.json`);
325
+ return version;
326
+ } catch {
327
+ return undefined;
328
+ }
329
+ }
330
+
322
331
  export async function copyPiralFiles(
323
332
  root: string,
324
333
  name: string,
325
- piralInfo: any,
334
+ piralInfo: PackageData,
326
335
  forceOverwrite: ForceOverwrite,
327
336
  variables: Record<string, string>,
328
337
  originalFiles?: Array<FileInfo>,
@@ -342,7 +351,7 @@ export async function copyPiralFiles(
342
351
  await copyFiles(files, forceOverwrite, originalFiles, variables);
343
352
  }
344
353
 
345
- export function getPiletsInfo(piralInfo: any): PiletsInfo {
354
+ export function getPiletsInfo(piralInfo: Partial<PackageData>): PiletsInfo {
346
355
  const {
347
356
  files = [],
348
357
  externals = [],
@@ -491,7 +500,7 @@ export async function patchPiletPackage(
491
500
  root: string,
492
501
  name: string,
493
502
  version: string,
494
- piralInfo: any,
503
+ piralInfo: PackageData,
495
504
  fromEmulator: boolean,
496
505
  newInfo?: { language: SourceLanguage; bundler: string },
497
506
  ) {
@@ -539,7 +548,7 @@ export async function patchPiletPackage(
539
548
  return deps;
540
549
  }, {}),
541
550
  ...allExternals.filter(isValidDependency).reduce((deps, name) => {
542
- const version = piralDependencies[name];
551
+ const version = piralDependencies[name] || tryFindPackageVersion(name);
543
552
 
544
553
  if (version || newInfo) {
545
554
  // set only if we have an explicit version or we are in the scaffolding case
@@ -576,7 +585,7 @@ export async function patchPiletPackage(
576
585
  /**
577
586
  * Returns true if its an emulator package, otherwise it has to be a "raw" app shell.
578
587
  */
579
- export function checkAppShellPackage(appPackage: any) {
588
+ export function checkAppShellPackage(appPackage: PackageData) {
580
589
  const { piralCLI = { generated: false, version: cliVersion } } = appPackage;
581
590
 
582
591
  if (piralCLI.generated) {
@@ -1,5 +1,5 @@
1
1
  import { join, dirname, resolve, basename, isAbsolute } from 'path';
2
- import { installPackage } from './npm';
2
+ import { installNpmPackage } from './npm';
3
3
  import { ForceOverwrite, SourceLanguage } from './enums';
4
4
  import { createDirectory, createFileIfNotExists, updateExistingJson } from './io';
5
5
  import { log, fail } from './log';
@@ -36,7 +36,7 @@ async function getTemplateFiles(
36
36
  if (templatePackageName.startsWith('.')) {
37
37
  templatePackageName = resolve(process.cwd(), templatePackageName);
38
38
  } else {
39
- await installPackage('npm', templatePackageName, __dirname, '--registry', registry);
39
+ await installNpmPackage('npm', templatePackageName, __dirname, '--registry', registry);
40
40
  }
41
41
 
42
42
  const templateRunner = getTemplatePackage(templatePackageName);
@@ -1,6 +1,7 @@
1
1
  import logger = require('@parcel/logger');
2
2
  import stripAnsi = require('strip-ansi');
3
3
  import inquirer = require('inquirer');
4
+ import jju = require('jju');
4
5
  import glob = require('glob');
5
6
  import tar = require('tar');
6
7
  import FormData = require('form-data');
@@ -10,4 +11,4 @@ import mime = require('mime');
10
11
  import getPort = require('get-port');
11
12
  import open = require('open');
12
13
 
13
- export { logger, inquirer, glob, tar, FormData, rc, axios, mime, stripAnsi, getPort, open };
14
+ export { logger, inquirer, glob, tar, FormData, rc, axios, mime, stripAnsi, getPort, open, jju };
@@ -6,7 +6,7 @@ import { KrasInjector, KrasResponse, KrasRequest, KrasInjectorConfig, KrasConfig
6
6
  import { log } from '../common/log';
7
7
  import { getPiletSpecMeta } from '../common/spec';
8
8
  import { config } from '../common/config';
9
- import { axios, mime } from '../external';
9
+ import { axios, mime, jju } from '../external';
10
10
  import { Bundler } from '../types';
11
11
 
12
12
  const { host } = config;
@@ -35,8 +35,8 @@ function fillPiletMeta(pilet: Pilet, basePath: string, metaFile: string) {
35
35
  const { root, bundler } = pilet;
36
36
  const metaPath = join(root, metaFile);
37
37
  const packagePath = join(root, 'package.json');
38
- const def = JSON.parse(readFileSync(packagePath, 'utf8'));
39
- const metaOverride = existsSync(metaPath) ? JSON.parse(readFileSync(metaPath, 'utf8')) : undefined;
38
+ const def = jju.parse(readFileSync(packagePath, 'utf8'));
39
+ const metaOverride = existsSync(metaPath) ? jju.parse(readFileSync(metaPath, 'utf8')) : undefined;
40
40
  const file = bundler.bundle.name.replace(/^[\/\\]/, '');
41
41
  const target = join(bundler.bundle.dir, file);
42
42
  const url = new URL(file, basePath);
@@ -1,4 +1,4 @@
1
- import { LogLevels } from './common';
1
+ import type { LogLevels, PiletsInfo } from './common';
2
2
 
3
3
  export interface PackageData {
4
4
  name: string;
@@ -13,6 +13,11 @@ export interface PackageData {
13
13
  email?: string;
14
14
  };
15
15
  custom?: any;
16
+ pilets?: PiletsInfo;
17
+ piralCLI?: { generated: boolean; version: string };
18
+ dependencies: Record<string, string>;
19
+ peerDependencies: Record<string, string>;
20
+ devDependencies: Record<string, string>;
16
21
  }
17
22
 
18
23
  export interface PackageFiles {