in components/base/packages/serverless-solution-commands/lib/serverless-solution-commands.js [106:184]
async assemble() {
const assemblyInfo = getAssemblyInfo(this.slsPlugin);
const pluginRegistry = assemblyInfo.getPluginRegistry();
const pluginRegistryUtil = new PluginRegistryUtil(pluginRegistry);
const assemblyTaskFns = await pluginRegistryUtil.visitPluginsAsync(
'assemble',
'getTasks',
{ payload: [] },
assemblyInfo,
this.slsPlugin,
pluginRegistry,
);
// If this flag is specified, skip the installation task.
// This is useful only when the solution is already assembled and you are making component assembly changes
// that you need to test without installing (e.g. no new packages, no package.json changes).
const shouldSkipInstall = this.slsPlugin.options.install === false;
const shouldUpdatePackageLock = this.slsPlugin.options['update-package-lock'] === true;
if (shouldSkipInstall && shouldUpdatePackageLock) {
this.slsPlugin.cli.error(
'The no installation flag and update package lock flags should not be simultaneously enabled',
);
return;
}
if (shouldSkipInstall) {
this.slsPlugin.cli.warn('The no installation flag was specified. Installation of dependencies will be skipped');
}
if (shouldUpdatePackageLock) {
this.slsPlugin.cli.warn(
'The update package lock flag was specified. This means the "frozen lockfile" functionality of "pnpm install" will NOT be used while installing dependencies.',
);
}
// eslint-disable-next-line no-restricted-syntax
for (const assemblyTaskFn of assemblyTaskFns) {
// eslint-disable-next-line no-await-in-loop
await assemblyTaskFn();
}
if (shouldSkipInstall) {
return;
}
try {
// Re-install all pnpm modules after assembly, since the assembly process may
// may have contributed new packages to the pnpm workspace.
await this.install(shouldUpdatePackageLock);
} catch (err) {
if (!(err instanceof ChildProcessError)) {
// Unexpected error occurred, so re-throw
throw err;
}
const errorMessageSubstringsToCatch = [
// pnpm-lock.yaml missing
'installation requires a pnpm-lock.yaml file',
// pnpm-lock.yaml requires updating
'pnpm-lock.yaml is not up-to-date with',
];
/* eslint-disable no-restricted-syntax */
for (const errorMessage of err.errorMessages) {
for (const errorMessageSubstringToCatch of errorMessageSubstringsToCatch) {
/* eslint-enable no-restricted-syntax */
if (errorMessage.includes(errorMessageSubstringToCatch)) {
this.slsPlugin.cli.error(
'Could not install all packages in the pnpm workspace without modifying the current "pnpm-lock.yaml" file. This error usually occurs if you:' +
'\n(a) Install or remove a component that contains one or more "package.json" files in the "assembly/assets/deployables/*" directories of its assembly package; or' +
'\n(b) Manually add or remove packages (by directly editing "package.json" files, instead of using pnpm add/remove) inside a "package.json" file in the "assembly/assets/deployables/*" directories of a component\'s assembly package.' +
'\n\nTo update the pnpm-lock.yaml and bypass this error, re-run this command with the "--update-package-lock" flag.',
);
return;
}
}
}
// Unexpected error occurred, so re-throw
throw err;
}
}