Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions change/change-a1057346-1fa6-441e-b15a-c3a9963c7e7f.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"changes": [
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/cache-github-actions",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/cache",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/cli",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/config",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/format-hrtime",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/hasher",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/logger",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/reporters",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/rpc",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/runners",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/scheduler-types",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/scheduler",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/target-graph",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Update scripts",
"packageName": "@lage-run/worker-threads-pool",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
}
]
}
4 changes: 2 additions & 2 deletions lage.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fastGlob = require("fast-glob");
const config = {
pipeline: {
"lage#bundle": ["^^transpile", "types"],
// Note that transpile/types/bundle are overridden later for the @lage-run/globby package
// Note that transpile/types are overridden later for the @lage-run/globby package
types: {
type: "worker",
options: {
Expand All @@ -37,7 +37,7 @@ const config = {
test: {
type: "worker",
weight: (target) => {
return fastGlob.sync("tests/**/*.test.ts", { cwd: target.cwd }).length;
return fastGlob.sync("src/__tests__/**/*.test.ts", { cwd: target.cwd }).length;
},
options: {
worker: path.join(__dirname, "scripts/worker/jest.js"),
Expand Down
2 changes: 1 addition & 1 deletion packages/cache-github-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"types": "yarn run -T tsc",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/format-hrtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/hasher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/monorepo-fixture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"types": "yarn run -T tsc",
"lint": "monorepo-scripts lint"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/reporters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"types": "yarn run -T tsc",
"lint": "buf lint",
"generate": "buf generate"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/runners/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/scheduler-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"types": "yarn run -T tsc",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/target-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/worker-threads-pool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"scripts": {
"build": "yarn types && yarn transpile",
"transpile": "monorepo-scripts transpile",
"types": "monorepo-scripts tsc",
"test": "monorepo-scripts jest",
"types": "yarn run -T tsc",
"test": "yarn run -T jest",
"lint": "monorepo-scripts lint"
},
"dependencies": {
Expand Down
58 changes: 7 additions & 51 deletions scripts/bin/monorepo-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,18 @@
const { spawn } = require("child_process");
const path = require("path");
const fs = require("fs");
const { findPackageRoot, findProjectRoot } = require("workspace-tools");

const projectRoot = findProjectRoot(process.cwd());

const [command, ...spawnArgs] = process.argv.slice(2);
const spawnCommand = findCommand(command);

let cp;
if (spawnCommand.endsWith(".js")) {
console.log(`Running ${command} as: node ${spawnCommand} ${spawnArgs.join(" ")}`);
cp = spawn(process.execPath, [spawnCommand, ...spawnArgs], {
const commandPath = path.resolve(__dirname, `../commands/${command}.js`);
if (fs.existsSync(commandPath)) {
const cp = spawn(process.execPath, [commandPath, ...spawnArgs], {
stdio: "inherit",
});
} else {
console.log(`Running ${command} as: ${spawnCommand} ${spawnArgs.join(" ")}`);
cp = spawn(spawnCommand, spawnArgs, {
stdio: "inherit",
shell: true,
cp.on("exit", (code) => {
process.exitCode = code || 0;
});
}

cp.on("exit", (code) => {
process.exitCode = code || 0;
});

function findCommand(/** @type {string} */ command) {
// Try to find a command under monorepo-scripts/commands
const commandPath = path.resolve(__dirname, "../commands", `${command}.js`);
if (fs.existsSync(commandPath)) {
return commandPath;
}

// Try to find command in package's own node_modules, then scripts/node_modules, then root node_modules
for (const basePath of [findPackageRoot(process.cwd()), findPackageRoot(__dirname), projectRoot]) {
if (basePath) {
const binPath = getBinPath(basePath, command);
if (binPath) {
return binPath;
}
}
}

console.error("Could not find command: " + command);
} else {
console.error(`Command not found (under scripts/commands): ${command}`);
process.exit(1);
}

function getBinPath(/** @type {string | undefined} */ packagePath, /** @type {string | undefined} */ command) {
if (!packagePath || !command) {
return undefined;
}

const binPath = path.join(packagePath, "node_modules/.bin", process.platform === "win32" ? `${command}.cmd` : command);

if (fs.existsSync(binPath)) {
return binPath;
}

return undefined;
}
2 changes: 1 addition & 1 deletion scripts/commands/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const lintWorker = require("../worker/lint");
}

return lintWorker({
target: { packageName: packageInfo.name, cwd: path.dirname(packageInfo.packageJsonPath), task: "lint" },
target: { packageName: packageInfo.name, cwd: path.dirname(packageInfo.packageJsonPath) },
taskArgs: process.argv.slice(2),
});
})().catch((error) => {
Expand Down
2 changes: 2 additions & 0 deletions scripts/commands/transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const { getPackageInfo } = require("workspace-tools");

await transpileWorker({
target: { packageName: packageJson.name, cwd: packageRoot },
// no CLI args are respected for the swc wrapper
taskArgs: [],
});
})().catch((error) => {
process.exitCode = 1;
Expand Down
1 change: 1 addition & 0 deletions scripts/config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ moduleNameMapper["^(\\.{1,2}/.*)\\.js$"] = "$1";
/** @type {import("jest").Config} */
const config = {
clearMocks: true,
passWithNoTests: true,
extensionsToTreatAsEsm: [".ts"],
testMatch: ["**/?(*.)+(spec|test).ts?(x)"],
testPathIgnorePatterns: ["/node_modules/"],
Expand Down
6 changes: 1 addition & 5 deletions scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
"emitDeclarationOnly": false,
"noEmit": true,
"paths": {
// Special path mappings to avoid relative references in individual files
"@/TargetGraph": ["../packages/target-graph/src/index.ts"],
"@/TargetRunner": ["../packages/runners/src/types/TargetRunner.ts"],
"@/WorkerRunner": ["../packages/runners/src/WorkerRunner.ts"],
// Required for above types to resolve @lage-run/target-graph if not built yet
// Required for resolution of @lage-run/target-graph by references in types.ts if not built yet
"@lage-run/target-graph": ["../packages/target-graph/src/index.ts"]
}
},
Expand Down
Loading