@ms-cloudpack/cli 0.39.11 → 0.39.12
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/lib/commands/bundle/bundle.d.ts +4 -1
- package/lib/commands/bundle/bundle.d.ts.map +1 -1
- package/lib/commands/bundle/bundle.js +1 -2
- package/lib/commands/bundle/bundle.js.map +1 -1
- package/lib/commands/bundle/index.d.ts +2 -2
- package/lib/commands/bundle/index.d.ts.map +1 -1
- package/lib/commands/bundle/index.js +3 -3
- package/lib/commands/bundle/index.js.map +1 -1
- package/lib/commands/dashboard/index.d.ts +2 -2
- package/lib/commands/dashboard/index.d.ts.map +1 -1
- package/lib/commands/dashboard/index.js +2 -2
- package/lib/commands/dashboard/index.js.map +1 -1
- package/lib/commands/init/bundleAndGetImports.d.ts +2 -0
- package/lib/commands/init/bundleAndGetImports.d.ts.map +1 -1
- package/lib/commands/init/bundleAndGetImports.js +1 -2
- package/lib/commands/init/bundleAndGetImports.js.map +1 -1
- package/lib/commands/init/index.d.ts +2 -2
- package/lib/commands/init/index.d.ts.map +1 -1
- package/lib/commands/init/index.js +4 -5
- package/lib/commands/init/index.js.map +1 -1
- package/lib/commands/init/init.d.ts +4 -1
- package/lib/commands/init/init.d.ts.map +1 -1
- package/lib/commands/init/init.js +3 -3
- package/lib/commands/init/init.js.map +1 -1
- package/lib/commands/start/appServer/startAppServer.d.ts +3 -1
- package/lib/commands/start/appServer/startAppServer.d.ts.map +1 -1
- package/lib/commands/start/appServer/startAppServer.js +1 -2
- package/lib/commands/start/appServer/startAppServer.js.map +1 -1
- package/lib/commands/start/createBundleTask.d.ts +2 -1
- package/lib/commands/start/createBundleTask.d.ts.map +1 -1
- package/lib/commands/start/createBundleTask.js +2 -2
- package/lib/commands/start/createBundleTask.js.map +1 -1
- package/lib/commands/start/createSession.d.ts +4 -1
- package/lib/commands/start/createSession.d.ts.map +1 -1
- package/lib/commands/start/createSession.js +2 -2
- package/lib/commands/start/createSession.js.map +1 -1
- package/lib/commands/start/index.d.ts +2 -2
- package/lib/commands/start/index.d.ts.map +1 -1
- package/lib/commands/start/index.js +3 -3
- package/lib/commands/start/index.js.map +1 -1
- package/lib/commands/start/start.d.ts +4 -1
- package/lib/commands/start/start.d.ts.map +1 -1
- package/lib/commands/start/start.js +4 -4
- package/lib/commands/start/start.js.map +1 -1
- package/lib/commands/start/startBundleServer.d.ts +3 -1
- package/lib/commands/start/startBundleServer.d.ts.map +1 -1
- package/lib/commands/start/startBundleServer.js +5 -5
- package/lib/commands/start/startBundleServer.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -5
- package/lib/index.js.map +1 -1
- package/lib/initReporter.d.ts +4 -0
- package/lib/initReporter.d.ts.map +1 -0
- package/lib/initReporter.js +7 -0
- package/lib/initReporter.js.map +1 -0
- package/lib/initTelemetry.d.ts +2 -1
- package/lib/initTelemetry.d.ts.map +1 -1
- package/lib/initTelemetry.js +4 -1
- package/lib/initTelemetry.js.map +1 -1
- package/lib/tasks/bundleTask.d.ts +3 -1
- package/lib/tasks/bundleTask.d.ts.map +1 -1
- package/lib/tasks/bundleTask.js +10 -5
- package/lib/tasks/bundleTask.js.map +1 -1
- package/lib/tasks/resolveDependenciesTask.d.ts +3 -0
- package/lib/tasks/resolveDependenciesTask.d.ts.map +1 -1
- package/lib/tasks/resolveDependenciesTask.js +1 -2
- package/lib/tasks/resolveDependenciesTask.js.map +1 -1
- package/lib/types/CommandFunction.d.ts +7 -0
- package/lib/types/CommandFunction.d.ts.map +1 -0
- package/lib/types/CommandFunction.js +2 -0
- package/lib/types/CommandFunction.js.map +1 -0
- package/package.json +4 -4
- package/lib/reporter.d.ts +0 -5
- package/lib/reporter.d.ts.map +0 -1
- package/lib/reporter.js +0 -9
- package/lib/reporter.js.map +0 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { BundleOptions } from './types/BundleOptions.js';
|
|
2
|
-
|
|
2
|
+
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
3
|
+
export declare function bundle(options: BundleOptions, { reporter }: {
|
|
4
|
+
reporter: TaskReporter;
|
|
5
|
+
}): Promise<void>;
|
|
3
6
|
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,iBAyB5F"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { bundleTask } from '../../tasks/bundleTask.js';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { PackageDefinitions } from '@ms-cloudpack/package-utilities';
|
|
4
|
-
|
|
5
|
-
export async function bundle(options) {
|
|
4
|
+
export async function bundle(options, { reporter }) {
|
|
6
5
|
const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options || {};
|
|
7
6
|
const packagePath = process.cwd();
|
|
8
7
|
const definition = await PackageDefinitions.getInstance().get(packagePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIrE,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB,EAAE,EAAE,QAAQ,EAA8B;IAC3F,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC/F,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3E,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,UAAU,IAAI,EAAE,CAAC;IACjE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,aAAa,GAAkB;QACnC,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,IAAI;QACjB,OAAO;QACP,WAAW;QACX,UAAU;QACV,UAAU,EAAE,IAAI;QAChB,WAAW;QACX,iBAAiB;KAClB,CAAC;IAEF,MAAM,UAAU,CAAC;QACf,aAAa;QACb,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;KACzB,CAAC,CAAC;IAEH,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAEpB,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { bundleTask } from '../../tasks/bundleTask.js';\nimport path from 'path';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\nexport async function bundle(options: BundleOptions, { reporter }: { reporter: TaskReporter }) {\n const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options || {};\n const packagePath = process.cwd();\n const definition = await PackageDefinitions.getInstance().get(packagePath);\n const { name = 'unknown', version = '0.0.0' } = definition || {};\n const outputPath = path.resolve(packagePath, outdir);\n const bundleRequest: BundleRequest = {\n id: 'bundle',\n packageName: name,\n version,\n packagePath,\n outputPath,\n isExternal: true,\n bundlerType,\n disableSourceMaps,\n };\n\n await bundleTask({\n bundleRequest,\n options: { force: true },\n });\n\n reporter.complete();\n\n process.exit(bundleRequest.result?.errors?.length === 0 ? 0 : 1);\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
1
|
+
import type { CommandFunction } from '../../types/CommandFunction.js';
|
|
2
|
+
export declare const init: CommandFunction;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,IAAI,EAAE,eAOlB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { bundle } from './bundle.js';
|
|
2
|
-
export
|
|
2
|
+
export const init = ({ command, reporter }) => {
|
|
3
3
|
command
|
|
4
4
|
.command('bundle')
|
|
5
5
|
.option('--bundler <name>', 'Forces use of a specific bundler.')
|
|
6
6
|
.option('--outdir <path>', 'Path to drop the bundle output, relative to current path.')
|
|
7
7
|
.description('Bundles a package.')
|
|
8
|
-
.action((
|
|
9
|
-
}
|
|
8
|
+
.action((bundleOptions) => bundle(bundleOptions, { reporter }));
|
|
9
|
+
};
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC7D,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,MAAM,CAAC,kBAAkB,EAAE,mCAAmC,CAAC;SAC/D,MAAM,CAAC,iBAAiB,EAAE,2DAA2D,CAAC;SACtF,WAAW,CAAC,oBAAoB,CAAC;SACjC,MAAM,CAAC,CAAC,aAA4B,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC","sourcesContent":["import { bundle } from './bundle.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport type { CommandFunction } from '../../types/CommandFunction.js';\n\nexport const init: CommandFunction = ({ command, reporter }) => {\n command\n .command('bundle')\n .option('--bundler <name>', 'Forces use of a specific bundler.')\n .option('--outdir <path>', 'Path to drop the bundle output, relative to current path.')\n .description('Bundles a package.')\n .action((bundleOptions: BundleOptions) => bundle(bundleOptions, { reporter }));\n};\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
1
|
+
import type { CommandFunction } from '../../types/CommandFunction.js';
|
|
2
|
+
export declare const init: CommandFunction;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,IAAI,EAAE,eAKlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IACnD,OAAO;SACJ,OAAO,CAAC,WAAW,CAAC;SACpB,WAAW,CAAC,sBAAsB,CAAC;SACnC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\n\nexport const init: CommandFunction = ({ command }) => {\n command\n .command('dashboard')\n .description('Shows the dashboard.')\n .action(() => console.log('i am showing the dashboard.'));\n};\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
3
|
/**
|
|
3
4
|
* Bundle the package and return the imports it depends on.
|
|
4
5
|
*/
|
|
5
6
|
export declare function bundleAndGetImports(options: {
|
|
6
7
|
packages: PackageDefinitionsCache;
|
|
8
|
+
reporter: TaskReporter;
|
|
7
9
|
packagePath: string;
|
|
8
10
|
definition: PackageJson;
|
|
9
11
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGxF,OAAO,EAAE,KAAK,YAAY,EAA2C,MAAM,6BAA6B,CAAC;AAEzG;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACpC,CAAC,CAiED"}
|
|
@@ -3,14 +3,13 @@ import { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';
|
|
|
3
3
|
import { getBundleDetails } from '../../common/getBundleDetails.js';
|
|
4
4
|
import { findImports } from './findImports.js';
|
|
5
5
|
import { prepareOutputPath } from '../../common/prepareOutputPath.js';
|
|
6
|
-
import { reporter } from '../../reporter.js';
|
|
7
6
|
import { bundleTask } from '../../tasks/bundleTask.js';
|
|
8
7
|
import { bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';
|
|
9
8
|
/**
|
|
10
9
|
* Bundle the package and return the imports it depends on.
|
|
11
10
|
*/
|
|
12
11
|
export async function bundleAndGetImports(options) {
|
|
13
|
-
const { packagePath, definition, packages } = options;
|
|
12
|
+
const { packagePath, definition, packages, reporter } = options;
|
|
14
13
|
const { outputPath, isExternal } = await getBundleDetails(packagePath);
|
|
15
14
|
if (!isExternal && !definition.exports) {
|
|
16
15
|
console.debug(`${path.join(packagePath, 'package.json')} does not have an "exports" field.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleAndGetImports.js","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"bundleAndGetImports.js","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAqB,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAEzG;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAKzC;IAMC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ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,CAC9E,CACF,CAAC;IACJ,CAAC,EAAE,EAAc,CAAC,CAAC;AACrB,CAAC","sourcesContent":["import path from 'path';\nimport { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';\nimport { getBundleDetails } from '../../common/getBundleDetails.js';\nimport { findImports } from './findImports.js';\nimport { prepareOutputPath } from '../../common/prepareOutputPath.js';\nimport type { PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\nimport { bundleTask } from '../../tasks/bundleTask.js';\nimport { type TaskReporter, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function bundleAndGetImports(options: {\n packages: PackageDefinitionsCache;\n reporter: TaskReporter;\n packagePath: string;\n definition: PackageJson;\n}): Promise<{\n hasWarnings: boolean;\n hasErrors: boolean;\n /** Map from package name to set of required relative paths */\n imports?: Map<string, Set<string>>;\n}> {\n const { packagePath, definition, packages, reporter } = options;\n const { outputPath, isExternal } = await getBundleDetails(packagePath);\n\n if (!isExternal && !definition.exports) {\n console.debug(`${path.join(packagePath, 'package.json')} does not have an \"exports\" field.`);\n }\n\n // Ensure outputPath exists and is empty.\n await prepareOutputPath(outputPath);\n\n // Determine entries.\n const entriesMap = await getEntriesMapFromPackage({\n inputPath: packagePath,\n packages,\n });\n\n if (!Object.keys(entriesMap).length) {\n console.warn(\n `${path.join(packagePath, 'package.json')} does not specify any entry points.`,\n isExternal\n ? ''\n : 'If this package contains code imported by other packages, please consider adding an \"exports\" field.',\n );\n return { hasWarnings: true, hasErrors: false };\n }\n\n const bundleRequest: BundleRequest = {\n id: packagePath,\n packageName: definition.name || '',\n version: definition.version || '',\n packagePath,\n outputPath,\n isExternal,\n packages,\n };\n\n await bundleTask({ bundleRequest, options: { force: true } });\n\n // For each outputFile, find all imports.\n let imports: Map<string, Set<string>> | undefined;\n\n await reporter.runTask(`Evaluate ${formatPackageName(definition)}`, async () => {\n imports = new Map(\n Object.entries(\n (await findImports(\n bundleRequest.result?.outputFiles?.map((file) => path.resolve(outputPath, file.outputPath)) || [],\n )) || {},\n ),\n );\n\n const importCount = imports.size;\n\n return {\n status: 'complete',\n message: importCount ? `Found ${plural(importCount, 'imported package')}` : undefined,\n details: importCount ? `${bulletedList(getImportsList(imports))}` : undefined,\n };\n });\n\n return {\n hasWarnings: !!bundleRequest.result?.warnings?.length,\n hasErrors: !!bundleRequest.result?.errors?.length,\n imports,\n };\n}\n\nfunction getImportsList(imports: Map<string, Set<string>>): string[] {\n return Array.from(imports.keys()).reduce((list, packageName) => {\n return list.concat(\n Array.from(imports.get(packageName) || []).map(\n (importPath) => `${packageName}${importPath === '.' ? '' : `/${importPath}`}`,\n ),\n );\n }, [] as string[]);\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
1
|
+
import type { CommandFunction } from '../../types/CommandFunction.js';
|
|
2
|
+
export declare const init: CommandFunction;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,eAAO,MAAM,IAAI,EAAE,eAkDlB,CAAC"}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { reporter } from '../../reporter.js';
|
|
2
1
|
import { plural, red, yellow } from '@ms-cloudpack/task-reporter';
|
|
3
2
|
import { configFileName } from '@ms-cloudpack/config';
|
|
4
3
|
import { stopTelemetry } from '../../initTelemetry.js';
|
|
5
4
|
/* Defines the "init" verb. */
|
|
6
|
-
export
|
|
5
|
+
export const init = ({ command, reporter }) => {
|
|
7
6
|
command
|
|
8
7
|
.command('init')
|
|
9
8
|
.description('Initializes a given app project and defines the necessary configuration overrides to make an existing app compatible with Cloudpack.')
|
|
10
9
|
.option('--fix', 'Applies fixes to all identified issues in internal packages.')
|
|
11
10
|
.option('--reset', 'Ignores existing overrides when determining all entries.')
|
|
12
11
|
.option('--check', 'Fails if any package exports are missing.')
|
|
13
|
-
.action(async (options) => {
|
|
12
|
+
.action(async (options, context) => {
|
|
14
13
|
const { init } = await import('./init.js');
|
|
15
14
|
let completeReason;
|
|
16
15
|
let hasErrors = false;
|
|
17
16
|
let hasWarnings = false;
|
|
18
17
|
try {
|
|
19
|
-
const { changeCount, errorPkgCount, warningPkgCount, successPkgCount } = await init(options);
|
|
18
|
+
const { changeCount, errorPkgCount, warningPkgCount, successPkgCount } = await init(options, context);
|
|
20
19
|
hasErrors = errorPkgCount > 0;
|
|
21
20
|
hasWarnings = warningPkgCount > 0;
|
|
22
21
|
const totalCount = errorPkgCount + warningPkgCount + successPkgCount;
|
|
@@ -46,5 +45,5 @@ export function init(command) {
|
|
|
46
45
|
reporter.complete(hasErrors ? red(completeReason) : hasWarnings ? yellow(completeReason) : completeReason);
|
|
47
46
|
process.exit(hasErrors ? 1 : 0);
|
|
48
47
|
});
|
|
49
|
-
}
|
|
48
|
+
};
|
|
50
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,EA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,EAAE;gBACf,cAAc,IAAI,gBAAgB,cAAc,UAAU,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC;aAC5F;SACF;QAAC,OAAO,KAAK,EAAE;YACd,SAAS,GAAG,IAAI,CAAC;YACjB,cAAc,GAAG,qBAAsB,KAAe,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC;SAC3E;QAED,MAAM,aAAa,EAAE,CAAC;QACtB,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;QAE3G,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import type { InitOptions } from './types/InitOptions.js';\nimport { type TaskReporter, plural, red, yellow } from '@ms-cloudpack/task-reporter';\nimport { configFileName } from '@ms-cloudpack/config';\nimport { stopTelemetry } from '../../initTelemetry.js';\nimport type { CommandFunction } from '../../types/CommandFunction.js';\n\n/* Defines the \"init\" verb. */\nexport const init: CommandFunction = ({ command, reporter }) => {\n command\n .command('init')\n .description(\n 'Initializes a given app project and defines the necessary configuration overrides to make an existing app compatible with Cloudpack.',\n )\n .option('--fix', 'Applies fixes to all identified issues in internal packages.')\n .option('--reset', 'Ignores existing overrides when determining all entries.')\n .option('--check', 'Fails if any package exports are missing.')\n .action(async (options: InitOptions, context: { reporter: TaskReporter }) => {\n const { init } = await import('./init.js');\n\n let completeReason: string | undefined;\n let hasErrors = false;\n let hasWarnings = false;\n try {\n const { changeCount, errorPkgCount, warningPkgCount, successPkgCount } = await init(options, context);\n\n hasErrors = errorPkgCount > 0;\n hasWarnings = warningPkgCount > 0;\n\n const totalCount = errorPkgCount + warningPkgCount + successPkgCount;\n\n if (hasErrors || hasWarnings) {\n const successPct = ((successPkgCount / totalCount) * 100).toFixed(1);\n completeReason =\n [\n `${successPkgCount}/${totalCount} (${successPct}%) packages bundled successfully`,\n hasErrors && `${errorPkgCount} packages with errors`,\n hasWarnings && `${warningPkgCount} packages with warnings`,\n ]\n .filter(Boolean)\n .join('\\n') + '\\n';\n } else {\n completeReason = `All ${totalCount} packages bundled successfully`;\n }\n\n if (changeCount) {\n completeReason += `\\n\\nUpdated \"${configFileName}\" with ${plural(changeCount, 'change')}.`;\n }\n } catch (error) {\n hasErrors = true;\n completeReason = `Unexpected error: ${(error as Error).message || error}`;\n }\n\n await stopTelemetry();\n reporter.complete(hasErrors ? red(completeReason) : hasWarnings ? yellow(completeReason) : completeReason);\n\n process.exit(hasErrors ? 1 : 0);\n });\n};\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { InitOptions } from './types/InitOptions.js';
|
|
2
|
+
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
3
|
/** Given the path, updates the Cloudpack config with overrides and project settings. */
|
|
3
|
-
export declare function init(options: InitOptions
|
|
4
|
+
export declare function init(options: InitOptions, { reporter }: {
|
|
5
|
+
reporter: TaskReporter;
|
|
6
|
+
}): Promise<{
|
|
4
7
|
changeCount: number;
|
|
5
8
|
errorPkgCount: number;
|
|
6
9
|
warningPkgCount: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,wFAAwF;AACxF,wBAAsB,IAAI,CACxB,OAAO,EAAE,WAAW,EACpB,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,GACvC,OAAO,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAiHD"}
|
|
@@ -7,7 +7,7 @@ import { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';
|
|
|
7
7
|
import { bundleAndGetImports } from './bundleAndGetImports.js';
|
|
8
8
|
import { patchAllInternalPackageExports } from './patchAllInternalPackageExports.js';
|
|
9
9
|
/** Given the path, updates the Cloudpack config with overrides and project settings. */
|
|
10
|
-
export async function init(options) {
|
|
10
|
+
export async function init(options, { reporter }) {
|
|
11
11
|
if (options.check && options.fix) {
|
|
12
12
|
throw Error('Cannot use --check and --fix together.');
|
|
13
13
|
}
|
|
@@ -20,7 +20,7 @@ export async function init(options) {
|
|
|
20
20
|
const packages = new PackageDefinitions();
|
|
21
21
|
packages.registerTransform(createPackageOverrideTransform({ packageOverrides }));
|
|
22
22
|
// Try to resolve dependencies.
|
|
23
|
-
const resolveMap = (await resolveDependenciesTask({ appPath, packages }));
|
|
23
|
+
const resolveMap = (await resolveDependenciesTask({ appPath, packages }, { reporter }));
|
|
24
24
|
if (!resolveMap) {
|
|
25
25
|
throw new Error("Couldn't resolve dependencies.");
|
|
26
26
|
}
|
|
@@ -46,7 +46,7 @@ export async function init(options) {
|
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
48
|
// Bundle the package and find the imports it depends on.
|
|
49
|
-
const bundleResult = await bundleAndGetImports({ packagePath, definition, packages });
|
|
49
|
+
const bundleResult = await bundleAndGetImports({ packagePath, definition, packages, reporter });
|
|
50
50
|
if (!bundleResult.imports) {
|
|
51
51
|
// This is expected if the package just doesn't import anything else.
|
|
52
52
|
console.info(`${packagePath} has no additional imports to evaluate.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAIrF,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,OAAoB,EACpB,EAAE,QAAQ,EAA8B;IAOxC,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GA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,CAAC,6BAA6B,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM;aAC7F,CAAC,CAAC;YACH,MAAM,KAAK,CACT,eAAe,CAAC,WAAW;gBACzB,CAAC,CAAC,oDAAoD;gBACtD,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACpD,CAAC;SACH;QAED,WAAW,IAAI,eAAe,CAAC,WAAW,CAAC;QAE3C,YAAY,CAAC,SAAS,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM;YACrD,CAAC,CAAC,aAAa,EAAE;YACjB,CAAC,CAAC,YAAY,CAAC,WAAW;gBAC1B,CAAC,CAAC,eAAe,EAAE;gBACnB,CAAC,CAAC,eAAe,EAAE,CAAC;KACvB;IAED,IAAI,OAAO,CAAC,GAAG,EAAE;QACf,MAAM,8BAA8B,CAAC,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC,CAAC;KACxE;IAED,IAAI,WAAW,EAAE;QACf,6BAA6B;QAC7B,OAAO,CAAC,GAAG,CACT,uBAAuB,uBAAuB,8EAA8E,CAC7H,CAAC;QAEF,IAAI,gBAAgB,CAAC,MAAM,EAAE;YAC3B,MAAM,oBAAoB,CAAC,EAAE,gBAAgB,EAAE,EAAE,OAAO,CAAC,CAAC;SAC3D;KACF;IAED,OAAO;QACL,WAAW;QACX,aAAa;QACb,eAAe;QACf,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageOverride } from '@ms-cloudpack/config';\nimport { generatedConfigFileName, readConfig, writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport { createPackageOverrideTransform } from '../../common/createPackageOverrideTransform.js';\nimport { rootSpan } from '../../initTelemetry.js';\nimport { resolveDependenciesTask } from '../../tasks/resolveDependenciesTask.js';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { bundleAndGetImports } from './bundleAndGetImports.js';\nimport { patchAllInternalPackageExports } from './patchAllInternalPackageExports.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\n/** Given the path, updates the Cloudpack config with overrides and project settings. */\nexport async function init(\n options: InitOptions,\n { reporter }: { reporter: TaskReporter },\n): Promise<{\n changeCount: number;\n errorPkgCount: number;\n warningPkgCount: number;\n successPkgCount: number;\n}> {\n if (options.check && options.fix) {\n throw Error('Cannot use --check and --fix together.');\n }\n\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\n\n const appPath = options.cwd || process.cwd();\n const config = await readConfig(appPath);\n const packageOverrides: PackageOverride[] = (!options.reset && config.packageOverrides) || [];\n const packages = new PackageDefinitions();\n\n packages.registerTransform(createPackageOverrideTransform({ packageOverrides }));\n\n // Try to resolve dependencies.\n const resolveMap = (await resolveDependenciesTask({ appPath, packages }, { reporter })) as ResolveMap;\n\n if (!resolveMap) {\n throw new Error(\"Couldn't resolve dependencies.\");\n }\n\n const packagePathsToEvaluate = new Set<string>([appPath]);\n const evaluatedPackages = new Set<string>();\n let changeCount = 0;\n let errorPkgCount = 0;\n let warningPkgCount = 0;\n let successPkgCount = 0;\n\n while (packagePathsToEvaluate.size) {\n const packagePath = packagePathsToEvaluate.values().next().value as string;\n\n packagePathsToEvaluate.delete(packagePath);\n\n // Skip already-visited packages.\n if (!packagePath || evaluatedPackages.has(packagePath)) {\n continue;\n }\n\n evaluatedPackages.add(packagePath);\n\n const definition = await packages.get(packagePath, { refresh: true });\n\n if (!definition) {\n // This is very weird and probably won't happen.\n console.error(`Skipping ${packagePath} evaluation because the package.json was not found or not readable.`);\n errorPkgCount++;\n continue;\n }\n\n // Bundle the package and find the imports it depends on.\n const bundleResult = await bundleAndGetImports({ packagePath, definition, packages, reporter });\n\n if (!bundleResult.imports) {\n // This is expected if the package just doesn't import anything else.\n console.info(`${packagePath} has no additional imports to evaluate.`);\n bundleResult.hasErrors ? errorPkgCount++ : bundleResult.hasWarnings ? warningPkgCount++ : successPkgCount++;\n continue;\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const overridesResult = await evaluateImportsForOverrides({\n definition,\n packages,\n packagePathsToEvaluate,\n evaluatedPackages,\n imports: bundleResult.imports,\n packageOverrides,\n resolveMap,\n });\n\n if (options.check && (overridesResult.changeCount || overridesResult.errors.length)) {\n rootSpan?.addEvent('INIT_CHECK_FAILED', {\n reason: overridesResult.changeCount ? 'Config needs to be updated.' : overridesResult.errors,\n });\n throw Error(\n overridesResult.changeCount\n ? 'Run \"cloudpack init --reset\" to update the config.'\n : overridesResult.errors.map((e) => e).join('\\n'),\n );\n }\n\n changeCount += overridesResult.changeCount;\n\n bundleResult.hasErrors || overridesResult.errors.length\n ? errorPkgCount++\n : bundleResult.hasWarnings\n ? warningPkgCount++\n : successPkgCount++;\n }\n\n if (options.fix) {\n await patchAllInternalPackageExports({ resolveMap, packageOverrides });\n }\n\n if (changeCount) {\n // Log the results to a file.\n console.log(\n `Writing updates to \"${generatedConfigFileName}\". If you're in a git repo, this file should be committed with your project.`,\n );\n\n if (packageOverrides.length) {\n await writeGeneratedConfig({ packageOverrides }, appPath);\n }\n }\n\n return {\n changeCount,\n errorPkgCount,\n warningPkgCount,\n successPkgCount,\n };\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BundleServer } from '../../../types/BundleServer.js';
|
|
2
2
|
import type { PackageJson } from '@ms-cloudpack/bundler-types';
|
|
3
|
+
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
3
4
|
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
4
5
|
import type { ApiServer, Session } from '@ms-cloudpack/api-server';
|
|
5
6
|
/**
|
|
@@ -10,12 +11,13 @@ import type { ApiServer, Session } from '@ms-cloudpack/api-server';
|
|
|
10
11
|
* can support whichever routes the app needs, while the bundle server can provide package
|
|
11
12
|
* assets in various forms using its own routing.
|
|
12
13
|
*/
|
|
13
|
-
export declare function startAppServer({ session, bundleServer, apiServer, definition, config, }: {
|
|
14
|
+
export declare function startAppServer({ session, bundleServer, apiServer, definition, config, reporter, }: {
|
|
14
15
|
session: Session;
|
|
15
16
|
definition: PackageJson;
|
|
16
17
|
bundleServer: BundleServer;
|
|
17
18
|
apiServer: ApiServer;
|
|
18
19
|
config: CloudpackConfig;
|
|
20
|
+
reporter: TaskReporter;
|
|
19
21
|
}): Promise<{
|
|
20
22
|
close: () => Promise<void>;
|
|
21
23
|
port: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startAppServer.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"startAppServer.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,KAAK,YAAY,EAAQ,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAA8B,EAC9B,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;CACxB;;;;GA6CA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createExpressApp } from '@ms-cloudpack/create-express-app';
|
|
2
2
|
import { createRoutes } from './createRoutes.js';
|
|
3
3
|
import { exitIfPortUnavailable } from './exitIfPortUnavailable.js';
|
|
4
|
-
import { reporter } from '../../../reporter.js';
|
|
5
4
|
import { cyan } from '@ms-cloudpack/task-reporter';
|
|
6
5
|
/**
|
|
7
6
|
* The app server hosts the appropriate routes for the web app, primarily returning html content
|
|
@@ -11,7 +10,7 @@ import { cyan } from '@ms-cloudpack/task-reporter';
|
|
|
11
10
|
* can support whichever routes the app needs, while the bundle server can provide package
|
|
12
11
|
* assets in various forms using its own routing.
|
|
13
12
|
*/
|
|
14
|
-
export async function startAppServer({ session, bundleServer, apiServer, definition, config = {}, }) {
|
|
13
|
+
export async function startAppServer({ session, bundleServer, apiServer, definition, config = {}, reporter, }) {
|
|
15
14
|
const { devServer = {} } = config || {};
|
|
16
15
|
// Read the port from the config file or default to array of ports.
|
|
17
16
|
const requireSpecifiedPort = devServer?.port !== undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAm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,CAAC;KACH;IAAC,OAAO,GAAY,EAAE;QACrB,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,4BAA4B,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1F,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAEvD,MAAM,GAAG,CAAC;KACX;AACH,CAAC","sourcesContent":["import { createExpressApp } from '@ms-cloudpack/create-express-app';\nimport type { BundleServer } from '../../../types/BundleServer.js';\nimport type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport { createRoutes } from './createRoutes.js';\nimport { exitIfPortUnavailable } from './exitIfPortUnavailable.js';\nimport { type TaskReporter, cyan } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\n\n/**\n * The app server hosts the appropriate routes for the web app, primarily returning html content\n * which loads resources from the bundle server.\n *\n * Separating the app server from the bundle service keeps the routes separate - the app server\n * can support whichever routes the app needs, while the bundle server can provide package\n * assets in various forms using its own routing.\n */\nexport async function startAppServer({\n session,\n bundleServer,\n apiServer,\n definition,\n config = {} as CloudpackConfig,\n reporter,\n}: {\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n reporter: TaskReporter;\n}) {\n const { devServer = {} } = config || ({} as CloudpackConfig);\n\n // Read the port from the config file or default to array of ports.\n const requireSpecifiedPort = devServer?.port !== undefined;\n const ports = devServer?.port ?? [5000, 5001, 5002, 5003];\n\n // Directory to serve as plain static assets. Defaults to \"public\".\n // Can be overridden by setting the 'publicDir' option in the cloudpack config.\n // const publicDir = path.resolve(devServer.publicPath ?? 'public');\n\n const task = reporter.addTask('Starting app server');\n\n try {\n const { close, port, url } = await createExpressApp({\n portRange: ports,\n requireSpecifiedPort,\n hostname: devServer?.domain,\n sslOptions: config.devServer?.https,\n // publicDir,\n setupCallback: (app, url) =>\n createRoutes({\n app,\n url,\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n }),\n });\n\n task.complete({ message: `Available @ ${cyan(url)}`, forceShow: true });\n\n return {\n close,\n port,\n url,\n };\n } catch (err: unknown) {\n task.complete({ status: 'fail', message: 'Failed to start app server', forceShow: true });\n exitIfPortUnavailable(err, session.projectName, ports);\n\n throw err;\n }\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { BundleTaskOptions } from '../../types/BundleTaskOptions.js';
|
|
2
2
|
import type { BundleRequest } from '../../types/BundleRequest.js';
|
|
3
3
|
import type { Task } from '@ms-cloudpack/api-server';
|
|
4
|
+
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
4
5
|
/**
|
|
5
6
|
* Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked
|
|
6
7
|
* remotely (e.g. in the browser) and allows the user to cancel tasks.
|
|
7
8
|
*/
|
|
8
|
-
export declare function createBundleTask(bundleRequest: BundleRequest, options?: BundleTaskOptions): Task<BundleRequest>;
|
|
9
|
+
export declare function createBundleTask(bundleRequest: BundleRequest, options?: BundleTaskOptions, reporter?: TaskReporter): Task<BundleRequest>;
|
|
9
10
|
//# sourceMappingURL=createBundleTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBundleTask.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createBundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAiC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"createBundleTask.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createBundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAiC,MAAM,0BAA0B,CAAC;AAIpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,EAC3B,QAAQ,CAAC,EAAE,YAAY,GACtB,IAAI,CAAC,aAAa,CAAC,CAoCrB"}
|
|
@@ -5,7 +5,7 @@ import { bundleTask } from '../../tasks/bundleTask.js';
|
|
|
5
5
|
* Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked
|
|
6
6
|
* remotely (e.g. in the browser) and allows the user to cancel tasks.
|
|
7
7
|
*/
|
|
8
|
-
export function createBundleTask(bundleRequest, options) {
|
|
8
|
+
export function createBundleTask(bundleRequest, options, reporter) {
|
|
9
9
|
const { id, packageName, version, outputPath, packagePath, isExternal } = bundleRequest;
|
|
10
10
|
return {
|
|
11
11
|
name: `Bundle ${packageName}@${version}`,
|
|
@@ -13,7 +13,7 @@ export function createBundleTask(bundleRequest, options) {
|
|
|
13
13
|
dir: `${path.join(packagePath, 'src')}`,
|
|
14
14
|
watch: !isExternal,
|
|
15
15
|
async execute() {
|
|
16
|
-
await bundleTask({ bundleRequest, options });
|
|
16
|
+
await bundleTask({ bundleRequest, options, reporter });
|
|
17
17
|
return bundleRequest;
|
|
18
18
|
},
|
|
19
19
|
clear: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../../src/commands/start/createBundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":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AAS,EAAE,WAAW,IAAI,EAAE;YAC5B,UAAU;SACX,CAAC;QACF,iBAAiB,EAAE,CAAC,UAAU,EAAE,EAAE,CAChC,CAAC;YACC,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;YAClC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ;SAChB,CAAA;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleTaskOptions } from '../../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\nimport type { Task, TaskEndDescription, TaskError } from '@ms-cloudpack/api-server';\nimport path from 'path';\nimport fs from 'fs';\nimport { bundleTask } from '../../tasks/bundleTask.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\n/**\n * Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked\n * remotely (e.g. in the browser) and allows the user to cancel tasks.\n */\nexport function createBundleTask(\n bundleRequest: BundleRequest,\n options?: BundleTaskOptions,\n reporter?: TaskReporter,\n): Task<BundleRequest> {\n const { id, packageName, version, outputPath, packagePath, isExternal } = bundleRequest;\n\n return {\n name: `Bundle ${packageName}@${version}`,\n id,\n dir: `${path.join(packagePath, 'src')}`,\n watch: !isExternal,\n async execute(): Promise<BundleRequest> {\n await bundleTask({ bundleRequest, options, reporter });\n\n return bundleRequest;\n },\n clear: () => {\n bundleRequest.result?.dispose?.();\n bundleRequest.result = undefined;\n // eslint-disable-next-line no-restricted-syntax -- this function can't be async\n fs.rmSync(outputPath, { recursive: true, force: true });\n },\n onDispose: () => {\n bundleRequest.result?.dispose?.();\n },\n getErrors: () => (<unknown>bundleRequest.result?.errors) as TaskError[],\n getStartDescription: () => ({\n id,\n name: `Bundle ${packageName}@${version}`,\n inputPath: packagePath || '',\n outputPath,\n }),\n getEndDescription: (taskResult) =>\n ({\n id,\n errors: taskResult?.result?.errors,\n warnings: taskResult?.result?.warnings,\n } as TaskEndDescription),\n };\n}\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { Session } from '@ms-cloudpack/api-server';
|
|
2
2
|
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
3
|
+
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
3
4
|
export interface SessionOptions {
|
|
4
5
|
appPath: string;
|
|
5
6
|
config: CloudpackConfig;
|
|
6
7
|
}
|
|
7
|
-
export declare function createSession(options: SessionOptions
|
|
8
|
+
export declare function createSession(options: SessionOptions, context: {
|
|
9
|
+
reporter: TaskReporter;
|
|
10
|
+
}): Promise<Session>;
|
|
8
11
|
//# sourceMappingURL=createSession.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAQ5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAyDlH"}
|
|
@@ -8,14 +8,14 @@ import { getLocalCachePath } from '../../common/getCachePath.js';
|
|
|
8
8
|
import { resolveDependenciesTask } from '../../tasks/resolveDependenciesTask.js';
|
|
9
9
|
const dashboardPackageName = '@ms-cloudpack/overlay';
|
|
10
10
|
const dashboardPackagePath = (await resolve(dashboardPackageName, path.dirname(fileURLToPath(import.meta.url)))) || '';
|
|
11
|
-
export async function createSession(options) {
|
|
11
|
+
export async function createSession(options, context) {
|
|
12
12
|
const { appPath, config } = options;
|
|
13
13
|
const projectName = path.basename(appPath);
|
|
14
14
|
const id = uuid();
|
|
15
15
|
const resolveMap = await resolveDependenciesTask({
|
|
16
16
|
appPath,
|
|
17
17
|
additionalPaths: [dashboardPackagePath],
|
|
18
|
-
});
|
|
18
|
+
}, context);
|
|
19
19
|
if (!resolveMap) {
|
|
20
20
|
throw new Error('Could not resolve dependencies.');
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../src/commands/start/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAE,OAAO,EAAkB,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../src/commands/start/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAE,OAAO,EAAkB,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE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AAC,EAAE,CAAC,CAAC;KAChE;IACD,MAAM,cAAc,GAAG,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAA2B,CAAC;IAE9F,OAAO;QACL,EAAE;QACF,OAAO;QACP,MAAM;QACN,WAAW;QACX,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,UAAU;QACV,QAAQ,EAAE,CAAC;QACX,cAAc;QACd,iBAAiB,EAAE,GAAG,EAAE,CAAC,cAAc;QACvC,uBAAuB,EAAE,CAAC,OAAgB,EAAE,EAAE;YAC5C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,GAAG,cAAc,EAAE;gBACrD,cAAc,GAAG,OAAO,IAAI,cAAc,GAAG,CAAC,CAAC;gBAC/C,SAAS,GAAG,SAAS,CAAC;aACvB;QACH,CAAC;QACD,sBAAsB,EAAE,CAAC,SAAiB,EAAE,EAAE;YAC5C,cAAc,CAAC,SAAS,MAAxB,cAAc,CAAC,SAAS,IAAM,CAAC,EAAC;YAChC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,SAAS,GAAG,SAAS,CAAC;YACtB,gFAAgF;YAChF,EAAE,CAAC,aAAa,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;QAC7B,YAAY,EAAE,CAAC,YAAuB,EAAE,EAAE;YACxC,SAAS,GAAG,YAAY,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { v4 as uuid } from 'uuid';\nimport type { Session } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport { resolve, type ImportMap } from '@ms-cloudpack/package-utilities';\nimport fs from 'fs';\nimport fsExtra from 'fs-extra';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { getLocalCachePath } from '../../common/getCachePath.js';\nimport { resolveDependenciesTask } from '../../tasks/resolveDependenciesTask.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\nconst dashboardPackageName = '@ms-cloudpack/overlay';\nconst dashboardPackagePath = (await resolve(dashboardPackageName, path.dirname(fileURLToPath(import.meta.url)))) || '';\n\nexport interface SessionOptions {\n appPath: string;\n config: CloudpackConfig;\n}\n\nexport async function createSession(options: SessionOptions, context: { reporter: TaskReporter }): Promise<Session> {\n const { appPath, config } = options;\n const projectName = path.basename(appPath);\n const id = uuid();\n const resolveMap = await resolveDependenciesTask(\n {\n appPath,\n additionalPaths: [dashboardPackagePath],\n },\n context,\n );\n\n if (!resolveMap) {\n throw new Error('Could not resolve dependencies.');\n }\n\n let importMap: ImportMap | undefined = undefined;\n let sessionVersion = 0;\n\n await fsExtra.ensureDir(getLocalCachePath(appPath));\n const targetVersionsPath = path.join(getLocalCachePath(appPath), 'targetVersions.json');\n const fileExists = await fsExtra.pathExists(targetVersionsPath);\n if (!fileExists) {\n await fsExtra.writeJson(targetVersionsPath, {}, { spaces: 2 });\n }\n const targetVersions = (await fsExtra.readJSON(targetVersionsPath)) as Record<string, number>;\n\n return {\n id,\n appPath,\n config,\n projectName,\n type: 'web-app',\n mode: 'library',\n resolveMap,\n sequence: 0,\n targetVersions,\n getSessionVersion: () => sessionVersion,\n incrementSessionVersion: (version?: number) => {\n if (version === undefined || version > sessionVersion) {\n sessionVersion = version ?? sessionVersion + 1;\n importMap = undefined;\n }\n },\n incrementTargetVersion: (inputPath: string) => {\n targetVersions[inputPath] ||= 0;\n targetVersions[inputPath]++;\n importMap = undefined;\n // eslint-disable-next-line no-restricted-syntax -- this function can't be async\n fs.writeFileSync(targetVersionsPath, JSON.stringify(targetVersions, null, 2));\n },\n getImportMap: () => importMap,\n setImportMap: (newImportMap: ImportMap) => {\n importMap = newImportMap;\n return importMap;\n },\n };\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
1
|
+
import type { CommandFunction } from '../../types/CommandFunction.js';
|
|
2
|
+
export declare const init: CommandFunction;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAItE,eAAO,MAAM,IAAI,EAAE,eAOlB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* Defines the "start" verb. */
|
|
2
|
-
export
|
|
2
|
+
export const init = ({ command, reporter }) => {
|
|
3
3
|
command
|
|
4
4
|
.command('start')
|
|
5
5
|
.description('Starts a web inner-loop from the current package folder.')
|
|
6
6
|
.option('--log-resolve-map', 'Logs the resolve map to "resolve-map.json" for diagnostics.')
|
|
7
7
|
.option('--features <featureName> [featureNames...]', 'Enable experimental features.')
|
|
8
|
-
.action(async (options) => (await import('./start.js')).start(options));
|
|
9
|
-
}
|
|
8
|
+
.action(async (options) => (await import('./start.js')).start(options, { reporter }));
|
|
9
|
+
};
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC7D,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,mBAAmB,EAAE,6DAA6D,CAAC;SAC1F,MAAM,CAAC,4CAA4C,EAAE,+BAA+B,CAAC;SACrF,MAAM,CAAC,KAAK,EAAE,OAAqB,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACxG,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\nimport type { StartOptions } from './types/StartOptions.js';\n\n/* Defines the \"start\" verb. */\nexport const init: CommandFunction = ({ command, reporter }) => {\n command\n .command('start')\n .description('Starts a web inner-loop from the current package folder.')\n .option('--log-resolve-map', 'Logs the resolve map to \"resolve-map.json\" for diagnostics.')\n .option('--features <featureName> [featureNames...]', 'Enable experimental features.')\n .action(async (options: StartOptions) => (await import('./start.js')).start(options, { reporter }));\n};\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { StartOptions } from './types/StartOptions.js';
|
|
2
|
+
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
3
|
/**
|
|
3
4
|
* Defines the "start" verb entry point.
|
|
4
5
|
*/
|
|
5
|
-
export declare function start(options: StartOptions
|
|
6
|
+
export declare function start(options: StartOptions, { reporter }: {
|
|
7
|
+
reporter: TaskReporter;
|
|
8
|
+
}): Promise<void>;
|
|
6
9
|
//# sourceMappingURL=start.d.ts.map
|