chore(repo): add sync generator for e2e configs (#26427)

This commit is contained in:
Jason Jean 2024-06-06 16:51:18 -04:00 committed by GitHub
parent ec5461fa85
commit 7495f0664b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 93 additions and 3 deletions

View File

@ -24,14 +24,14 @@
"nx:build-native", "nx:build-native",
"@nx/nx-source:populate-local-registry-storage" "@nx/nx-source:populate-local-registry-storage"
], ],
"inputs": ["e2eInputs"] "inputs": ["e2eInputs", "^production"]
}, },
"e2e-ci--src/detox.test.ts": { "e2e-ci--src/detox.test.ts": {
"dependsOn": [ "dependsOn": [
"nx:build-native", "nx:build-native",
"@nx/nx-source:populate-local-registry-storage" "@nx/nx-source:populate-local-registry-storage"
], ],
"inputs": ["e2eInputs"] "inputs": ["e2eInputs", "^production"]
} }
} }
} }

View File

@ -10,6 +10,20 @@
}, },
"e2e-macos-ci--src/expo-legacy.test.ts": { "e2e-macos-ci--src/expo-legacy.test.ts": {
"inputs": ["e2eInputs", "^production"] "inputs": ["e2eInputs", "^production"]
},
"e2e-ci--src/expo-legacy.test.ts": {
"dependsOn": [
"nx:build-native",
"@nx/nx-source:populate-local-registry-storage"
],
"inputs": ["e2eInputs", "^production"]
},
"e2e-ci--src/expo.test.ts": {
"dependsOn": [
"nx:build-native",
"@nx/nx-source:populate-local-registry-storage"
],
"inputs": ["e2eInputs", "^production"]
} }
} }
} }

View File

@ -10,6 +10,20 @@
}, },
"e2e-macos-ci--src/react-native.test.ts": { "e2e-macos-ci--src/react-native.test.ts": {
"inputs": ["e2eInputs", "^production"] "inputs": ["e2eInputs", "^production"]
},
"e2e-ci--src/react-native-legacy.test.ts": {
"dependsOn": [
"nx:build-native",
"@nx/nx-source:populate-local-registry-storage"
],
"inputs": ["e2eInputs", "^production"]
},
"e2e-ci--src/react-native.test.ts": {
"dependsOn": [
"nx:build-native",
"@nx/nx-source:populate-local-registry-storage"
],
"inputs": ["e2eInputs", "^production"]
} }
} }
} }

View File

@ -53,6 +53,13 @@
"@nx/nx-source:populate-local-registry-storage" "@nx/nx-source:populate-local-registry-storage"
], ],
"inputs": ["e2eInputs", "^production"] "inputs": ["e2eInputs", "^production"]
},
"e2e-ci--src/react-package-legacy.test.ts": {
"dependsOn": [
"nx:build-native",
"@nx/nx-source:populate-local-registry-storage"
],
"inputs": ["e2eInputs", "^production"]
} }
} }
} }

View File

@ -4,7 +4,6 @@
"sourceRoot": "e2e/remix", "sourceRoot": "e2e/remix",
"projectType": "application", "projectType": "application",
"implicitDependencies": ["remix"], "implicitDependencies": ["remix"],
"// targets": "to see all targets run: nx show project e2e-remix --web",
"targets": { "targets": {
"e2e-ci--src/nx-remix.test.ts": { "e2e-ci--src/nx-remix.test.ts": {
"dependsOn": [ "dependsOn": [

View File

@ -11,6 +11,13 @@
"@nx/nx-source:populate-local-registry-storage" "@nx/nx-source:populate-local-registry-storage"
], ],
"inputs": ["e2eInputs", "^production"] "inputs": ["e2eInputs", "^production"]
},
"e2e-ci--src/rollup-legacy.test.ts": {
"dependsOn": [
"nx:build-native",
"@nx/nx-source:populate-local-registry-storage"
],
"inputs": ["e2eInputs", "^production"]
} }
} }
} }

View File

@ -9,6 +9,11 @@
"factory": "./src/generators/create-nodes-plugin/generator", "factory": "./src/generators/create-nodes-plugin/generator",
"schema": "./src/generators/create-nodes-plugin/schema.json", "schema": "./src/generators/create-nodes-plugin/schema.json",
"description": "Workspace Generator to create a create-nodes-plugin" "description": "Workspace Generator to create a create-nodes-plugin"
},
"sync-e2e-configs": {
"factory": "./src/generators/sync-e2e-config/generator",
"schema": "./src/generators/sync-e2e-config/schema.json",
"description": "Generator to sync configuration for our e2e targets"
} }
} }
} }

View File

@ -0,0 +1,35 @@
import {
formatFiles,
getProjects,
globAsync,
Tree,
updateProjectConfiguration,
} from '@nx/devkit';
import { relative } from 'node:path';
import { join } from 'path';
export async function syncE2eConfigsGenerator(tree: Tree) {
for (const [projName, projectConfig] of getProjects(tree)) {
const { root, targets } = projectConfig;
if (!root.startsWith('e2e/')) {
continue;
}
const testFiles = await globAsync(tree, [join(root, `**/*.test.ts`)]);
for (const testFile of testFiles) {
const relativePath = relative(root, testFile);
let target = (targets[`e2e-ci--${relativePath}`] ??= {});
target.dependsOn = [
'nx:build-native',
'@nx/nx-source:populate-local-registry-storage',
];
target.inputs = ['e2eInputs', '^production'];
}
updateProjectConfiguration(tree, projName, projectConfig);
}
await formatFiles(tree);
}
export default syncE2eConfigsGenerator;

View File

@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/schema",
"$id": "SyncE2eConfigs",
"title": "",
"description": "Generator to sync configuration for our e2e targets.",
"type": "object",
"properties": {},
"required": []
}