chore: replace optional-dev-dependencies with iodd (#836)

This commit is contained in:
Robert Kieffer
2024-11-04 10:52:05 -10:00
committed by GitHub
parent 809c6d188a
commit 4dec60c06e
11 changed files with 838 additions and 764 deletions
-2
View File
@@ -46,7 +46,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
@@ -128,7 +127,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
-2
View File
@@ -43,7 +43,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
@@ -81,7 +80,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
-2
View File
@@ -48,7 +48,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
@@ -1122,7 +1121,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
-2
View File
@@ -47,7 +47,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
@@ -2288,7 +2287,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
-2
View File
@@ -43,7 +43,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
@@ -81,7 +80,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
-2
View File
@@ -43,7 +43,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
@@ -81,7 +80,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
-2
View File
@@ -47,7 +47,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
@@ -7129,7 +7128,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
-2
View File
@@ -47,7 +47,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
@@ -2179,7 +2178,6 @@
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
+781 -746
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -57,6 +57,7 @@
"@eslint/js": "9.13.0",
"@types/eslint__js": "8.42.3",
"bundlewatch": "0.4.0",
"commander": "12.1.0",
"eslint": "9.13.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
@@ -66,7 +67,6 @@
"lint-staged": "15.2.10",
"neostandard": "0.11.7",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "3.3.3",
"release-please": "16.14.3",
"runmd": "1.3.9",
@@ -100,7 +100,7 @@
"prepack": "npm run build",
"prepare": "husky",
"pretest:benchmark": "npm run build",
"pretest:browser": "optional-dev-dependency && npm run build && npm-run-all --parallel examples:browser:**",
"pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
"pretest:node": "npm run build",
"pretest": "npm run build",
"prettier:check": "prettier --check .",
Executable
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env node
import { program } from 'commander';
import { spawn } from 'node:child_process';
import fs from 'node:fs/promises';
import path from 'node:path';
program
.name('iodd')
.description(
'(I)nstall (o)ptional (d)ev (d)ependencies from package.json#optionalDevDependencies'
)
.option('-v, --verbose', 'Output npm install output to stdout/stderr')
.option('-r, --required', 'Exit with non-zero code if dependencies fail to install')
.argument('[packagePath]', 'Path to package.json file', './package.json')
.action(main);
async function main(packagePath, options) {
// Get list of optional dependencies from package.json
const json = await fs.readFile(path.join(process.cwd(), packagePath));
const packageJson = JSON.parse(json);
const { optionalDevDependencies: deps } = packageJson;
if (!deps) {
console.error(`No optional dependencies found in ${packagePath}`);
process.exit(1);
}
const packageRefs = Object.entries(deps).map(([name, version]) => `${name}@${version}`);
// Install optional dependencies with child_process running npm
const args = ['install', '--no-save', ...packageRefs];
console.log('Running: ', 'npm', args.join(' '));
const cp = spawn('npm', args);
if (options.verbose) {
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);
}
const exitCode = await new Promise((resolve) => {
cp.on('close', resolve);
});
if (exitCode !== 0) {
console.error('Dependencies failed to install');
if (options.required) {
process.exit(exitCode);
}
}
}
program.parseAsync();