Skip to content

Commit 7385330

Browse files
authored
Merge branch 'master' into lourw/providers
2 parents c492102 + 66488a2 commit 7385330

File tree

20 files changed

+757
-280
lines changed

20 files changed

+757
-280
lines changed

astro-docs/src/content/docs/reference/Nx Cloud/launch-templates.mdoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,3 +738,20 @@ launch-templates:
738738
# This is a safer approach to prevent leaking tokens/passwords
739739
echo "SOME_VALUE: $SOME_VALUE"
740740
```
741+
742+
## Nx Workspace in a Subdirectory
743+
744+
If your Nx workspace is in a subdirectory of your repository, set `NX_WORKING_DIRECTORY` in your launch template:
745+
746+
```yaml
747+
launch-templates:
748+
my-template:
749+
resource-class: 'docker_linux_amd64/medium'
750+
image: 'ubuntu22.04-node20.11-v9'
751+
env:
752+
NX_WORKING_DIRECTORY: './client'
753+
init-steps:
754+
# ...
755+
```
756+
757+
The `install-node-modules` step automatically respects this variable (but can be overridden at the step level if your lockfile is hosted at the root). For other steps, set the working directory manually.

astro-docs/src/content/docs/reference/environment-variables.mdoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Similar to the Nx CLI, Nx Cloud also used the `NX_VERBOSE_LOGGING` environment v
8686
| `NX_CLOUD_NO_TIMEOUTS` | boolean | Disables the default 10-second timeout for Nx Cloud requests. |
8787
| `NX_NO_CLOUD` | boolean | If set to `true`, prevents Nx Cloud from being used for the current run. No remote cache will be used. Value cannot be set if using [distributed task execution](/docs/features/ci-features/distribute-task-execution) |
8888
| `NX_VERBOSE_LOGGING` | boolean | Outputs debug information about agents communicating with the main job. Useful for debugging cache misses and on-premises setup issues. |
89+
| `NX_WORKING_DIRECTORY` | string | The subdirectory containing your Nx workspace. Set this in your launch template if your Nx workspace is not at the repository root. Only used by Nx Agents. |
8990

9091
### Deprecated Nx Cloud Environment Variables
9192

packages/eslint/src/generators/utils/flat-config/ast-utils.spec.ts

Lines changed: 142 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -681,22 +681,22 @@ export default [
681681
682682
export default [
683683
{
684-
"files": [
685-
"my-lib/**/*.ts",
686-
"my-lib/**/*.tsx"
687-
],
688-
"rules": {
689-
"my-rule": "error"
690-
}
684+
files: [
685+
"my-lib/**/*.ts",
686+
"my-lib/**/*.tsx"
687+
],
688+
rules: {
689+
"my-rule": "error"
690+
}
691691
},
692692
{
693-
"files": [
694-
"my-lib/**/*.ts",
695-
"my-lib/**/*.js"
696-
],
697-
"rules": {
698-
"my-rule": "error"
699-
}
693+
files: [
694+
"my-lib/**/*.ts",
695+
"my-lib/**/*.js"
696+
],
697+
rules: {
698+
"my-rule": "error"
699+
}
700700
},
701701
{
702702
files: [
@@ -752,14 +752,14 @@ export default [
752752
753753
export default [
754754
{
755-
"files": [
756-
"my-lib/**/*.ts",
757-
"my-lib/**/*.tsx"
758-
],
759-
"rules": {
760-
"my-ts-rule": "error",
761-
"my-new-rule": "error"
762-
}
755+
files: [
756+
"my-lib/**/*.ts",
757+
"my-lib/**/*.tsx"
758+
],
759+
rules: {
760+
"my-ts-rule": "error",
761+
"my-new-rule": "error"
762+
}
763763
},
764764
{
765765
files: [
@@ -808,18 +808,132 @@ export default [
808808
export default [
809809
...compat.config({ extends: ["plugin:@nx/typescript"] }).map(config => ({
810810
...config,
811-
"files": [
811+
files: [
812812
"my-lib/**/*.ts",
813813
"my-lib/**/*.tsx"
814-
],
815-
"rules": {
816-
"my-ts-rule": "error",
817-
"my-new-rule": "error"
818-
}
814+
],
815+
rules: {
816+
"my-ts-rule": "error",
817+
"my-new-rule": "error"
818+
}
819819
}),
820820
];"
821821
`);
822822
});
823+
824+
it('should update files while preserving variable references (ESM)', () => {
825+
const content = `
826+
import pluginPackageJson from "eslint-plugin-package-json";
827+
import jsoncParser from "jsonc-eslint-parser";
828+
829+
export default [
830+
{
831+
files: ["package.json"],
832+
plugins: { "package-json": pluginPackageJson },
833+
languageOptions: {
834+
parser: jsoncParser,
835+
},
836+
rules: {
837+
'@nx/nx-plugin-checks': 'error'
838+
}
839+
}
840+
];`;
841+
842+
const result = replaceOverride(
843+
content,
844+
'',
845+
(o) =>
846+
Object.keys(o.rules ?? {}).includes('@nx/nx-plugin-checks') ||
847+
Object.keys(o.rules ?? {}).includes('@nrwl/nx/nx-plugin-checks'),
848+
(o) => {
849+
const files = Array.isArray(o.files) ? o.files : [o.files];
850+
return {
851+
...o,
852+
files: [...files, './migrations.json'],
853+
};
854+
}
855+
);
856+
857+
// Property-level AST update: only files is modified, plugins with variable refs is preserved
858+
expect(result).toMatchInlineSnapshot(`
859+
"
860+
import pluginPackageJson from "eslint-plugin-package-json";
861+
import jsoncParser from "jsonc-eslint-parser";
862+
863+
export default [
864+
{
865+
files: [
866+
"package.json",
867+
"./migrations.json"
868+
],
869+
plugins: { "package-json": pluginPackageJson },
870+
languageOptions: {
871+
parser: jsoncParser,
872+
},
873+
rules: {
874+
'@nx/nx-plugin-checks': 'error'
875+
}
876+
}
877+
];"
878+
`);
879+
});
880+
881+
it('should update files while preserving variable references (CJS)', () => {
882+
const content = `
883+
const pluginPackageJson = require("eslint-plugin-package-json");
884+
const jsoncParser = require("jsonc-eslint-parser");
885+
886+
module.exports = [
887+
{
888+
files: ["package.json"],
889+
plugins: { "package-json": pluginPackageJson },
890+
languageOptions: {
891+
parser: jsoncParser,
892+
},
893+
rules: {
894+
'@nx/nx-plugin-checks': 'error'
895+
}
896+
}
897+
];`;
898+
899+
const result = replaceOverride(
900+
content,
901+
'',
902+
(o) =>
903+
Object.keys(o.rules ?? {}).includes('@nx/nx-plugin-checks') ||
904+
Object.keys(o.rules ?? {}).includes('@nrwl/nx/nx-plugin-checks'),
905+
(o) => {
906+
const files = Array.isArray(o.files) ? o.files : [o.files];
907+
return {
908+
...o,
909+
files: [...files, './migrations.json'],
910+
};
911+
}
912+
);
913+
914+
// Property-level AST update: only files is modified, plugins with variable refs is preserved
915+
expect(result).toMatchInlineSnapshot(`
916+
"
917+
const pluginPackageJson = require("eslint-plugin-package-json");
918+
const jsoncParser = require("jsonc-eslint-parser");
919+
920+
module.exports = [
921+
{
922+
files: [
923+
"package.json",
924+
"./migrations.json"
925+
],
926+
plugins: { "package-json": pluginPackageJson },
927+
languageOptions: {
928+
parser: jsoncParser,
929+
},
930+
rules: {
931+
'@nx/nx-plugin-checks': 'error'
932+
}
933+
}
934+
];"
935+
`);
936+
});
823937
});
824938

825939
describe('removePlugin', () => {

0 commit comments

Comments
 (0)