@ms-cloudpack/cli 0.54.20 → 0.54.22
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/sync/execute.d.ts.map +1 -1
- package/lib/commands/sync/execute.js +5 -0
- package/lib/commands/sync/execute.js.map +1 -1
- package/lib/common/createInitializeFunction.d.ts.map +1 -1
- package/lib/common/createInitializeFunction.js +13 -7
- package/lib/common/createInitializeFunction.js.map +1 -1
- package/lib/common/getMergedFeatureFlags.d.ts +6 -0
- package/lib/common/getMergedFeatureFlags.d.ts.map +1 -0
- package/lib/common/getMergedFeatureFlags.js +32 -0
- package/lib/common/getMergedFeatureFlags.js.map +1 -0
- package/lib/common/mergeFeatures.d.ts +4 -1
- package/lib/common/mergeFeatures.d.ts.map +1 -1
- package/lib/common/mergeFeatures.js +2 -2
- package/lib/common/mergeFeatures.js.map +1 -1
- package/lib/setupReporting.d.ts +1 -1
- package/lib/setupReporting.d.ts.map +1 -1
- package/lib/setupReporting.js +2 -5
- package/lib/setupReporting.js.map +1 -1
- package/lib/utilities/getRepositoryName.d.ts +6 -0
- package/lib/utilities/getRepositoryName.d.ts.map +1 -0
- package/lib/utilities/getRepositoryName.js +32 -0
- package/lib/utilities/getRepositoryName.js.map +1 -0
- package/package.json +10 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAmD9C,CAAC"}
|
|
@@ -3,6 +3,11 @@ import { runPrerequisites } from '../../common/runPrerequisites.js';
|
|
|
3
3
|
export const execute = async ({ options, reporter, initialize, exit, autoDispose }) => {
|
|
4
4
|
const { cwd, login, upload } = options;
|
|
5
5
|
const { config, telemetryClient } = await initialize({ appPath: cwd });
|
|
6
|
+
if (!config.features?.syncBundles) {
|
|
7
|
+
console.warn('Sync is disabled.');
|
|
8
|
+
await exit({ exitCode: 0 });
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
6
11
|
try {
|
|
7
12
|
const remoteCacheConfig = config.remoteCache;
|
|
8
13
|
if (!remoteCacheConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE;IAChH,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEvE,IAAI,CAAC;QACH,MAAM,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAAC;QAC7C,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CACV,gHAAgH,CACjH,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG;YACZ,WAAW,EAAE,KAAK;SACnB,CAAC;QAEF,MAAM,iBAAiB,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;QAC9E,IAAI,MAAM,EAAE,CAAC;YACX,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAE9B,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CACvB,MAAM,uBAAuB,CAAC;gBAC5B,GAAG,iBAAiB;gBACpB,KAAK,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,oBAAoB,EAAE,eAAe,CAAC;aACtG,CAAC,CACH,CAAC;YACF,MAAM,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CACvB,MAAM,uBAAuB,CAAC;gBAC5B,GAAG,iBAAiB;gBACpB,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,eAAe,CAAC;aAChD,CAAC,CACH,CAAC;YACF,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server/apis';\nimport { runPrerequisites } from '../../common/runPrerequisites.js';\n\nexport const execute: CommandAction<SyncOptions> = async ({ options, reporter, initialize, exit, autoDispose }) => {\n const { cwd, login, upload } = options;\n const { config, telemetryClient } = await initialize({ appPath: cwd });\n\n try {\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n console.warn(\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n );\n return;\n }\n\n const input = {\n loginMethod: login,\n };\n\n const apiContextOptions = { appPath: cwd, config, reporter, telemetryClient };\n if (upload) {\n runPrerequisites(config, cwd);\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n await exit({ exitCode: 0 });\n } catch (error) {\n if (error instanceof Error) {\n telemetryClient.rootSpan.recordException(error);\n }\n throw error;\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE;IAChH,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEvE,IAAI,CAAC,MAAM,CAAC,Q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AC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server/apis';\nimport { runPrerequisites } from '../../common/runPrerequisites.js';\n\nexport const execute: CommandAction<SyncOptions> = async ({ options, reporter, initialize, exit, autoDispose }) => {\n const { cwd, login, upload } = options;\n const { config, telemetryClient } = await initialize({ appPath: cwd });\n\n if (!config.features?.syncBundles) {\n console.warn('Sync is disabled.');\n await exit({ exitCode: 0 });\n return;\n }\n\n try {\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n console.warn(\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n );\n return;\n }\n\n const input = {\n loginMethod: login,\n };\n\n const apiContextOptions = { appPath: cwd, config, reporter, telemetryClient };\n if (upload) {\n runPrerequisites(config, cwd);\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n await exit({ exitCode: 0 });\n } catch (error) {\n if (error instanceof Error) {\n telemetryClient.rootSpan.recordException(error);\n }\n throw error;\n }\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInitializeFunction.d.ts","sourceRoot":"","sources":["../../src/common/createInitializeFunction.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"createInitializeFunction.d.ts","sourceRoot":"","sources":["../../src/common/createInitializeFunction.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,QAAQ,EAAE,YAAY,CAAC;IACvB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,mDAAmD;IACnD,OAAO,EAAE,aAAa,CAAC;CACxB,sBAEoD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,QAAQ,aAAa,CAAC,CAAA;CAAE;;;GAmDlH"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { readConfig } from '@ms-cloudpack/config';
|
|
2
2
|
import { yellow } from '@ms-cloudpack/task-reporter';
|
|
3
3
|
import { setupReporting } from '../setupReporting.js';
|
|
4
|
-
import { mergeFeatures } from './mergeFeatures.js';
|
|
5
4
|
import { checkFeatures } from './checkFeatures.js';
|
|
5
|
+
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { getMergedFeatureFlags } from './getMergedFeatureFlags.js';
|
|
6
8
|
export function createInitializeFunction(params) {
|
|
7
9
|
const { reporter, autoDispose, command } = params;
|
|
8
10
|
return async function initialize(initializeParams) {
|
|
@@ -12,15 +14,19 @@ export function createInitializeFunction(params) {
|
|
|
12
14
|
...initializeParams.optionsOverrides,
|
|
13
15
|
};
|
|
14
16
|
const config = await readConfig(appPath);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
commandLineFeatures: actionOptions.features,
|
|
19
|
-
});
|
|
17
|
+
const definition = (await readJson(path.join(appPath, 'package.json')));
|
|
18
|
+
// Merge in any additional features from the command line and remote feature flags.
|
|
19
|
+
config.features = await getMergedFeatureFlags(config, actionOptions, appPath, definition.name);
|
|
20
20
|
const enabledFeatureNames = Object.entries(config.features)
|
|
21
21
|
.filter(([, value]) => value)
|
|
22
22
|
.map(([key]) => key);
|
|
23
|
-
const telemetryClient = await setupReporting({
|
|
23
|
+
const telemetryClient = await setupReporting({
|
|
24
|
+
appName: definition.name,
|
|
25
|
+
config,
|
|
26
|
+
reporter,
|
|
27
|
+
command,
|
|
28
|
+
options: actionOptions,
|
|
29
|
+
});
|
|
24
30
|
const errors = checkFeatures({ configFeatures: config.features });
|
|
25
31
|
// If there are any invalid features, exit with an error.
|
|
26
32
|
if (errors.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInitializeFunction.js","sourceRoot":"","sources":["../../src/common/createInitializeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAqB,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"createInitializeFunction.js","sourceRoot":"","sources":["../../src/common/createInitializeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAqB,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD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AC,CAAC;QAClE,yDAAyD;QACzD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAC/B,eAAe,CAAC,sBAAsB,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;YACxE,OAAO,CAAC,GAAG,CAAC,qBAAqB,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3F,CAAC;QAED,uDAAuD;QACvD,MAAM,sBAAsB,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC9E,MAAM,mBAAmB,GAAe;YACtC,OAAO,EAAE,sBAAsB;SAChC,CAAC;QACF,WAAW,CAAC,mBAAmB,CAAC,CAAC;QAEjC,OAAO;YACL,eAAe;YACf,MAAM;SACP,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport { yellow, type TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { Command } from 'commander';\nimport { setupReporting } from '../setupReporting.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport type { AutoDispose } from '../types/AutoDispose.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport type { Disposable } from '../types/Disposable.js';\nimport type { PackageJson } from '@ms-cloudpack/config-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport { getMergedFeatureFlags } from './getMergedFeatureFlags.js';\n\nexport function createInitializeFunction(params: {\n reporter: TaskReporter;\n /** Command object for the current command (not the whole program). */\n command: Command;\n autoDispose: AutoDispose;\n /** Options from CLI args for the whole program. */\n options: SharedOptions;\n}) {\n const { reporter, autoDispose, command } = params;\n return async function initialize(initializeParams: { appPath: string; optionsOverrides?: Partial<SharedOptions> }) {\n const { appPath } = initializeParams;\n\n const actionOptions: SharedOptions = {\n ...params.options,\n ...initializeParams.optionsOverrides,\n };\n\n const config = await readConfig(appPath);\n\n const definition = (await readJson(path.join(appPath, 'package.json'))) as PackageJson;\n\n // Merge in any additional features from the command line and remote feature flags.\n config.features = await getMergedFeatureFlags(config, actionOptions, appPath, definition.name);\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n const telemetryClient = await setupReporting({\n appName: definition.name,\n config,\n reporter,\n command,\n options: actionOptions,\n });\n\n const errors = checkFeatures({ configFeatures: config.features });\n // If there are any invalid features, exit with an error.\n if (errors.length) {\n errors.forEach((error) => console.error(error));\n process.exit(1);\n }\n\n if (enabledFeatureNames.length) {\n telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n // Dispose the telemetry client when the app is closing\n const disposeTelemetryClient = telemetryClient.shutdown.bind(telemetryClient);\n const disposableTelemetry: Disposable = {\n dispose: disposeTelemetryClient,\n };\n autoDispose(disposableTelemetry);\n\n return {\n telemetryClient,\n config,\n };\n };\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SharedOptions } from '../types/SharedOptions.js';
|
|
2
|
+
import { type CloudpackConfig } from '@ms-cloudpack/config-types';
|
|
3
|
+
export declare function getMergedFeatureFlags(config: CloudpackConfig, actionOptions: SharedOptions, appPath: string, appName?: string): Promise<{
|
|
4
|
+
[x: string]: boolean | undefined;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=getMergedFeatureFlags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMergedFeatureFlags.d.ts","sourceRoot":"","sources":["../../src/common/getMergedFeatureFlags.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG/E,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM;;GAiCjB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { mergeFeatures } from './mergeFeatures.js';
|
|
2
|
+
import { downloadFeatureFlags, getFeatureFlags } from '@ms-cloudpack/feature-flags';
|
|
3
|
+
import { allFeatures } from '@ms-cloudpack/config-types';
|
|
4
|
+
import { getRepositoryName } from '../utilities/getRepositoryName.js';
|
|
5
|
+
export async function getMergedFeatureFlags(config, actionOptions, appPath, appName) {
|
|
6
|
+
const repositoryName = await getRepositoryName(appPath);
|
|
7
|
+
// Get the feature flags for the current application. (ie: cloudpack.@ms-cloudpack/onedrive-mock)
|
|
8
|
+
const remoteFeatureFlags = appName && repositoryName
|
|
9
|
+
? getFeatureFlags({
|
|
10
|
+
applicationName: `cloudpack.${appName}`,
|
|
11
|
+
repositoryName,
|
|
12
|
+
})
|
|
13
|
+
: {};
|
|
14
|
+
// remove invalid remove feature flags from remoteFeatureFlags
|
|
15
|
+
const validFeatures = new Set(Object.keys(allFeatures));
|
|
16
|
+
Object.keys(remoteFeatureFlags).forEach((key) => {
|
|
17
|
+
if (!validFeatures.has(key)) {
|
|
18
|
+
delete remoteFeatureFlags[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
// Kick off an async download operation for feature flags.
|
|
22
|
+
// Downloaded feature flags will be used by the cloudpack in the next run.
|
|
23
|
+
void downloadFeatureFlags();
|
|
24
|
+
// Merge in any additional features from the command line.
|
|
25
|
+
const mergedFeatures = mergeFeatures({
|
|
26
|
+
remoteFeatureFlags,
|
|
27
|
+
configFeatures: config.features,
|
|
28
|
+
commandLineFeatures: actionOptions.features,
|
|
29
|
+
});
|
|
30
|
+
return mergedFeatures;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=getMergedFeatureFlags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMergedFeatureFlags.js","sourceRoot":"","sources":["../../src/common/getMergedFeatureFlags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,WAAW,EAAwB,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAuB,EACvB,aAA4B,EAC5B,OAAe,EACf,OAAgB;IAEhB,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAExD,iGAAiG;IACjG,MAAM,kBAAkB,GACtB,OAAO,IAAI,cAAc;QACvB,CAAC,CAAC,eAAe,CAAC;YACd,eAAe,EAAE,aAAa,OAAO,EAAE;YACvC,cAAc;SACf,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IAET,8DAA8D;IAC9D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAChE,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC9C,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,0EAA0E;IAC1E,KAAK,oBAAoB,EAAE,CAAC;IAE5B,0DAA0D;IAC1D,MAAM,cAAc,GAAG,aAAa,CAAC;QACnC,kBAAkB;QAClB,cAAc,EAAE,MAAM,CAAC,QAAQ;QAC/B,mBAAmB,EAAE,aAAa,CAAC,QAAQ;KAC5C,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import { mergeFeatures } from './mergeFeatures.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { downloadFeatureFlags, getFeatureFlags } from '@ms-cloudpack/feature-flags';\nimport { allFeatures, type CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { getRepositoryName } from '../utilities/getRepositoryName.js';\n\nexport async function getMergedFeatureFlags(\n config: CloudpackConfig,\n actionOptions: SharedOptions,\n appPath: string,\n appName?: string,\n) {\n const repositoryName = await getRepositoryName(appPath);\n\n // Get the feature flags for the current application. (ie: cloudpack.@ms-cloudpack/onedrive-mock)\n const remoteFeatureFlags =\n appName && repositoryName\n ? getFeatureFlags({\n applicationName: `cloudpack.${appName}`,\n repositoryName,\n })\n : {};\n\n // remove invalid remove feature flags from remoteFeatureFlags\n const validFeatures = new Set<string>(Object.keys(allFeatures));\n Object.keys(remoteFeatureFlags).forEach((key) => {\n if (!validFeatures.has(key)) {\n delete remoteFeatureFlags[key];\n }\n });\n\n // Kick off an async download operation for feature flags.\n // Downloaded feature flags will be used by the cloudpack in the next run.\n void downloadFeatureFlags();\n\n // Merge in any additional features from the command line.\n const mergedFeatures = mergeFeatures({\n remoteFeatureFlags,\n configFeatures: config.features,\n commandLineFeatures: actionOptions.features,\n });\n\n return mergedFeatures;\n}\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { allFeatures } from '@ms-cloudpack/config-types';
|
|
2
|
-
export declare function mergeFeatures<TFeatureSet extends Record<string, unknown> = typeof allFeatures>({ configFeatures, commandLineFeatures, featureSet, }: {
|
|
2
|
+
export declare function mergeFeatures<TFeatureSet extends Record<string, unknown> = typeof allFeatures>({ configFeatures, commandLineFeatures, remoteFeatureFlags, featureSet, }: {
|
|
3
3
|
configFeatures?: {
|
|
4
4
|
[key in keyof typeof featureSet]?: boolean;
|
|
5
5
|
};
|
|
6
|
+
remoteFeatureFlags?: {
|
|
7
|
+
[key in keyof typeof featureSet]?: boolean;
|
|
8
|
+
};
|
|
6
9
|
commandLineFeatures?: string[];
|
|
7
10
|
featureSet?: TFeatureSet;
|
|
8
11
|
}): { [key in keyof TFeatureSet]?: boolean | undefined; };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeFeatures.d.ts","sourceRoot":"","sources":["../../src/common/mergeFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,wBAAgB,aAAa,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,WAAW,EAAE,EAC9F,cAAc,EACd,mBAAmB,EACnB,UAAkD,GACnD,EAAE;IACD,cAAc,CAAC,EAAE;SAAG,GAAG,IAAI,MAAM,OAAO,UAAU,CAAC,CAAC,EAAE,OAAO;KAAE,CAAC;IAChE,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B,yDAiBA"}
|
|
1
|
+
{"version":3,"file":"mergeFeatures.d.ts","sourceRoot":"","sources":["../../src/common/mergeFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,wBAAgB,aAAa,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,WAAW,EAAE,EAC9F,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,UAAkD,GACnD,EAAE;IACD,cAAc,CAAC,EAAE;SAAG,GAAG,IAAI,MAAM,OAAO,UAAU,CAAC,CAAC,EAAE,OAAO;KAAE,CAAC;IAChE,kBAAkB,CAAC,EAAE;SAAG,GAAG,IAAI,MAAM,OAAO,UAAU,CAAC,CAAC,EAAE,OAAO;KAAE,CAAC;IACpE,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B,yDAiBA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { allFeatures } from '@ms-cloudpack/config-types';
|
|
2
|
-
export function mergeFeatures({ configFeatures, commandLineFeatures, featureSet = allFeatures, }) {
|
|
2
|
+
export function mergeFeatures({ configFeatures, commandLineFeatures, remoteFeatureFlags, featureSet = allFeatures, }) {
|
|
3
3
|
const featureList = Object.keys(featureSet);
|
|
4
|
-
const features = { ...configFeatures };
|
|
4
|
+
const features = { ...remoteFeatureFlags, ...configFeatures };
|
|
5
5
|
commandLineFeatures?.forEach((partialFeatureName) => {
|
|
6
6
|
// Prefer an exact match, but fall back to partial match.
|
|
7
7
|
const matchedFeatureName = (featureList.find((f) => f.toLowerCase() === partialFeatureName.toLowerCase()) ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeFeatures.js","sourceRoot":"","sources":["../../src/common/mergeFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,UAAU,aAAa,CAAmE,EAC9F,cAAc,EACd,mBAAmB,EACnB,UAAU,GAAG,WAAqC,
|
|
1
|
+
{"version":3,"file":"mergeFeatures.js","sourceRoot":"","sources":["../../src/common/mergeFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,UAAU,aAAa,CAAmE,EAC9F,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,GAAG,WAAqC,GAMnD;IACC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,EAAE,GAAG,kBAAkB,EAAE,GAAG,cAAc,EAAE,CAAC;IAE9D,mBAAmB,EAAE,OAAO,CAAC,CAAC,kBAAkB,EAAE,EAAE;QAClD,yDAAyD;QACzD,MAAM,kBAAkB,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,kBAAkB,CAAC,WAAW,EAAE,CAAC;YACvG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAE5E,CAAC;QAEd,IAAI,kBAAkB,EAAE,CAAC;YACvB,QAAQ,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,QAA0D,CAAC;AACpE,CAAC","sourcesContent":["import { allFeatures } from '@ms-cloudpack/config-types';\n\nexport function mergeFeatures<TFeatureSet extends Record<string, unknown> = typeof allFeatures>({\n configFeatures,\n commandLineFeatures,\n remoteFeatureFlags,\n featureSet = allFeatures as unknown as TFeatureSet,\n}: {\n configFeatures?: { [key in keyof typeof featureSet]?: boolean };\n remoteFeatureFlags?: { [key in keyof typeof featureSet]?: boolean };\n commandLineFeatures?: string[];\n featureSet?: TFeatureSet;\n}) {\n const featureList = Object.keys(featureSet);\n const features = { ...remoteFeatureFlags, ...configFeatures };\n\n commandLineFeatures?.forEach((partialFeatureName) => {\n // Prefer an exact match, but fall back to partial match.\n const matchedFeatureName = (featureList.find((f) => f.toLowerCase() === partialFeatureName.toLowerCase()) ||\n featureList.find((f) => f.toLowerCase().indexOf(partialFeatureName.toLowerCase()) > -1)) as\n | keyof typeof features\n | undefined;\n\n if (matchedFeatureName) {\n features[matchedFeatureName] = true;\n }\n });\n\n return features as { [key in keyof typeof featureSet]?: boolean };\n}\n"]}
|
package/lib/setupReporting.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
|
3
3
|
import type { Command } from 'commander';
|
|
4
4
|
import type { SharedOptions } from './types/SharedOptions.js';
|
|
5
5
|
export declare function setupReporting(params: {
|
|
6
|
+
appName?: string;
|
|
6
7
|
options: SharedOptions;
|
|
7
8
|
reporter: TaskReporter;
|
|
8
9
|
config: CloudpackConfig;
|
|
9
|
-
appPath: string;
|
|
10
10
|
/** Command object for the current command (not the whole program). */
|
|
11
11
|
command: Command;
|
|
12
12
|
}): Promise<import("@ms-cloudpack/telemetry").TelemetryClient>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupReporting.d.ts","sourceRoot":"","sources":["../src/setupReporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"setupReporting.d.ts","sourceRoot":"","sources":["../src/setupReporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,wBAAsB,cAAc,CAAC,MAAM,EAAE;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;CAClB,8DA8CA"}
|
package/lib/setupReporting.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
2
1
|
import { getVersion } from '@ms-cloudpack/package-utilities';
|
|
3
2
|
import { bold, defaultLoggingConfig, verboseLoggingConfig, debugLoggingConfig, noLoggingConfig, } from '@ms-cloudpack/task-reporter';
|
|
4
|
-
import path from 'path';
|
|
5
3
|
import { initTelemetry } from './initTelemetry.js';
|
|
6
4
|
import { isCIBuild } from './utilities/isCIBuild.js';
|
|
7
5
|
const version = getVersion(import.meta.url);
|
|
8
6
|
export async function setupReporting(params) {
|
|
9
|
-
const {
|
|
7
|
+
const { appName, config, reporter, options, command } = params;
|
|
10
8
|
// commander stores the original argv under the "program" command where `parseAsync` was called.
|
|
11
9
|
// Usually `command` is a sub-command (e.g. "bundle"), but it could also be a sub-sub-command
|
|
12
10
|
// (e.g. "cache clean"), so we look up two levels if present.
|
|
@@ -31,7 +29,6 @@ export async function setupReporting(params) {
|
|
|
31
29
|
? noLoggingConfig
|
|
32
30
|
: defaultLoggingConfig),
|
|
33
31
|
});
|
|
34
|
-
const definition = (await readJson(path.join(appPath, 'package.json')));
|
|
35
32
|
const telemetryClient = await initTelemetry({
|
|
36
33
|
useDebugLogging: !!options.debug,
|
|
37
34
|
useVerboseLogging: !!options.verbose,
|
|
@@ -40,7 +37,7 @@ export async function setupReporting(params) {
|
|
|
40
37
|
verb,
|
|
41
38
|
arguments: argv.slice(3).join(' '),
|
|
42
39
|
environment: isCIBuild() ? 'ci' : 'local',
|
|
43
|
-
appName:
|
|
40
|
+
appName: appName || '<unknown>',
|
|
44
41
|
},
|
|
45
42
|
}, reporter);
|
|
46
43
|
return telemetryClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupReporting.js","sourceRoot":"","sources":["../src/setupReporting.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"setupReporting.js","sourceRoot":"","sources":["../src/setupReporting.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EACL,IAAI,EACJ,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,GAEhB,MAAM,6BAA6B,CAA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,CAAC;KAC9B,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,MAAM,aAAa,CACzC;QACE,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK;QAChC,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO;QACpC,eAAe,EAAE,MAAM,CAAC,SAAS;QACjC,oBAAoB,EAAE;YACpB,IAAI;YACJ,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAClC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;YACzC,OAAO,EAAE,OAAO,IAAI,WAAW;SAChC;KACF,EACD,QAAQ,CACT,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport {\n bold,\n defaultLoggingConfig,\n verboseLoggingConfig,\n debugLoggingConfig,\n noLoggingConfig,\n type TaskReporter,\n} from '@ms-cloudpack/task-reporter';\nimport type { Command } from 'commander';\nimport { initTelemetry } from './initTelemetry.js';\nimport type { SharedOptions } from './types/SharedOptions.js';\nimport { isCIBuild } from './utilities/isCIBuild.js';\n\nconst version = getVersion(import.meta.url);\n\nexport async function setupReporting(params: {\n appName?: string;\n options: SharedOptions;\n reporter: TaskReporter;\n config: CloudpackConfig;\n /** Command object for the current command (not the whole program). */\n command: Command;\n}) {\n const { appName, config, reporter, options, command } = params;\n\n // commander stores the original argv under the \"program\" command where `parseAsync` was called.\n // Usually `command` is a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\"), so we look up two levels if present.\n const program = command.parent?.parent || command.parent || command;\n // It looks like rawArgs was intended to be a public API (\"private\" member are prefixed with _)\n // but isn't included in the types...\n const argv = (program as unknown as { rawArgs: string[] }).rawArgs;\n\n // For same reasons as above, check if this is a sub-sub-command\n const verb = command.parent?.parent ? command.parent.name() : command.name();\n\n // Set reporter options and print the product info header\n reporter.setOptions({\n productName: 'Cloudpack',\n version,\n description: () => `Running \"${bold(argv.slice(2).join(' '))}\"`,\n helpMessage: config.helpMessage,\n plainTextMode: !options.color,\n ...(options.debug\n ? debugLoggingConfig\n : options.verbose\n ? verboseLoggingConfig\n : options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n const telemetryClient = await initTelemetry(\n {\n useDebugLogging: !!options.debug,\n useVerboseLogging: !!options.verbose,\n telemetryConfig: config.telemetry,\n sharedSpanAttributes: {\n verb,\n arguments: argv.slice(3).join(' '),\n environment: isCIBuild() ? 'ci' : 'local',\n appName: appName || '<unknown>',\n },\n },\n reporter,\n );\n\n return telemetryClient;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the name of the workspace or git repository from the root package.json.
|
|
3
|
+
* @returns The name of the workspace or repository. If the name is not found, undefined is returned.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getRepositoryName(appPath: string): Promise<string | undefined>;
|
|
6
|
+
//# sourceMappingURL=getRepositoryName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRepositoryName.d.ts","sourceRoot":"","sources":["../../src/utilities/getRepositoryName.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,+BAkBtD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { findGitRoot } from 'workspace-tools';
|
|
2
|
+
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
function getGitRoot(cwd) {
|
|
5
|
+
try {
|
|
6
|
+
return findGitRoot(cwd);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Gets the name of the workspace or git repository from the root package.json.
|
|
14
|
+
* @returns The name of the workspace or repository. If the name is not found, undefined is returned.
|
|
15
|
+
*/
|
|
16
|
+
export async function getRepositoryName(appPath) {
|
|
17
|
+
try {
|
|
18
|
+
const repoRootPath = getGitRoot(appPath) || appPath;
|
|
19
|
+
const rootPackageJsonPath = path.join(repoRootPath, 'package.json');
|
|
20
|
+
const packageJsonContent = (await readJson(rootPackageJsonPath));
|
|
21
|
+
if (!packageJsonContent) {
|
|
22
|
+
console.warn(`Could not read ${rootPackageJsonPath}.`);
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return packageJsonContent.name;
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
console.warn('An error occurred while getting repository name. This is not a critical error. You man continue to work.', e);
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=getRepositoryName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRepositoryName.js","sourceRoot":"","sources":["../../src/utilities/getRepositoryName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;QACpD,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACpE,MAAM,kBAAkB,GAAG,CAAC,MAAM,QAAQ,CAAC,mBAAmB,CAAC,CAAsB,CAAC;QACtF,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,kBAAkB,mBAAmB,GAAG,CAAC,CAAC;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,kBAAkB,CAAC,IAAI,CAAC;IACjC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CACV,0GAA0G,EAC1G,CAAC,CACF,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { findGitRoot } from 'workspace-tools';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\n\nfunction getGitRoot(cwd: string) {\n try {\n return findGitRoot(cwd);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Gets the name of the workspace or git repository from the root package.json.\n * @returns The name of the workspace or repository. If the name is not found, undefined is returned.\n */\nexport async function getRepositoryName(appPath: string) {\n try {\n const repoRootPath = getGitRoot(appPath) || appPath;\n const rootPackageJsonPath = path.join(repoRootPath, 'package.json');\n const packageJsonContent = (await readJson(rootPackageJsonPath)) as { name?: string };\n if (!packageJsonContent) {\n console.warn(`Could not read ${rootPackageJsonPath}.`);\n return undefined;\n }\n\n return packageJsonContent.name;\n } catch (e) {\n console.warn(\n 'An error occurred while getting repository name. This is not a critical error. You man continue to work.',\n e,\n );\n return undefined;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.22",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,16 +10,17 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.29.
|
|
14
|
-
"@ms-cloudpack/bundle-server": "^0.2.
|
|
15
|
-
"@ms-cloudpack/config": "^0.17.
|
|
16
|
-
"@ms-cloudpack/config-types": "^0.4.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.29.14",
|
|
14
|
+
"@ms-cloudpack/bundle-server": "^0.2.7",
|
|
15
|
+
"@ms-cloudpack/config": "^0.17.15",
|
|
16
|
+
"@ms-cloudpack/config-types": "^0.4.1",
|
|
17
|
+
"@ms-cloudpack/feature-flags": "^0.0.2",
|
|
17
18
|
"@ms-cloudpack/json-utilities": "^0.1.3",
|
|
18
|
-
"@ms-cloudpack/package-utilities": "^5.7.
|
|
19
|
+
"@ms-cloudpack/package-utilities": "^5.7.9",
|
|
19
20
|
"@ms-cloudpack/path-string-parsing": "^1.1.3",
|
|
20
|
-
"@ms-cloudpack/remote-cache": "^0.4.
|
|
21
|
-
"@ms-cloudpack/app-server": "^0.1.
|
|
22
|
-
"@ms-cloudpack/task-reporter": "^0.11.
|
|
21
|
+
"@ms-cloudpack/remote-cache": "^0.4.6",
|
|
22
|
+
"@ms-cloudpack/app-server": "^0.1.9",
|
|
23
|
+
"@ms-cloudpack/task-reporter": "^0.11.1",
|
|
23
24
|
"@ms-cloudpack/telemetry": "^0.4.5",
|
|
24
25
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
25
26
|
"commander": "^11.1.0",
|