diff --git a/.pnp.js b/.pnp.js index c2e5ac692ce0..9a64c9b4c96b 100755 --- a/.pnp.js +++ b/.pnp.js @@ -7858,7 +7858,7 @@ function $$SETUP_STATE(hydrateRuntimeState) { ], [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ], [ "brfs", @@ -7999,7 +7999,7 @@ function $$SETUP_STATE(hydrateRuntimeState) { ], [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ], [ "chalk", @@ -8060,7 +8060,7 @@ function $$SETUP_STATE(hydrateRuntimeState) { ], [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ], [ "chalk", @@ -8576,7 +8576,7 @@ function $$SETUP_STATE(hydrateRuntimeState) { ], [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ], [ "execa", @@ -8696,7 +8696,7 @@ function $$SETUP_STATE(hydrateRuntimeState) { ], [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ], [ "dateformat", @@ -8761,7 +8761,7 @@ function $$SETUP_STATE(hydrateRuntimeState) { ], [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ] ] } @@ -8848,7 +8848,7 @@ function $$SETUP_STATE(hydrateRuntimeState) { ], [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ] ] } @@ -8918,7 +8918,7 @@ function $$SETUP_STATE(hydrateRuntimeState) { ], [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ] ] } @@ -11333,13 +11333,13 @@ function $$SETUP_STATE(hydrateRuntimeState) { "@manaflair/concierge", [ [ - "npm:0.12.1", + "npm:0.12.3", { - "packageLocation": "./.yarn/cache/@manaflair-concierge-npm-0.12.1-987f3547dd3a12d10a8127c69f5759341ce33e9d9ff0d772b8b79fdec63e838b.zip/node_modules/@manaflair/concierge/", + "packageLocation": "./.yarn/cache/@manaflair-concierge-npm-0.12.3-e4e3704a6ac56bf1620563541973a1af5d8cd5108f3cd4cfdc2d994baa9745a7.zip/node_modules/@manaflair/concierge/", "packageDependencies": [ [ "@manaflair/concierge", - "npm:0.12.1" + "npm:0.12.3" ], [ "chalk", diff --git a/.yarn/cache/@manaflair-concierge-npm-0.12.1-987f3547dd3a12d10a8127c69f5759341ce33e9d9ff0d772b8b79fdec63e838b.zip b/.yarn/cache/@manaflair-concierge-npm-0.12.3-e4e3704a6ac56bf1620563541973a1af5d8cd5108f3cd4cfdc2d994baa9745a7.zip similarity index 78% rename from .yarn/cache/@manaflair-concierge-npm-0.12.1-987f3547dd3a12d10a8127c69f5759341ce33e9d9ff0d772b8b79fdec63e838b.zip rename to .yarn/cache/@manaflair-concierge-npm-0.12.3-e4e3704a6ac56bf1620563541973a1af5d8cd5108f3cd4cfdc2d994baa9745a7.zip index dde5a2fc51be..988b8d976737 100644 Binary files a/.yarn/cache/@manaflair-concierge-npm-0.12.1-987f3547dd3a12d10a8127c69f5759341ce33e9d9ff0d772b8b79fdec63e838b.zip and b/.yarn/cache/@manaflair-concierge-npm-0.12.3-e4e3704a6ac56bf1620563541973a1af5d8cd5108f3cd4cfdc2d994baa9745a7.zip differ diff --git a/packages/berry-builder/package.json b/packages/berry-builder/package.json index f574016932ee..30f6cdaa5f08 100644 --- a/packages/berry-builder/package.json +++ b/packages/berry-builder/package.json @@ -13,7 +13,7 @@ "@babel/preset-typescript": "^7.1.0", "@babel/register": "^7.0.0", "@berry/cli": "workspace:*", - "@manaflair/concierge": "^0.12.1", + "@manaflair/concierge": "^0.12.3", "brfs": "^2.0.1", "buffer-loader": "^0.1.0", "joi": "^13.6.0", diff --git a/packages/berry-cli/package.json b/packages/berry-cli/package.json index 71e486211248..6995d0cdd592 100644 --- a/packages/berry-cli/package.json +++ b/packages/berry-cli/package.json @@ -10,7 +10,7 @@ "@berry/fslib": "workspace:*", "@berry/parsers": "workspace:*", "@berry/shell": "workspace:*", - "@manaflair/concierge": "^0.12.1", + "@manaflair/concierge": "^0.12.3", "chalk": "^2.4.1", "execa": "^1.0.0", "joi": "^13.6.0", diff --git a/packages/berry-core/package.json b/packages/berry-core/package.json index 7b5ea144695a..8b834c39083f 100644 --- a/packages/berry-core/package.json +++ b/packages/berry-core/package.json @@ -9,7 +9,7 @@ "@berry/parsers": "workspace:*", "@berry/pnp": "workspace:*", "@berry/shell": "workspace:*", - "@manaflair/concierge": "^0.12.1", + "@manaflair/concierge": "^0.12.3", "chalk": "^2.4.1", "execa": "^1.0.0", "globby": "^8.0.1", diff --git a/packages/berry-core/sources/scriptUtils.ts b/packages/berry-core/sources/scriptUtils.ts index 77b8f60d2d28..e79b15a7c8f9 100644 --- a/packages/berry-core/sources/scriptUtils.ts +++ b/packages/berry-core/sources/scriptUtils.ts @@ -26,12 +26,13 @@ export async function makeScriptEnv(project: Project) { const binFolder = scriptEnv.BERRY_BIN_FOLDER = dirSync().name; // Register some binaries that must be made available in all subprocesses - // spawned by Berry + // spawned by Yarn - await makePathWrapper(binFolder, `run`, process.execPath, [process.argv[1], `run`]), - await makePathWrapper(binFolder, `yarn`, process.execPath, [process.argv[1]]), - await makePathWrapper(binFolder, `yarnpkg`, process.execPath, [process.argv[1]]), - await makePathWrapper(binFolder, `node`, process.execPath), + await makePathWrapper(binFolder, `run`, process.execPath, [process.argv[1], `run`]); + await makePathWrapper(binFolder, `yarn`, process.execPath, [process.argv[1]]); + await makePathWrapper(binFolder, `yarnpkg`, process.execPath, [process.argv[1]]); + await makePathWrapper(binFolder, `node`, process.execPath); + await makePathWrapper(binFolder, `node-gyp`, process.execPath, [process.argv[1], `run`, `--top-level`, `node-gyp`]); scriptEnv.PATH = scriptEnv.PATH ? `${binFolder}${delimiter}${scriptEnv.PATH}` diff --git a/packages/plugin-essentials/package.json b/packages/plugin-essentials/package.json index 98f6cc00bf19..bb43d706dca6 100644 --- a/packages/plugin-essentials/package.json +++ b/packages/plugin-essentials/package.json @@ -8,7 +8,7 @@ "@berry/fslib": "workspace:*", "@berry/json-proxy": "workspace:*", "@berry/parsers": "workspace:*", - "@manaflair/concierge": "^0.12.1", + "@manaflair/concierge": "^0.12.3", "execa": "^1.0.0", "inquirer": "^6.2.0", "joi": "^13.6.0", diff --git a/packages/plugin-essentials/sources/commands/run.ts b/packages/plugin-essentials/sources/commands/run.ts index 626196cd14ac..85c8f7bfb9e4 100644 --- a/packages/plugin-essentials/sources/commands/run.ts +++ b/packages/plugin-essentials/sources/commands/run.ts @@ -1,12 +1,12 @@ -import {Configuration, PluginConfiguration, Project, Workspace, Manifest, Cache} from '@berry/core'; -import {LightReport, ThrowReport} from '@berry/core'; -import {scriptUtils} from '@berry/core'; -import {UsageError} from '@manaflair/concierge'; -import {Readable, Writable} from 'stream'; +import {Configuration, PluginConfiguration, Project, Workspace, Cache} from '@berry/core'; +import {LightReport} from '@berry/core'; +import {scriptUtils, structUtils} from '@berry/core'; +import {UsageError} from '@manaflair/concierge'; +import {Readable, Writable} from 'stream'; export default (concierge: any, pluginConfiguration: PluginConfiguration) => concierge - .command(`run [... args]`) + .command(`run [... args] [-T,--top-level]`) .describe(`run a script defined in the package.json`) .flags({proxyArguments: true}) @@ -22,7 +22,7 @@ export default (concierge: any, pluginConfiguration: PluginConfiguration) => con Whatever happens, the cwd of the spawned process will be the workspace that declares the script (which makes it possible to call commands cross-workspaces using the third syntax). `) - .action(async ({cwd, stdin, stdout, stderr, name, args}: {cwd: string, stdin: Readable, stdout: Writable, stderr: Writable, name: string, args: Array}) => { + .action(async ({cwd, stdin, stdout, stderr, name, topLevel, args}: {cwd: string, stdin: Readable, stdout: Writable, stderr: Writable, name: string, topLevel: boolean, args: Array}) => { const configuration = await Configuration.find(cwd, pluginConfiguration); const {project, workspace, locator} = await Project.find(configuration, cwd); const cache = await Cache.find(configuration); @@ -31,23 +31,27 @@ export default (concierge: any, pluginConfiguration: PluginConfiguration) => con await project.resolveEverything({lockfileOnly: true, cache, report}); }); + const effectiveLocator = topLevel + ? project.topLevelWorkspace.anchoredLocator + : locator; + if (report.hasErrors()) return report.exitCode(); - // First we check to see whether a script exist inside the current workspace + // First we check to see whether a script exist inside the current package // for the given name - if (await scriptUtils.hasPackageScript(locator, name, {project})) - return await scriptUtils.executePackageScript(locator, name, args, {project, stdin, stdout, stderr}); + if (await scriptUtils.hasPackageScript(effectiveLocator, name, {project})) + return await scriptUtils.executePackageScript(effectiveLocator, name, args, {project, stdin, stdout, stderr}); // If we can't find it, we then check whether one of the dependencies of the - // current workspace exports a binary with the requested name + // current package exports a binary with the requested name - const binaries = await scriptUtils.getPackageAccessibleBinaries(locator, {project}); + const binaries = await scriptUtils.getPackageAccessibleBinaries(effectiveLocator, {project}); const binary = binaries.get(name); if (binary) - return await scriptUtils.executePackageAccessibleBinary(locator, name, args, {cwd, project, stdin, stdout, stderr}); + return await scriptUtils.executePackageAccessibleBinary(effectiveLocator, name, args, {cwd, project, stdin, stdout, stderr}); // When it fails, we try to check whether it's a global script (ie we look // into all the workspaces to find one that exports this script). We only do @@ -57,7 +61,7 @@ export default (concierge: any, pluginConfiguration: PluginConfiguration) => con // We also disable this logic for packages coming from third-parties (ie // not workspaces). Not particular reason except maybe security concerns. - if (workspace && name.includes(`:`)) { + if (!topLevel && workspace && name.includes(`:`)) { let candidateWorkspaces = await Promise.all(project.workspaces.map(async workspace => { return workspace.manifest.scripts.has(name) ? workspace : null; })); @@ -71,5 +75,13 @@ export default (concierge: any, pluginConfiguration: PluginConfiguration) => con } } - throw new UsageError(`Couldn't find a script named "${name}"`); + if (topLevel) { + if (name === `node-gyp`) { + throw new UsageError(`Couldn't find a script name "${name}" in the top-level (used by ${structUtils.prettyLocator(configuration, locator)}). This typically happens because some package depends on "node-gyp" to build itself, but didn't list it in their dependencies. To fix that, please run "yarn add node-gyp" into your top-level workspace. You also can open an issue on the repository of the specified package to suggest them to use an optional peer dependency.`); + } else { + throw new UsageError(`Couldn't find a script name "${name}" in the top-level (used by ${structUtils.prettyLocator(configuration, locator)}).`); + } + } else { + throw new UsageError(`Couldn't find a script named "${name}".`); + } }); diff --git a/packages/plugin-hub/package.json b/packages/plugin-hub/package.json index a0d6a6502baa..78dfcdd47e43 100644 --- a/packages/plugin-hub/package.json +++ b/packages/plugin-hub/package.json @@ -6,7 +6,7 @@ "@berry/core": "workspace:*", "@berry/json-proxy": "workspace:*", "@berry/ui": "workspace:*", - "@manaflair/concierge": "^0.12.1", + "@manaflair/concierge": "^0.12.3", "dateformat": "^3.0.3", "immer": "^1.7.2", "joi": "^13.6.0", diff --git a/packages/plugin-init/package.json b/packages/plugin-init/package.json index 3781fb6dd57c..e27f04f60045 100644 --- a/packages/plugin-init/package.json +++ b/packages/plugin-init/package.json @@ -6,6 +6,6 @@ "@berry/core": "workspace:*", "@berry/fslib": "workspace:*", "@berry/json-proxy": "workspace:*", - "@manaflair/concierge": "^0.12.1" + "@manaflair/concierge": "^0.12.3" } } diff --git a/packages/plugin-pack/package.json b/packages/plugin-pack/package.json index 2ca5488f083a..53307ffc7649 100644 --- a/packages/plugin-pack/package.json +++ b/packages/plugin-pack/package.json @@ -6,7 +6,7 @@ "@berry/core": "workspace:*", "@berry/fslib": "workspace:*", "@berry/json-proxy": "workspace:*", - "@manaflair/concierge": "^0.12.1" + "@manaflair/concierge": "^0.12.3" }, "devDependencies": { "@berry/builder": "workspace:packages/berry-builder" diff --git a/packages/plugin-stage/package.json b/packages/plugin-stage/package.json index 609332138eb2..6b1913ce830c 100644 --- a/packages/plugin-stage/package.json +++ b/packages/plugin-stage/package.json @@ -6,7 +6,7 @@ "@berry/builder": "workspace:*", "@berry/core": "workspace:*", "@berry/fslib": "workspace:*", - "@manaflair/concierge": "^0.12.1" + "@manaflair/concierge": "^0.12.3" }, "scripts": { "build:plugin-stage": "run @berry-build-plugin" diff --git a/yarn.lock b/yarn.lock index 1824628b1b5b..428a509bf450 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1246,7 +1246,7 @@ __metadata: "@babel/preset-typescript": "npm:^7.1.0" "@babel/register": "npm:^7.0.0" "@berry/cli": "workspace:*" - "@manaflair/concierge": "npm:^0.12.1" + "@manaflair/concierge": "npm:^0.12.3" brfs: "npm:^2.0.1" buffer-loader: "npm:^0.1.0" joi: "npm:^13.6.0" @@ -1284,7 +1284,7 @@ __metadata: "@berry/plugin-typescript": "workspace:*" "@berry/pnp": "workspace:*" "@berry/shell": "workspace:*" - "@manaflair/concierge": "npm:^0.12.1" + "@manaflair/concierge": "npm:^0.12.3" chalk: "npm:^2.4.1" execa: "npm:^1.0.0" joi: "npm:^13.6.0" @@ -1302,7 +1302,7 @@ __metadata: "@berry/parsers": "workspace:*" "@berry/pnp": "workspace:*" "@berry/shell": "workspace:*" - "@manaflair/concierge": "npm:^0.12.1" + "@manaflair/concierge": "npm:^0.12.3" chalk: "npm:^2.4.1" execa: "npm:^1.0.0" globby: "npm:^8.0.1" @@ -1458,7 +1458,7 @@ __metadata: "@berry/fslib": "workspace:*" "@berry/json-proxy": "workspace:*" "@berry/parsers": "workspace:*" - "@manaflair/concierge": "npm:^0.12.1" + "@manaflair/concierge": "npm:^0.12.3" execa: "npm:^1.0.0" inquirer: "npm:^6.2.0" joi: "npm:^13.6.0" @@ -1499,7 +1499,7 @@ __metadata: "@berry/core": "workspace:*" "@berry/json-proxy": "workspace:*" "@berry/ui": "workspace:*" - "@manaflair/concierge": "npm:^0.12.1" + "@manaflair/concierge": "npm:^0.12.3" dateformat: "npm:^3.0.3" immer: "npm:^1.7.2" joi: "npm:^13.6.0" @@ -1518,7 +1518,7 @@ __metadata: "@berry/core": "workspace:*" "@berry/fslib": "workspace:*" "@berry/json-proxy": "workspace:*" - "@manaflair/concierge": "npm:^0.12.1" + "@manaflair/concierge": "npm:^0.12.3" languageName: unknown linkType: soft @@ -1548,7 +1548,7 @@ __metadata: "@berry/core": "workspace:*" "@berry/fslib": "workspace:*" "@berry/json-proxy": "workspace:*" - "@manaflair/concierge": "npm:^0.12.1" + "@manaflair/concierge": "npm:^0.12.3" languageName: unknown linkType: soft @@ -1571,7 +1571,7 @@ __metadata: "@berry/builder": "workspace:*" "@berry/core": "workspace:*" "@berry/fslib": "workspace:*" - "@manaflair/concierge": "npm:^0.12.1" + "@manaflair/concierge": "npm:^0.12.3" languageName: unknown linkType: soft @@ -2173,13 +2173,13 @@ __metadata: languageName: node linkType: hard -"@manaflair/concierge@npm:^0.12.1": - version: 0.12.1 - resolution: "@manaflair/concierge@npm:0.12.1" +"@manaflair/concierge@npm:^0.12.3": + version: 0.12.3 + resolution: "@manaflair/concierge@npm:0.12.3" dependencies: chalk: "npm:^1.1.3" lodash: "npm:^4.17.4" - checksum: 163178b7d5d77643734d365c52e9868025dd4220f737f41c92dc304c27f4a430501a13ac6f4d5aea447cbe9e16888bf87668f16da44c5afba777319778ff71a1 + checksum: de63d1eda831e577a3c942df56a729440d2d21c29bd8f6a50d432a5013b0622f100e8af17edce621a7af73cb70298d3d5278e7e5dce950d19c713007bd5b746c languageName: node linkType: hard