@ms-cloudpack/cli 0.42.1 → 0.42.3

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 (100) hide show
  1. package/lib/commands/bundle/bundle.d.ts +1 -1
  2. package/lib/commands/bundle/bundle.d.ts.map +1 -1
  3. package/lib/commands/bundle/bundle.js +6 -4
  4. package/lib/commands/bundle/bundle.js.map +1 -1
  5. package/lib/commands/init/bundleAndGetImports.d.ts.map +1 -1
  6. package/lib/commands/init/bundleAndGetImports.js +2 -4
  7. package/lib/commands/init/bundleAndGetImports.js.map +1 -1
  8. package/lib/commands/init/init.js +3 -3
  9. package/lib/commands/init/init.js.map +1 -1
  10. package/lib/commands/start/start.d.ts +1 -1
  11. package/lib/commands/start/start.d.ts.map +1 -1
  12. package/lib/commands/start/start.js +7 -7
  13. package/lib/commands/start/start.js.map +1 -1
  14. package/lib/commands/start/startBundleServer.d.ts.map +1 -1
  15. package/lib/commands/start/startBundleServer.js +1 -2
  16. package/lib/commands/start/startBundleServer.js.map +1 -1
  17. package/lib/commands/sync/sync.d.ts +1 -1
  18. package/lib/commands/sync/sync.d.ts.map +1 -1
  19. package/lib/commands/sync/sync.js +27 -4
  20. package/lib/commands/sync/sync.js.map +1 -1
  21. package/lib/index.d.ts.map +1 -1
  22. package/lib/index.js +0 -10
  23. package/lib/index.js.map +1 -1
  24. package/lib/initTelemetry.d.ts +3 -15
  25. package/lib/initTelemetry.d.ts.map +1 -1
  26. package/lib/initTelemetry.js +6 -19
  27. package/lib/initTelemetry.js.map +1 -1
  28. package/lib/setupReporting.d.ts +3 -0
  29. package/lib/setupReporting.d.ts.map +1 -0
  30. package/lib/{commands/start/setupReporting.js → setupReporting.js} +13 -3
  31. package/lib/setupReporting.js.map +1 -0
  32. package/lib/tasks/bundleTaskWorker.js +1 -1
  33. package/lib/tasks/bundleTaskWorker.js.map +1 -1
  34. package/lib/types/Watcher.d.ts +1 -1
  35. package/lib/types/Watcher.d.ts.map +1 -1
  36. package/lib/types/Watcher.js.map +1 -1
  37. package/package.json +5 -10
  38. package/lib/commands/init/findImports.d.ts +0 -6
  39. package/lib/commands/init/findImports.d.ts.map +0 -1
  40. package/lib/commands/init/findImports.js +0 -73
  41. package/lib/commands/init/findImports.js.map +0 -1
  42. package/lib/commands/start/createBundleRequestForPackage.d.ts +0 -11
  43. package/lib/commands/start/createBundleRequestForPackage.d.ts.map +0 -1
  44. package/lib/commands/start/createBundleRequestForPackage.js +0 -21
  45. package/lib/commands/start/createBundleRequestForPackage.js.map +0 -1
  46. package/lib/commands/start/createBundleTask.d.ts +0 -10
  47. package/lib/commands/start/createBundleTask.d.ts.map +0 -1
  48. package/lib/commands/start/createBundleTask.js +0 -42
  49. package/lib/commands/start/createBundleTask.js.map +0 -1
  50. package/lib/commands/start/setupReporting.d.ts +0 -3
  51. package/lib/commands/start/setupReporting.d.ts.map +0 -1
  52. package/lib/commands/start/setupReporting.js.map +0 -1
  53. package/lib/commands/sync/Task.d.ts +0 -6
  54. package/lib/commands/sync/Task.d.ts.map +0 -1
  55. package/lib/commands/sync/Task.js +0 -2
  56. package/lib/commands/sync/Task.js.map +0 -1
  57. package/lib/commands/sync/createDownloadTask.d.ts +0 -5
  58. package/lib/commands/sync/createDownloadTask.d.ts.map +0 -1
  59. package/lib/commands/sync/createDownloadTask.js +0 -22
  60. package/lib/commands/sync/createDownloadTask.js.map +0 -1
  61. package/lib/commands/sync/createUploadTask.d.ts +0 -5
  62. package/lib/commands/sync/createUploadTask.d.ts.map +0 -1
  63. package/lib/commands/sync/createUploadTask.js +0 -18
  64. package/lib/commands/sync/createUploadTask.js.map +0 -1
  65. package/lib/commands/sync/getPackagesToSync.d.ts +0 -9
  66. package/lib/commands/sync/getPackagesToSync.d.ts.map +0 -1
  67. package/lib/commands/sync/getPackagesToSync.js +0 -24
  68. package/lib/commands/sync/getPackagesToSync.js.map +0 -1
  69. package/lib/commands/sync/syncInternal.d.ts +0 -10
  70. package/lib/commands/sync/syncInternal.d.ts.map +0 -1
  71. package/lib/commands/sync/syncInternal.js +0 -39
  72. package/lib/commands/sync/syncInternal.js.map +0 -1
  73. package/lib/common/getBundleDetails.d.ts +0 -14
  74. package/lib/common/getBundleDetails.d.ts.map +0 -1
  75. package/lib/common/getBundleDetails.js +0 -35
  76. package/lib/common/getBundleDetails.js.map +0 -1
  77. package/lib/tasks/bundleTask.d.ts +0 -9
  78. package/lib/tasks/bundleTask.d.ts.map +0 -1
  79. package/lib/tasks/bundleTask.js +0 -119
  80. package/lib/tasks/bundleTask.js.map +0 -1
  81. package/lib/tasks/formatBundleErrors.d.ts +0 -9
  82. package/lib/tasks/formatBundleErrors.d.ts.map +0 -1
  83. package/lib/tasks/formatBundleErrors.js +0 -19
  84. package/lib/tasks/formatBundleErrors.js.map +0 -1
  85. package/lib/tasks/getFileSizeSync.d.ts +0 -5
  86. package/lib/tasks/getFileSizeSync.d.ts.map +0 -1
  87. package/lib/tasks/getFileSizeSync.js +0 -16
  88. package/lib/tasks/getFileSizeSync.js.map +0 -1
  89. package/lib/tasks/hashPackage.d.ts +0 -6
  90. package/lib/tasks/hashPackage.d.ts.map +0 -1
  91. package/lib/tasks/hashPackage.js +0 -21
  92. package/lib/tasks/hashPackage.js.map +0 -1
  93. package/lib/types/BundleRequest.d.ts +0 -26
  94. package/lib/types/BundleRequest.d.ts.map +0 -1
  95. package/lib/types/BundleRequest.js +0 -2
  96. package/lib/types/BundleRequest.js.map +0 -1
  97. package/lib/types/BundleTaskOptions.d.ts +0 -4
  98. package/lib/types/BundleTaskOptions.d.ts.map +0 -1
  99. package/lib/types/BundleTaskOptions.js +0 -2
  100. package/lib/types/BundleTaskOptions.js.map +0 -1
@@ -1,14 +0,0 @@
1
- import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
- export declare function getBundleDetails(options: {
3
- packagePath: string;
4
- }, context: {
5
- packages: PackageDefinitionsCache;
6
- }): Promise<{
7
- bundleId: string;
8
- isExternal: boolean;
9
- outputLocation: {
10
- path: string;
11
- folderName: string;
12
- };
13
- }>;
14
- //# sourceMappingURL=getBundleDetails.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBundleDetails.d.ts","sourceRoot":"","sources":["../../src/common/getBundleDetails.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,wBAAsB,gBAAgB,CACpC,OAAO,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,EAChC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE;;;;;;;GAmC/C"}
@@ -1,35 +0,0 @@
1
- import { isExternalPackage } from '@ms-cloudpack/package-utilities';
2
- import hash from 'object-hash';
3
- import filenamify from 'filenamify';
4
- import path from 'path';
5
- import { getCachePath } from '@ms-cloudpack/api-server';
6
- export async function getBundleDetails(options, context) {
7
- const { packagePath } = options;
8
- const { packages } = context;
9
- const definition = await packages.get(packagePath);
10
- if (!definition) {
11
- throw new Error(`Package definition (package.json) missing or invalid at "${packagePath}"`);
12
- }
13
- const { name: packageName, version } = definition;
14
- if (!packageName) {
15
- throw new Error(`Package definition (package.json) missing name at "${packagePath}"`);
16
- }
17
- const isExternal = isExternalPackage(packagePath);
18
- const bundleId = hash({
19
- name: packageName,
20
- ...definition,
21
- version: (isExternal ? version : packagePath) || packagePath,
22
- });
23
- // Derive where the output should be.
24
- const folderName = `${filenamify(packageName)}-${version}-${bundleId}`;
25
- const outputPath = path.join(getCachePath(), folderName);
26
- return {
27
- bundleId,
28
- isExternal,
29
- outputLocation: {
30
- path: outputPath,
31
- folderName,
32
- },
33
- };
34
- }
35
- //# sourceMappingURL=getBundleDetails.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBundleDetails.js","sourceRoot":"","sources":["../../src/common/getBundleDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,IAAI,MA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cloudpack/package-utilities';\nimport hash from 'object-hash';\nimport filenamify from 'filenamify';\nimport path from 'path';\nimport { getCachePath } from '@ms-cloudpack/api-server';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\n\nexport async function getBundleDetails(\n options: { packagePath: string },\n context: { packages: PackageDefinitionsCache },\n) {\n const { packagePath } = options;\n const { packages } = context;\n const definition = await packages.get(packagePath);\n\n if (!definition) {\n throw new Error(`Package definition (package.json) missing or invalid at \"${packagePath}\"`);\n }\n\n const { name: packageName, version } = definition;\n\n if (!packageName) {\n throw new Error(`Package definition (package.json) missing name at \"${packagePath}\"`);\n }\n\n const isExternal = isExternalPackage(packagePath);\n const bundleId = hash({\n name: packageName,\n ...definition,\n version: (isExternal ? version : packagePath) || packagePath,\n });\n\n // Derive where the output should be.\n const folderName = `${filenamify(packageName)}-${version}-${bundleId}`;\n const outputPath = path.join(getCachePath(), folderName);\n\n return {\n bundleId,\n isExternal,\n outputLocation: {\n path: outputPath,\n folderName,\n },\n };\n}\n"]}
@@ -1,9 +0,0 @@
1
- import { type TaskReporter } from '@ms-cloudpack/task-reporter';
2
- import type { BundleTaskOptions } from '../types/BundleTaskOptions.js';
3
- import type { BundleRequest } from '../types/BundleRequest.js';
4
- export declare function bundleTask({ bundleRequest, options, reporter, }: {
5
- bundleRequest: BundleRequest;
6
- options?: BundleTaskOptions;
7
- reporter?: TaskReporter;
8
- }): Promise<BundleRequest>;
9
- //# sourceMappingURL=bundleTask.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/tasks/bundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,6BAA6B,CAAC;AAIrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D,wBAAsB,UAAU,CAAC,EAC/B,aAAa,EACb,OAAY,EACZ,QAAQ,GACT,EAAE;IACD,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB,0BAwDA"}
@@ -1,119 +0,0 @@
1
- import { bundle as bundleInternal, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';
2
- import { readJson, writeJson } from '@ms-cloudpack/json-utilities';
3
- import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
4
- import { bulletedList, formatPackageName, } from '@ms-cloudpack/task-reporter';
5
- import path from 'path';
6
- import { findImports } from '../commands/init/findImports.js';
7
- import { prepareOutputPath } from '../common/prepareOutputPath.js';
8
- import { formatBundleErrors } from './formatBundleErrors.js';
9
- import { getFileSizeSync } from './getFileSizeSync.js';
10
- import { hashPackage } from './hashPackage.js';
11
- import { getPackageSettings } from '@ms-cloudpack/config';
12
- export async function bundleTask({ bundleRequest, options = {}, reporter, }) {
13
- const { packageName, version } = bundleRequest;
14
- const { force } = options || {};
15
- const { rebuild } = bundleRequest?.result || {};
16
- const taskName = `${rebuild ? `Re-bundle` : `Bundle`} ${formatPackageName({ name: packageName, version })}`;
17
- const executeBundle = async () => {
18
- if (rebuild) {
19
- bundleRequest.result = await rebuild();
20
- }
21
- else {
22
- await bundle(bundleRequest, force);
23
- }
24
- const result = (bundleRequest.result ??= {});
25
- result.outputFiles ??= [];
26
- result.errors ??= [];
27
- result.warnings ??= [];
28
- if (!result.outputFiles.length) {
29
- result.warnings.push({
30
- text: `No output files were found for "${packageName}" in "${bundleRequest.outputPath}"`,
31
- });
32
- }
33
- return {
34
- status: result.errors.length ? 'fail' : 'complete',
35
- ...(result.errors?.length
36
- ? formatBundleErrors(result.errors)
37
- : {
38
- details: bulletedList([
39
- `Package: ${bundleRequest.packageName}@${bundleRequest.version}`,
40
- `Bundler: ${bundleRequest.result?.bundlerName || 'unknown'}`,
41
- `Input path: ${bundleRequest.packagePath}`,
42
- `Entries:`,
43
- Object.values(bundleRequest.result?.entries || {}),
44
- `Output path: ${bundleRequest.outputPath}`,
45
- bundleRequest.result?.outputFiles?.map((file) => `${safeRelativePath(path.relative(bundleRequest.outputPath, file.outputPath))} (${getFileSizeSync(file.outputPath)})`),
46
- ]),
47
- }),
48
- };
49
- };
50
- if (reporter) {
51
- await reporter.runTask(taskName, executeBundle);
52
- }
53
- else {
54
- await executeBundle();
55
- }
56
- return bundleRequest;
57
- }
58
- async function bundle(bundleRequest, force) {
59
- const { packages, config } = bundleRequest;
60
- const context = { packages, config };
61
- // If force is set, dispose the existing result.
62
- if (force && bundleRequest?.result?.dispose) {
63
- bundleRequest.result.dispose();
64
- bundleRequest.result = undefined;
65
- }
66
- const { packagePath, outputPath, isExternal, disableSourceMaps, enableFindImports, enableCacheInternalPackages } = bundleRequest;
67
- // Rehydrate the result if not incremental.
68
- if ((isExternal || enableCacheInternalPackages) && !force) {
69
- bundleRequest.result = await readJson(path.join(outputPath, 'result.json'));
70
- }
71
- const { userPackageSettings } = getPackageSettings({
72
- name: bundleRequest.packageName,
73
- version: bundleRequest.version,
74
- config,
75
- }) || {};
76
- const { bundlerType, bundlerOptions } = userPackageSettings || {};
77
- const bundleOptions = {
78
- bundlerType: bundleRequest.bundlerType || bundlerType,
79
- overrideOptions: bundlerOptions,
80
- inputPath: packagePath,
81
- outputPath,
82
- incremental: !isExternal,
83
- sourcemap: disableSourceMaps ? undefined : 'linked',
84
- entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),
85
- external: await getExternalsFromPackage({ inputPath: packagePath }, context),
86
- };
87
- const hash = !isExternal && enableCacheInternalPackages
88
- ? await hashPackage({ packagePath, isExternal, additionalProperties: bundleOptions })
89
- : undefined;
90
- if (bundleRequest.result?.errors?.length === 0 &&
91
- // Dependencies are undefined if the older version of bundleTask was used to bundle the package.
92
- // In this case, we need to bundle it again with the new version to have dependencies defined in the result.json.
93
- (!enableFindImports || !!bundleRequest.result?.dependencies) &&
94
- // Internal packages should be re-bundled if the package hash has changed.
95
- (isExternal || (enableCacheInternalPackages && bundleRequest.result.hash === hash))) {
96
- console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);
97
- bundleRequest.resultFromCache = true;
98
- }
99
- else {
100
- bundleRequest.resultFromCache = false;
101
- // Only use cached result if it's successful.
102
- await prepareOutputPath(outputPath);
103
- bundleRequest.result = await bundleInternal(bundleOptions);
104
- bundleRequest.result.hash = hash;
105
- if (enableFindImports) {
106
- // Find imports that are in the output files and set dependencies.
107
- const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => f.outputPath);
108
- const imports = outputFilePaths && (await findImports(outputFilePaths));
109
- bundleRequest.result.dependencies = imports && Object.keys(imports);
110
- }
111
- // Write the result to disk.
112
- if (isExternal || enableCacheInternalPackages) {
113
- bundleRequest.result.rawInput = bundleRequest.result.rawOutput = undefined;
114
- await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);
115
- }
116
- }
117
- return bundleRequest;
118
- }
119
- //# sourceMappingURL=bundleTask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/tasks/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,iBAAiB,GAGlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,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AC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SAC7E;KACF;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { bundle as bundleInternal, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport { readJson, writeJson } from '@ms-cloudpack/json-utilities';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport {\n bulletedList,\n formatPackageName,\n type TaskReporter,\n type TaskReporterTaskResult,\n} from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { findImports } from '../commands/init/findImports.js';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleTaskOptions } from '../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { formatBundleErrors } from './formatBundleErrors.js';\nimport { getFileSizeSync } from './getFileSizeSync.js';\nimport { hashPackage } from './hashPackage.js';\nimport type { BundleOptions } from '@ms-cloudpack/bundler-types';\nimport { getPackageSettings } from '@ms-cloudpack/config';\n\nexport async function bundleTask({\n bundleRequest,\n options = {},\n reporter,\n}: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n reporter?: TaskReporter;\n}) {\n const { packageName, version } = bundleRequest;\n const { force } = options || {};\n\n const { rebuild } = bundleRequest?.result || {};\n const taskName = `${rebuild ? `Re-bundle` : `Bundle`} ${formatPackageName({ name: packageName, version })}`;\n\n const executeBundle = async (): Promise<TaskReporterTaskResult> => {\n if (rebuild) {\n bundleRequest.result = await rebuild();\n } else {\n await bundle(bundleRequest, force);\n }\n\n const result = (bundleRequest.result ??= {});\n\n result.outputFiles ??= [];\n result.errors ??= [];\n result.warnings ??= [];\n\n if (!result.outputFiles.length) {\n result.warnings.push({\n text: `No output files were found for \"${packageName}\" in \"${bundleRequest.outputPath}\"`,\n });\n }\n\n return {\n status: result.errors.length ? 'fail' : 'complete',\n ...(result.errors?.length\n ? formatBundleErrors(result.errors)\n : {\n details: bulletedList([\n `Package: ${bundleRequest.packageName}@${bundleRequest.version}`,\n `Bundler: ${bundleRequest.result?.bundlerName || 'unknown'}`,\n `Input path: ${bundleRequest.packagePath}`,\n `Entries:`,\n Object.values(bundleRequest.result?.entries || {}),\n `Output path: ${bundleRequest.outputPath}`,\n bundleRequest.result?.outputFiles?.map(\n (file) =>\n `${safeRelativePath(path.relative(bundleRequest.outputPath, file.outputPath))} (${getFileSizeSync(\n file.outputPath,\n )})`,\n ),\n ]),\n }),\n };\n };\n\n if (reporter) {\n await reporter.runTask(taskName, executeBundle);\n } else {\n await executeBundle();\n }\n\n return bundleRequest;\n}\n\nasync function bundle(bundleRequest: BundleRequest, force?: boolean): Promise<BundleRequest> {\n const { packages, config } = bundleRequest;\n const context = { packages, config };\n\n // If force is set, dispose the existing result.\n if (force && bundleRequest?.result?.dispose) {\n bundleRequest.result.dispose();\n bundleRequest.result = undefined;\n }\n\n const { packagePath, outputPath, isExternal, disableSourceMaps, enableFindImports, enableCacheInternalPackages } =\n bundleRequest;\n\n // Rehydrate the result if not incremental.\n if ((isExternal || enableCacheInternalPackages) && !force) {\n bundleRequest.result = await readJson(path.join(outputPath, 'result.json'));\n }\n\n const { userPackageSettings } =\n getPackageSettings({\n name: bundleRequest.packageName,\n version: bundleRequest.version,\n config,\n }) || {};\n const { bundlerType, bundlerOptions } = userPackageSettings || {};\n\n const bundleOptions: BundleOptions = {\n bundlerType: bundleRequest.bundlerType || bundlerType,\n overrideOptions: bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: !isExternal,\n sourcemap: disableSourceMaps ? undefined : 'linked',\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),\n external: await getExternalsFromPackage({ inputPath: packagePath }, context),\n };\n\n const hash =\n !isExternal && enableCacheInternalPackages\n ? await hashPackage({ packagePath, isExternal, additionalProperties: bundleOptions })\n : undefined;\n\n if (\n bundleRequest.result?.errors?.length === 0 &&\n // Dependencies are undefined if the older version of bundleTask was used to bundle the package.\n // In this case, we need to bundle it again with the new version to have dependencies defined in the result.json.\n (!enableFindImports || !!bundleRequest.result?.dependencies) &&\n // Internal packages should be re-bundled if the package hash has changed.\n (isExternal || (enableCacheInternalPackages && bundleRequest.result.hash === hash))\n ) {\n console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);\n bundleRequest.resultFromCache = true;\n } else {\n bundleRequest.resultFromCache = false;\n\n // Only use cached result if it's successful.\n await prepareOutputPath(outputPath);\n\n bundleRequest.result = await bundleInternal(bundleOptions);\n bundleRequest.result.hash = hash;\n\n if (enableFindImports) {\n // Find imports that are in the output files and set dependencies.\n const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => f.outputPath);\n const imports = outputFilePaths && (await findImports(outputFilePaths));\n bundleRequest.result.dependencies = imports && Object.keys(imports);\n }\n\n // Write the result to disk.\n if (isExternal || enableCacheInternalPackages) {\n bundleRequest.result.rawInput = bundleRequest.result.rawOutput = undefined;\n await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);\n }\n }\n\n return bundleRequest;\n}\n"]}
@@ -1,9 +0,0 @@
1
- import type { BundleMessage } from '@ms-cloudpack/bundler-types';
2
- export declare function formatBundleErrors(errors: BundleMessage[] | undefined): {
3
- message?: undefined;
4
- details?: undefined;
5
- } | {
6
- message: string;
7
- details: string;
8
- };
9
- //# sourceMappingURL=formatBundleErrors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatBundleErrors.d.ts","sourceRoot":"","sources":["../../src/tasks/formatBundleErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,SAAS;;;;;;EAOrE"}
@@ -1,19 +0,0 @@
1
- import { darkGrey, red, bulletedList } from '@ms-cloudpack/task-reporter';
2
- export function formatBundleErrors(errors) {
3
- if (!errors?.length)
4
- return {};
5
- return {
6
- message: `${errors.length} ${errors.length === 1 ? 'error' : 'errors'} found`,
7
- details: bulletedList(errors.map((error) => formatError(error))),
8
- };
9
- }
10
- function formatError(error) {
11
- const { location } = error;
12
- return [
13
- location && darkGrey(`${location.file}:${location.line}:${location.column}:`),
14
- red(error.text ? error.text : JSON.stringify(error, null, 2)),
15
- ]
16
- .filter(Boolean)
17
- .join(' ');
18
- }
19
- //# sourceMappingURL=formatBundleErrors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatBundleErrors.js","sourceRoot":"","sources":["../../src/tasks/formatBundleErrors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE1E,MAAM,UAAU,kBAAkB,CAAC,MAAmC;IACpE,IAAI,CAAC,MAAM,EAAE,MAAM;QAAE,OAAO,EAAE,CAAC;IAE/B,OAAO;QACL,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,QAAQ;QAC7E,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;KACjE,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,KAAoB;IACvC,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE3B,OAAO;QACL,QAAQ,IAAI,QAAQ,CAAC,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC7E,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;KAC9D;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/bundler-types';\nimport { darkGrey, red, bulletedList } from '@ms-cloudpack/task-reporter';\n\nexport function formatBundleErrors(errors: BundleMessage[] | undefined) {\n if (!errors?.length) return {};\n\n return {\n message: `${errors.length} ${errors.length === 1 ? 'error' : 'errors'} found`,\n details: bulletedList(errors.map((error) => formatError(error))),\n };\n}\n\nfunction formatError(error: BundleMessage) {\n const { location } = error;\n\n return [\n location && darkGrey(`${location.file}:${location.line}:${location.column}:`),\n red(error.text ? error.text : JSON.stringify(error, null, 2)),\n ]\n .filter(Boolean)\n .join(' ');\n}\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * Given a file path, returns a human-readable file size description.
3
- */
4
- export declare function getFileSizeSync(filePath: string): string;
5
- //# sourceMappingURL=getFileSizeSync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFileSizeSync.d.ts","sourceRoot":"","sources":["../../src/tasks/getFileSizeSync.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAaxD"}
@@ -1,16 +0,0 @@
1
- import fs from 'fs';
2
- /**
3
- * Given a file path, returns a human-readable file size description.
4
- */
5
- export function getFileSizeSync(filePath) {
6
- // eslint-disable-next-line no-restricted-syntax
7
- const { size } = fs.statSync(filePath);
8
- if (size > 1024 * 1024) {
9
- return `${(size / 1024 / 1024).toFixed(2)} MB`;
10
- }
11
- if (size > 1024) {
12
- return `${(size / 1024).toFixed(2)} KB`;
13
- }
14
- return `${size} ${size === 1 ? 'byte' : 'bytes'}`;
15
- }
16
- //# sourceMappingURL=getFileSizeSync.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFileSizeSync.js","sourceRoot":"","sources":["../../src/tasks/getFileSizeSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,gDAAgD;IAChD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEvC,IAAI,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE;QACtB,OAAO,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;KAChD;IAED,IAAI,IAAI,GAAG,IAAI,EAAE;QACf,OAAO,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;KACzC;IAED,OAAO,GAAG,IAAI,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import fs from 'fs';\n\n/**\n * Given a file path, returns a human-readable file size description.\n */\nexport function getFileSizeSync(filePath: string): string {\n // eslint-disable-next-line no-restricted-syntax\n const { size } = fs.statSync(filePath);\n\n if (size > 1024 * 1024) {\n return `${(size / 1024 / 1024).toFixed(2)} MB`;\n }\n\n if (size > 1024) {\n return `${(size / 1024).toFixed(2)} KB`;\n }\n\n return `${size} ${size === 1 ? 'byte' : 'bytes'}`;\n}\n"]}
@@ -1,6 +0,0 @@
1
- export declare function hashPackage<T extends object>(options: {
2
- packagePath: string;
3
- isExternal: boolean;
4
- additionalProperties: T;
5
- }): Promise<string>;
6
- //# sourceMappingURL=hashPackage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hashPackage.d.ts","sourceRoot":"","sources":["../../src/tasks/hashPackage.ts"],"names":[],"mappings":"AASA,wBAAsB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,oBAAoB,EAAE,CAAC,CAAC;CACzB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBlB"}
@@ -1,21 +0,0 @@
1
- import glob from 'fast-glob';
2
- import { existsSync } from 'fs';
3
- import { hash } from 'glob-hasher';
4
- import objectHash from 'object-hash';
5
- import path from 'path';
6
- import { performance } from 'perf_hooks';
7
- const excludeNodeModules = '!**/node_modules/**';
8
- export async function hashPackage(options) {
9
- const start = performance.now();
10
- const { packagePath, isExternal, additionalProperties } = options;
11
- const shouldUseSrc = !isExternal && existsSync(path.join(packagePath, 'src'));
12
- const patterns = shouldUseSrc ? ['src/**', '*.json', excludeNodeModules] : ['**', excludeNodeModules];
13
- const files = await glob(patterns, {
14
- cwd: packagePath,
15
- });
16
- const globHash = hash(files, { cwd: packagePath });
17
- const result = objectHash({ files: globHash, additionalProperties }, { algorithm: 'md5' });
18
- console.debug(`Hashed ${path.basename(packagePath)} in ${performance.now() - start}ms`);
19
- return result;
20
- }
21
- //# sourceMappingURL=hashPackage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hashPackage.js","sourceRoot":"","sources":["../../src/tasks/hashPackage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAmB,OAInD;IACC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC;IAElE,MAAM,YAAY,GAAG,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAE9E,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACtG,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE;QACjC,GAAG,EAAE,WAAW;KACjB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAE3F,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport { existsSync } from 'fs';\nimport { hash } from 'glob-hasher';\nimport objectHash from 'object-hash';\nimport path from 'path';\nimport { performance } from 'perf_hooks';\n\nconst excludeNodeModules = '!**/node_modules/**';\n\nexport async function hashPackage<T extends object>(options: {\n packagePath: string;\n isExternal: boolean;\n additionalProperties: T;\n}): Promise<string> {\n const start = performance.now();\n const { packagePath, isExternal, additionalProperties } = options;\n\n const shouldUseSrc = !isExternal && existsSync(path.join(packagePath, 'src'));\n\n const patterns = shouldUseSrc ? ['src/**', '*.json', excludeNodeModules] : ['**', excludeNodeModules];\n const files = await glob(patterns, {\n cwd: packagePath,\n });\n\n const globHash = hash(files, { cwd: packagePath });\n const result = objectHash({ files: globHash, additionalProperties }, { algorithm: 'md5' });\n\n console.debug(`Hashed ${path.basename(packagePath)} in ${performance.now() - start}ms`);\n return result;\n}\n"]}
@@ -1,26 +0,0 @@
1
- import type { BundleResult, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
- import type { CloudpackConfig } from '@ms-cloudpack/config';
3
- /**
4
- * Tracks a given bundle request and its result.
5
- */
6
- export interface BundleRequest {
7
- id: string;
8
- packageName: string;
9
- version: string;
10
- packagePath: string;
11
- outputPath: string;
12
- isExternal: boolean;
13
- bundlerType?: string;
14
- result?: BundleResult & {
15
- dependencies?: string[];
16
- hash?: string;
17
- };
18
- resultFromCache?: boolean;
19
- isRebuildRequired?: boolean;
20
- disableSourceMaps?: boolean;
21
- enableFindImports?: boolean;
22
- enableCacheInternalPackages?: boolean;
23
- packages: PackageDefinitionsCache;
24
- config: CloudpackConfig;
25
- }
26
- //# sourceMappingURL=BundleRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BundleRequest.d.ts","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,YAAY,GAAG;QAAE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;CACzB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=BundleRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BundleRequest.js","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleResult, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\n/**\n * Tracks a given bundle request and its result.\n */\n\nexport interface BundleRequest {\n id: string;\n packageName: string;\n version: string;\n packagePath: string;\n outputPath: string;\n isExternal: boolean;\n bundlerType?: string;\n result?: BundleResult & { dependencies?: string[]; hash?: string };\n resultFromCache?: boolean;\n isRebuildRequired?: boolean;\n disableSourceMaps?: boolean;\n enableFindImports?: boolean;\n enableCacheInternalPackages?: boolean;\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n}\n"]}
@@ -1,4 +0,0 @@
1
- export interface BundleTaskOptions {
2
- force?: boolean;
3
- }
4
- //# sourceMappingURL=BundleTaskOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BundleTaskOptions.d.ts","sourceRoot":"","sources":["../../src/types/BundleTaskOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=BundleTaskOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BundleTaskOptions.js","sourceRoot":"","sources":["../../src/types/BundleTaskOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface BundleTaskOptions {\n force?: boolean;\n}\n"]}