Skip to content

chore: support cross env scripts for develop #2710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2024
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
29 changes: 13 additions & 16 deletions common/autoinstallers/lint/change-all.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import chalk from 'chalk';
import minimist, { ParsedArgs } from 'minimist';
import { spawnSync, execSync } from 'child_process';
import { execSync } from 'child_process';

interface RunScriptArgv extends ParsedArgs {
message?: string;
Expand Down Expand Up @@ -31,12 +31,12 @@ function run() {
);
message = lastCommitMessage;
} else {
const result = spawnSync('sh', ['-c', `echo ${message} | ${commitLintBinPath} --config ${commitLineConfigPath}`], {
stdio: 'inherit'
});

if (result.status !== 0) {
process.exit(1);
try {
execSync(`echo ${message} | ${commitLintBinPath} --config ${commitLineConfigPath}`, {
stdio: 'inherit'
});
} catch (e) {
console.error(`encountered error: ${e}`);
}
}

Expand All @@ -47,20 +47,17 @@ function run() {
bumpType = 'patch';
}

spawnSync('sh', ['-c', `rush change --bulk --bump-type '${bumpType}' --message '${message}'`], {
stdio: 'inherit',
shell: false
execSync(`rush change --bulk --bump-type '${bumpType}' --message '${message}'`, {
stdio: 'inherit'
});

if (!notCommit) {
spawnSync('sh', ['-c', 'git add --all'], {
stdio: 'inherit',
shell: false
execSync('git add --all', {
stdio: 'inherit'
});

spawnSync('sh', ['-c', `git commit -m 'docs: update changlog of rush'`], {
stdio: 'inherit',
shell: false
execSync(`git commit -m 'docs: update changlog of rush'`, {
stdio: 'inherit'
});
}
}
Expand Down
29 changes: 14 additions & 15 deletions common/autoinstallers/lint/commit-lint.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
const path = require("path");
const fs = require("fs");
const child_process = require("child_process");
const path = require('path');
const fs = require('fs');
const child_process = require('child_process');

const gitPath = path.resolve(__dirname, "../../../.git");
const configPath = path.resolve(__dirname, "./commitlint.config.js");
const commitlintBinPath = path.resolve(__dirname, "./node_modules/.bin/commitlint");
const gitPath = path.resolve(__dirname, '../../../.git');
const configPath = path.resolve(__dirname, './commitlint.config.js');
const commitlintBinPath = path.resolve(__dirname, './node_modules/.bin/commitlint');

if (!fs.existsSync(gitPath)) {
console.error("no valid .git path");
console.error('no valid .git path');
process.exit(1);
}

const result = child_process.spawnSync(
"sh",
["-c", `${commitlintBinPath} --config ${configPath} --cwd ${path.dirname(gitPath)} --edit`],
{
stdio: "inherit",
},
);
try {
child_process.execSync(`${commitlintBinPath} --config ${configPath} --cwd ${path.dirname(gitPath)} --edit`, {
stdio: 'inherit',
windowsHide: true
});

if (result.status !== 0) {
} catch (e) {
console.error(`lint error: ${e}`);
process.exit(1);
}
28 changes: 10 additions & 18 deletions common/autoinstallers/lint/prettier.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import minimist, { ParsedArgs } from "minimist";
import { spawnSync } from "child_process";
import { RushConfiguration } from "@microsoft/rush-lib";
import minimist, { ParsedArgs } from 'minimist';
import { execSync } from 'child_process';
import { RushConfiguration } from '@microsoft/rush-lib';

interface PrettierScriptArgv extends ParsedArgs {
dir?: string;
Expand All @@ -12,12 +12,12 @@ function run() {
const rushConfiguration = RushConfiguration.loadFromDefaultLocation({ startingFolder: cwd });

const argv: PrettierScriptArgv = minimist(process.argv.slice(2));
const configFilePath = rushConfiguration.rushJsonFolder + "/.prettierrc.js";
const ignoreFilePath = rushConfiguration.rushJsonFolder + "/.prettierignore";
const configFilePath = rushConfiguration.rushJsonFolder + '/.prettierrc.js';
const ignoreFilePath = rushConfiguration.rushJsonFolder + '/.prettierignore';

let ext = "{ts,tsx,less}";
let ext = '{ts,tsx,less}';
if (argv.ext) {
const length = argv.ext.split(",").length;
const length = argv.ext.split(',').length;
ext = length === 1 ? `${argv.ext}` : `{${argv.ext}}`;
}

Expand All @@ -28,17 +28,9 @@ function run() {

console.log(patterns);

spawnSync(
"sh",
[
"-c",
`prettier --config ${configFilePath} --ignore-path ${ignoreFilePath} --write ${patterns}`,
],
{
shell: false,
stdio: [0, 1, 2],
},
);
execSync(`prettier --config ${configFilePath} --ignore-path ${ignoreFilePath} --write ${patterns}`, {
stdio: [0, 1, 2]
});
}

run();
22 changes: 11 additions & 11 deletions common/autoinstallers/run-script/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import minimist, { ParsedArgs } from "minimist";
import { RushConfiguration } from "@microsoft/rush-lib";
import { spawnSync } from "child_process";
import minimist, { ParsedArgs } from 'minimist';
import { RushConfiguration } from '@microsoft/rush-lib';
import { execSync } from 'child_process';

interface RunScriptArgv extends ParsedArgs {
project?: string;
Expand All @@ -10,19 +10,19 @@ interface RunScriptArgv extends ParsedArgs {
function run() {
const argv: RunScriptArgv = minimist(process.argv.slice(2));
const projects = RushConfiguration.loadFromDefaultLocation({
startingFolder: process.cwd(),
startingFolder: process.cwd()
});

const targetProject = projects.findProjectByShorthandName(argv.project!);

if (targetProject) {
const result = spawnSync("sh", ["-c", `rushx ${argv.script}`], {
cwd: targetProject?.projectFolder,
shell: false,
stdio: [0, 1, 2],
});
if (result.status !== 0) {
process.exit(result.status);
try {
execSync(`rushx ${argv.script}`, {
cwd: targetProject?.projectFolder,
stdio: [0, 1, 2]
});
} catch (e) {
console.error(`Encountered error: ${e}`);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions packages/vchart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"build:cjs": "bundle --clean -f cjs --ignorePostTasks --ignoreUmdEntries",
"build:es": "bundle --clean -f es --ignorePostTasks",
"analyze": "npm run analyze-full && npm run analyze-line && npm run analyze-simple",
"analyze-full": "BUNDLE_ANALYZE='full' bundle -f umd ",
"analyze-simple": "BUNDLE_ANALYZE='simple' bundle -f umd",
"analyze-full": "cross-env BUNDLE_ANALYZE='full' bundle -f umd ",
"analyze-simple": "cross-env BUNDLE_ANALYZE='simple' bundle -f umd",
"dev": "bundle --clean -f es -w",
"compile": "tsc --noEmit",
"start": "ts-node __tests__/runtime/browser/scripts/initVite.ts && vite serve __tests__/runtime/browser",
Expand All @@ -39,7 +39,7 @@
"test": "jest",
"test-cov": "jest -w 16 --coverage",
"test-live": "npm run test-watch __tests__/unit",
"test-watch": "DEBUG_MODE=1 jest --watch",
"test-watch": "cross-env DEBUG_MODE=1 jest --watch",
"ci": "ts-node --transpileOnly --skipProject ./scripts/trigger-test.ts",
"size": "size-limit"
},
Expand Down Expand Up @@ -112,7 +112,8 @@
"canvas": "2.11.2",
"size-limit": "9.0.0",
"@size-limit/file": "9.0.0",
"rimraf": "3.0.2"
"rimraf": "3.0.2",
"cross-env": "^7.0.3"
},
"dependencies": {
"@visactor/vutils": "~0.18.6",
Expand Down