refactor: use node scheme imports in scripts (#38846)
* refactor: use node scheme imports in script * refactor: use node scheme imports in build
This commit is contained in:
parent
395b608dd5
commit
abec9ead06
40 changed files with 105 additions and 89 deletions
8
build/.eslintrc.json
Normal file
8
build/.eslintrc.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"plugins": [
|
||||
"unicorn"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/prefer-node-protocol": "error"
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const webpack = require('webpack');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const WrapperPlugin = require('wrapper-webpack-plugin');
|
||||
|
|
8
script/.eslintrc.json
Normal file
8
script/.eslintrc.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"plugins": [
|
||||
"unicorn"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/prefer-node-protocol": "error"
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { spawnSync } from 'child_process';
|
||||
import * as path from 'path';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as path from 'node:path';
|
||||
|
||||
const srcPath = path.resolve(__dirname, '..', '..', '..');
|
||||
const patchExportFnPath = path.resolve(__dirname, 'export_all_patches.py');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const utils = require('./lib/utils');
|
||||
const branding = require('../shell/app/BRANDING.json');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as cp from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as cp from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
|
||||
const certificatePath = process.argv[2];
|
||||
const outPath = process.argv[3];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { parseDocs } = require('@electron/docs-parser');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const { getElectronVersion } = require('./lib/get-version');
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const args = require('minimist')(process.argv.slice(2));
|
||||
const fs = require('fs');
|
||||
const fs = require('node:fs');
|
||||
const got = require('got');
|
||||
const stream = require('stream');
|
||||
const { promisify } = require('util');
|
||||
const stream = require('node:stream');
|
||||
const { promisify } = require('node:util');
|
||||
|
||||
const pipeline = promisify(stream.pipeline);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as cp from 'child_process';
|
||||
import * as cp from 'node:child_process';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
|
||||
const rootPath = path.resolve(__dirname, '..');
|
||||
const gniPath = path.resolve(__dirname, '../filenames.auto.gni');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const check = process.argv.includes('--check');
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const check = process.argv.includes('--check');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('node:crypto');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
// Fallback to blow away old cache keys
|
||||
const FALLBACK_HASH_VERSION = 3;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const semver = require('semver');
|
||||
|
||||
const outputPath = process.argv[2];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const asar = require('@electron/asar');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const crypto = require('node:crypto');
|
||||
const fs = require('node:fs');
|
||||
|
||||
const archive = process.argv[2];
|
||||
const hashFile = process.argv[3];
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const asar = require('@electron/asar');
|
||||
const assert = require('assert');
|
||||
const assert = require('node:assert');
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
|
||||
const getArgGroup = (name) => {
|
||||
const group = [];
|
||||
|
|
|
@ -4,8 +4,8 @@ Usage:
|
|||
$ node ./script/gn-check.js [--outDir=dirName]
|
||||
*/
|
||||
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
const cp = require('node:child_process');
|
||||
const path = require('node:path');
|
||||
const args = require('minimist')(process.argv.slice(2), { string: ['outDir'] });
|
||||
|
||||
const { getOutDir } = require('./lib/utils');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const fs = require('fs');
|
||||
const fs = require('node:fs');
|
||||
|
||||
const [,, plistPath, outputPath, ...keySet] = process.argv;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable camelcase */
|
||||
const { BlobServiceClient } = require('@azure/storage-blob');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const blobServiceClient = BlobServiceClient.fromConnectionString(process.env.ELECTRON_ARTIFACTS_BLOB_STORAGE);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { spawnSync } = require('child_process');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('node:child_process');
|
||||
const path = require('node:path');
|
||||
|
||||
module.exports.getElectronVersion = () => {
|
||||
// Find the nearest tag to the current HEAD
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const { GitProcess } = require('dugite');
|
||||
const fs = require('fs');
|
||||
const fs = require('node:fs');
|
||||
const klaw = require('klaw');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
|
||||
const ELECTRON_DIR = path.resolve(__dirname, '..', '..');
|
||||
const SRC_DIR = path.resolve(ELECTRON_DIR, '..');
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const crypto = require('crypto');
|
||||
const crypto = require('node:crypto');
|
||||
const { GitProcess } = require('dugite');
|
||||
const childProcess = require('child_process');
|
||||
const childProcess = require('node:child_process');
|
||||
const { ESLint } = require('eslint');
|
||||
const fs = require('fs');
|
||||
const fs = require('node:fs');
|
||||
const minimist = require('minimist');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
const { chunkFilenames, findMatchingFiles } = require('./lib/utils');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const cp = require('node:child_process');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const BASE = path.resolve(__dirname, '../..');
|
||||
const NAN_DIR = path.resolve(BASE, 'third_party', 'nan');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const cp = require('node:child_process');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const args = require('minimist')(process.argv.slice(2), {
|
||||
boolean: ['default', 'validateDisabled'],
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
if (!process.env.CI) require('dotenv-safe').load();
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const assert = require('node:assert');
|
||||
const fs = require('node:fs');
|
||||
const got = require('got');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
const { handleGitCall, ELECTRON_DIR } = require('./lib/utils.js');
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
const octokit = new Octokit();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { appCredentialsFromString, getTokenForRepo } = require('@electron/github-app-auth');
|
||||
const cp = require('child_process');
|
||||
const cp = require('node:child_process');
|
||||
|
||||
if (!process.env.CIRCLE_BRANCH) {
|
||||
console.error('Not building for a specific branch, can\'t autopush a patch');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
if (!process.env.CI) require('dotenv-safe').load();
|
||||
|
||||
const assert = require('assert');
|
||||
const assert = require('node:assert');
|
||||
const got = require('got');
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const got = require('got');
|
||||
const url = require('url');
|
||||
const url = require('node:url');
|
||||
|
||||
module.exports = async function getUrlHash (targetUrl, algorithm = 'sha256', attempts = 3) {
|
||||
const options = {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const { GitProcess } = require('dugite');
|
||||
const minimist = require('minimist');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
const semver = require('semver');
|
||||
|
||||
const { ELECTRON_DIR } = require('../../lib/utils');
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const { GitProcess } = require('dugite');
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ const args = require('minimist')(process.argv.slice(2), {
|
|||
});
|
||||
const ciReleaseBuild = require('./ci-release-build');
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
const { execSync } = require('child_process');
|
||||
const { execSync } = require('node:child_process');
|
||||
const { GitProcess } = require('dugite');
|
||||
|
||||
const path = require('path');
|
||||
const readline = require('readline');
|
||||
const path = require('node:path');
|
||||
const readline = require('node:readline');
|
||||
const releaseNotesGenerator = require('./notes/index.js');
|
||||
const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils.js');
|
||||
const bumpType = args._[0];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const temp = require('temp');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const childProcess = require('node:child_process');
|
||||
const got = require('got');
|
||||
const semver = require('semver');
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ const args = require('minimist')(process.argv.slice(2), {
|
|||
string: ['tag', 'releaseID'],
|
||||
default: { releaseID: '' }
|
||||
});
|
||||
const { execSync } = require('child_process');
|
||||
const { execSync } = require('node:child_process');
|
||||
const { GitProcess } = require('dugite');
|
||||
const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils.js');
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
|
|
|
@ -9,13 +9,13 @@ const args = require('minimist')(process.argv.slice(2), {
|
|||
],
|
||||
default: { verboseNugget: false }
|
||||
});
|
||||
const fs = require('fs');
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('node:fs');
|
||||
const { execSync } = require('node:child_process');
|
||||
const got = require('got');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
const semver = require('semver');
|
||||
const temp = require('temp').track();
|
||||
const { URL } = require('url');
|
||||
const { URL } = require('node:url');
|
||||
const { BlobServiceClient } = require('@azure/storage-blob');
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Octokit } from '@octokit/rest';
|
||||
import * as fs from 'fs';
|
||||
import * as fs from 'node:fs';
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: process.env.ELECTRON_GITHUB_TOKEN
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
const semver = require('semver');
|
||||
const { GitProcess } = require('dugite');
|
||||
const { promisify } = require('util');
|
||||
const { promisify } = require('node:util');
|
||||
|
||||
const { ELECTRON_DIR } = require('../lib/utils');
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import * as childProcess from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
import * as childProcess from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as minimist from 'minimist';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import * as streamChain from 'stream-chain';
|
||||
import * as streamJson from 'stream-json';
|
||||
import { ignore as streamJsonIgnore } from 'stream-json/filters/Ignore';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const cp = require('node:child_process');
|
||||
const fs = require('node:fs');
|
||||
|
||||
const checkPath = process.argv[2];
|
||||
const command = process.argv.slice(3);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const { ElectronVersions, Installer } = require('@electron/fiddle-core');
|
||||
const childProcess = require('child_process');
|
||||
const crypto = require('crypto');
|
||||
const childProcess = require('node:child_process');
|
||||
const crypto = require('node:crypto');
|
||||
const fs = require('fs-extra');
|
||||
const { hashElement } = require('folder-hash');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
const unknownFlags = [];
|
||||
|
||||
require('colors');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const cp = require('child_process');
|
||||
const cp = require('node:child_process');
|
||||
const utils = require('./lib/utils');
|
||||
const electronPath = utils.getAbsoluteElectronExec();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const cp = require('node:child_process');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const YARN_VERSION = /'yarn_version': '(.+?)'/.exec(fs.readFileSync(path.resolve(__dirname, '../DEPS'), 'utf8'))[1];
|
||||
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
||||
|
|
Loading…
Reference in a new issue