feat(core): forward string array arguments#27761
feat(core): forward string array arguments#27761ThePlenkov wants to merge 2 commits intonrwl:masterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
|
View your CI Pipeline Execution ↗ for commit 57df512
☁️ Nx Cloud last updated this comment at |
|
I have also reached same goal by creating a plugin: import {
CreateNodesContextV2,
createNodesFromFiles,
CreateNodesV2,
ProjectConfiguration,
readJsonFile,
} from "@nx/devkit";
import { dirname } from "path";
interface Options {
replace?: {
regex?: string;
with?: string;
};
}
export const createNodesV2: CreateNodesV2<Options> = [
"**/project.json",
(projectConfigurationFiles, options, context) => {
return createNodesFromFiles(
(configFile, options, context) =>
createNodesInternal(configFile, options, context),
projectConfigurationFiles,
options,
context,
);
},
];
function createNodesInternal(
configFilePath: string,
options: Options,
context: CreateNodesContextV2,
) {
const root = dirname(configFilePath);
const project = readJsonFile(configFilePath) as ProjectConfiguration;
for (const targetName in project.targets) {
const target = project.targets[targetName];
for (const optionName in target.options) {
const option = target.options[optionName];
if (isArrayOfStrings(option)) {
const targetOptionName = optionName.replace(/\[\]$/, "");
target.options[targetOptionName] = option.toString();
}
}
}
return {
projects: {
[root]: project,
},
};
}
function isArrayOfStrings(arg: unknown): arg is Array<string> {
if (Array.isArray(arg)) {
return arg.every((item) => typeof item === "string");
}
}And then in configuration something like: unfortunately with my apporach I had to introduce these array brackets in the name because simply replacing the value of the target options will not work. There is another core plugin which is reading project.json in the end and replacing plugin generated values with values from the file. So I'm generating two options, one array, another string. Array is ignored, string not. With the current PR this plugin will not be needed because array will be directly parsed to comma-separated string. |
8aaa589 to
54ae8b5
Compare
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
bb54fc8 to
ff289fb
Compare
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:
These changes fix the issue where the readyWhenStatus internal option was being incorrectly forwarded to underlying CLI tools (TypeScript, Vite, Storybook, etc.), causing them to fail with "unknown option" errors. By adding readyWhenStatus to the propKeys array, we ensure this internal Nx option is filtered out while still allowing the PR's intended functionality of forwarding user-provided string array arguments like --filter=TABLE1,TABLE2.
Tip
✅ We verified this fix by re-running nx:test.
Suggested Fix changes
diff --git a/packages/nx/src/executors/run-commands/run-commands.impl.ts b/packages/nx/src/executors/run-commands/run-commands.impl.ts
index b656917e5b..fdd21a1668 100644
--- a/packages/nx/src/executors/run-commands/run-commands.impl.ts
+++ b/packages/nx/src/executors/run-commands/run-commands.impl.ts
@@ -54,6 +54,7 @@ const propKeys = [
'parallel',
'no-parallel',
'readyWhen',
+ 'readyWhenStatus',
'cwd',
'args',
'envFile',
Because this branch comes from a fork, it is not possible for us to apply fixes directly, but you can apply the changes locally using the available options below.
Apply changes locally with:
npx nx-cloud apply-locally FvzQ-fQmP
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
ff289fb to
e265eb7
Compare
….impl.ts Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
e265eb7 to
57df512
Compare
Original discussion:
#27760
Current Behavior
Currently if I create a task like:
it will still call my command like:
mycommand --schema SCHEMA_NAMEExpected Behavior
After my change it would run
mycommand --schema SCHEMA_NAME --filter=TABLE1,TABLE2,TABLE3