progress on migrating to heex templates and font-icons
This commit is contained in:
parent
d43daafdb7
commit
3eff955672
21793 changed files with 2161968 additions and 16895 deletions
assets_old/node_modules/webpack-cli/lib
bootstrap.jsindex.jswebpack-cli.js
plugins
utils
__tests__
get-package-manager.test.jsprompt-installation.test.js
capitalize-first-letter.jsdynamic-import-loader.jsget-package-manager.jsindex.jslogger.jspackage-exists.jsprompt-installation.jsrun-command.jsto-kebab-case.jstest-all-lock
test-npm-and-pnpm
test-npm-and-yarn
test-npm-lock
test-pnpm-lock
test-yarn-and-pnpm
test-yarn-lock
18
assets_old/node_modules/webpack-cli/lib/bootstrap.js
generated
vendored
Normal file
18
assets_old/node_modules/webpack-cli/lib/bootstrap.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
const WebpackCLI = require('./webpack-cli');
|
||||
const utils = require('./utils');
|
||||
|
||||
const runCLI = async (args, originalModuleCompile) => {
|
||||
try {
|
||||
// Create a new instance of the CLI object
|
||||
const cli = new WebpackCLI();
|
||||
|
||||
cli._originalModuleCompile = originalModuleCompile;
|
||||
|
||||
await cli.run(args);
|
||||
} catch (error) {
|
||||
utils.logger.error(error);
|
||||
process.exit(2);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = runCLI;
|
5
assets_old/node_modules/webpack-cli/lib/index.js
generated
vendored
Normal file
5
assets_old/node_modules/webpack-cli/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
const CLI = require('./webpack-cli');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = CLI;
|
||||
module.exports.utils = utils;
|
99
assets_old/node_modules/webpack-cli/lib/plugins/CLIPlugin.js
generated
vendored
Normal file
99
assets_old/node_modules/webpack-cli/lib/plugins/CLIPlugin.js
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
class CLIPlugin {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
setupHotPlugin(compiler) {
|
||||
const { HotModuleReplacementPlugin } = compiler.webpack || require('webpack');
|
||||
const hotModuleReplacementPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof HotModuleReplacementPlugin));
|
||||
|
||||
if (!hotModuleReplacementPlugin) {
|
||||
new HotModuleReplacementPlugin().apply(compiler);
|
||||
}
|
||||
}
|
||||
|
||||
setupPrefetchPlugin(compiler) {
|
||||
const { PrefetchPlugin } = compiler.webpack || require('webpack');
|
||||
|
||||
new PrefetchPlugin(null, this.options.prefetch).apply(compiler);
|
||||
}
|
||||
|
||||
async setupBundleAnalyzerPlugin(compiler) {
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const bundleAnalyzerPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof BundleAnalyzerPlugin));
|
||||
|
||||
if (!bundleAnalyzerPlugin) {
|
||||
new BundleAnalyzerPlugin().apply(compiler);
|
||||
}
|
||||
}
|
||||
|
||||
setupProgressPlugin(compiler) {
|
||||
const { ProgressPlugin } = compiler.webpack || require('webpack');
|
||||
const progressPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin));
|
||||
|
||||
if (!progressPlugin) {
|
||||
new ProgressPlugin({ profile: this.options.progress === 'profile' }).apply(compiler);
|
||||
}
|
||||
}
|
||||
|
||||
setupHelpfulOutput(compiler) {
|
||||
const pluginName = 'webpack-cli';
|
||||
const getCompilationName = () => (compiler.name ? ` '${compiler.name}'` : '');
|
||||
|
||||
compiler.hooks.run.tap(pluginName, () => {
|
||||
this.logger.log(`Compilation${getCompilationName()} starting...`);
|
||||
});
|
||||
|
||||
compiler.hooks.watchRun.tap(pluginName, (compiler) => {
|
||||
const { bail, watch } = compiler.options;
|
||||
|
||||
if (bail && watch) {
|
||||
this.logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.');
|
||||
}
|
||||
|
||||
this.logger.log(`Compilation${getCompilationName()} starting...`);
|
||||
});
|
||||
|
||||
compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => {
|
||||
const date = new Date(changeTime * 1000);
|
||||
|
||||
this.logger.log(`File '${filename}' was modified`);
|
||||
this.logger.log(`Changed time is ${date} (timestamp is ${changeTime})`);
|
||||
});
|
||||
|
||||
(compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, () => {
|
||||
this.logger.log(`Compilation${getCompilationName()} finished`);
|
||||
|
||||
process.nextTick(() => {
|
||||
if (compiler.watchMode) {
|
||||
this.logger.log(`Compiler${getCompilationName()} is watching files for updates...`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
this.logger = compiler.getInfrastructureLogger('webpack-cli');
|
||||
|
||||
if (this.options.progress) {
|
||||
this.setupProgressPlugin(compiler);
|
||||
}
|
||||
|
||||
if (this.options.hot) {
|
||||
this.setupHotPlugin(compiler);
|
||||
}
|
||||
|
||||
if (this.options.prefetch) {
|
||||
this.setupPrefetchPlugin(compiler);
|
||||
}
|
||||
|
||||
if (this.options.analyze) {
|
||||
this.setupBundleAnalyzerPlugin(compiler);
|
||||
}
|
||||
|
||||
this.setupHelpfulOutput(compiler);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CLIPlugin;
|
108
assets_old/node_modules/webpack-cli/lib/utils/__tests__/get-package-manager.test.js
generated
vendored
Normal file
108
assets_old/node_modules/webpack-cli/lib/utils/__tests__/get-package-manager.test.js
generated
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const syncMock = jest.fn(() => {
|
||||
return {
|
||||
stdout: '1.0.0',
|
||||
};
|
||||
});
|
||||
jest.setMock('execa', {
|
||||
sync: syncMock,
|
||||
});
|
||||
const getPackageManager = require('../get-package-manager');
|
||||
|
||||
jest.mock('../get-package-manager', () => jest.fn());
|
||||
const globalModulesNpmValue = 'test-npm';
|
||||
jest.setMock('global-modules', globalModulesNpmValue);
|
||||
jest.setMock('enquirer', {
|
||||
prompt: jest.fn(),
|
||||
});
|
||||
|
||||
describe('packageUtils', () => {
|
||||
describe('getPackageManager', () => {
|
||||
const testYarnLockPath = path.resolve(__dirname, 'test-yarn-lock');
|
||||
const testNpmLockPath = path.resolve(__dirname, 'test-npm-lock');
|
||||
const testPnpmLockPath = path.resolve(__dirname, 'test-pnpm-lock');
|
||||
const testNpmAndPnpmPath = path.resolve(__dirname, 'test-npm-and-pnpm');
|
||||
const testNpmAndYarnPath = path.resolve(__dirname, 'test-npm-and-yarn');
|
||||
const testYarnAndPnpmPath = path.resolve(__dirname, 'test-yarn-and-pnpm');
|
||||
const testAllPath = path.resolve(__dirname, 'test-all-lock');
|
||||
const noLockPath = path.resolve(__dirname, 'no-lock-files');
|
||||
|
||||
const cwdSpy = jest.spyOn(process, 'cwd');
|
||||
|
||||
beforeAll(() => {
|
||||
// package-lock.json is ignored by .gitignore, so we simply
|
||||
// write a lockfile here for testing
|
||||
if (!fs.existsSync(testNpmLockPath)) {
|
||||
fs.mkdirSync(testNpmLockPath);
|
||||
}
|
||||
fs.writeFileSync(path.resolve(testNpmLockPath, 'package-lock.json'), '');
|
||||
fs.writeFileSync(path.resolve(testNpmAndPnpmPath, 'package-lock.json'), '');
|
||||
fs.writeFileSync(path.resolve(testNpmAndYarnPath, 'package-lock.json'), '');
|
||||
fs.writeFileSync(path.resolve(testAllPath, 'package-lock.json'), '');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
syncMock.mockClear();
|
||||
});
|
||||
|
||||
it('should find yarn.lock', () => {
|
||||
cwdSpy.mockReturnValue(testYarnLockPath);
|
||||
expect(getPackageManager()).toEqual('yarn');
|
||||
expect(syncMock.mock.calls.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should find package-lock.json', () => {
|
||||
cwdSpy.mockReturnValue(testNpmLockPath);
|
||||
expect(getPackageManager()).toEqual('npm');
|
||||
expect(syncMock.mock.calls.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should find pnpm-lock.yaml', () => {
|
||||
cwdSpy.mockReturnValue(testPnpmLockPath);
|
||||
expect(getPackageManager()).toEqual('pnpm');
|
||||
expect(syncMock.mock.calls.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should prioritize npm over pnpm', () => {
|
||||
cwdSpy.mockReturnValue(testNpmAndPnpmPath);
|
||||
expect(getPackageManager()).toEqual('npm');
|
||||
expect(syncMock.mock.calls.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should prioritize npm over yarn', () => {
|
||||
cwdSpy.mockReturnValue(testNpmAndYarnPath);
|
||||
expect(getPackageManager()).toEqual('npm');
|
||||
expect(syncMock.mock.calls.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should prioritize yarn over pnpm', () => {
|
||||
cwdSpy.mockReturnValue(testYarnAndPnpmPath);
|
||||
expect(getPackageManager()).toEqual('yarn');
|
||||
expect(syncMock.mock.calls.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should prioritize npm with many lock files', () => {
|
||||
cwdSpy.mockReturnValue(testAllPath);
|
||||
expect(getPackageManager()).toEqual('npm');
|
||||
expect(syncMock.mock.calls.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should prioritize global npm over other package managers', () => {
|
||||
cwdSpy.mockReturnValue(noLockPath);
|
||||
expect(getPackageManager()).toEqual('npm');
|
||||
expect(syncMock.mock.calls.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should throw error if no package manager is found', () => {
|
||||
syncMock.mockImplementation(() => {
|
||||
throw new Error();
|
||||
});
|
||||
const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {});
|
||||
expect(getPackageManager()).toBeFalsy();
|
||||
expect(mockExit).toBeCalledWith(2);
|
||||
expect(syncMock.mock.calls.length).toEqual(3); // 3 calls for npm, yarn and pnpm
|
||||
});
|
||||
});
|
||||
});
|
118
assets_old/node_modules/webpack-cli/lib/utils/__tests__/prompt-installation.test.js
generated
vendored
Normal file
118
assets_old/node_modules/webpack-cli/lib/utils/__tests__/prompt-installation.test.js
generated
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
'use strict';
|
||||
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const stripAnsi = require('strip-ansi');
|
||||
const globalModulesNpmValue = 'test-npm';
|
||||
|
||||
jest.setMock('global-modules', globalModulesNpmValue);
|
||||
jest.setMock('enquirer', { prompt: jest.fn() });
|
||||
jest.setMock('../run-command', jest.fn());
|
||||
jest.setMock('../package-exists', jest.fn());
|
||||
jest.setMock('../get-package-manager', jest.fn());
|
||||
|
||||
const getPackageManager = require('../get-package-manager');
|
||||
const packageExists = require('../package-exists');
|
||||
const promptInstallation = require('../prompt-installation');
|
||||
const runCommand = require('../run-command');
|
||||
const { prompt } = require('enquirer');
|
||||
|
||||
describe('promptInstallation', () => {
|
||||
beforeAll(() => {
|
||||
packageExists.mockReturnValue(true);
|
||||
});
|
||||
beforeEach(() => {
|
||||
runCommand.mockClear();
|
||||
prompt.mockClear();
|
||||
});
|
||||
|
||||
it('should prompt to install using npm if npm is package manager', async () => {
|
||||
prompt.mockReturnValue({ installConfirm: true });
|
||||
|
||||
getPackageManager.mockReturnValue('npm');
|
||||
|
||||
const preMessage = jest.fn();
|
||||
const promptResult = await promptInstallation('test-package', preMessage);
|
||||
|
||||
expect(promptResult).toBeTruthy();
|
||||
expect(preMessage.mock.calls.length).toEqual(1);
|
||||
expect(prompt.mock.calls.length).toEqual(1);
|
||||
expect(runCommand.mock.calls.length).toEqual(1);
|
||||
expect(stripAnsi(prompt.mock.calls[0][0][0].message)).toContain(
|
||||
"Would you like to install 'test-package' package? (That will run 'npm install -D test-package')",
|
||||
);
|
||||
|
||||
// install the package using npm
|
||||
expect(runCommand.mock.calls[0][0]).toEqual('npm install -D test-package');
|
||||
});
|
||||
|
||||
it('should prompt to install using yarn if yarn is package manager', async () => {
|
||||
prompt.mockReturnValue({ installConfirm: true });
|
||||
|
||||
getPackageManager.mockReturnValue('yarn');
|
||||
|
||||
const promptResult = await promptInstallation('test-package');
|
||||
|
||||
expect(promptResult).toBeTruthy();
|
||||
expect(prompt.mock.calls.length).toEqual(1);
|
||||
expect(runCommand.mock.calls.length).toEqual(1);
|
||||
expect(stripAnsi(prompt.mock.calls[0][0][0].message)).toContain(
|
||||
"Would you like to install 'test-package' package? (That will run 'yarn add -D test-package')",
|
||||
);
|
||||
|
||||
// install the package using yarn
|
||||
expect(runCommand.mock.calls[0][0]).toEqual('yarn add -D test-package');
|
||||
});
|
||||
|
||||
it('should prompt to install using pnpm if pnpm is package manager', async () => {
|
||||
prompt.mockReturnValue({ installConfirm: true });
|
||||
|
||||
getPackageManager.mockReturnValue('pnpm');
|
||||
|
||||
const promptResult = await promptInstallation('test-package');
|
||||
|
||||
expect(promptResult).toBeTruthy();
|
||||
expect(prompt.mock.calls.length).toEqual(1);
|
||||
expect(runCommand.mock.calls.length).toEqual(1);
|
||||
expect(stripAnsi(prompt.mock.calls[0][0][0].message)).toContain(
|
||||
"Would you like to install 'test-package' package? (That will run 'pnpm install -D test-package')",
|
||||
);
|
||||
|
||||
// install the package using npm
|
||||
expect(runCommand.mock.calls[0][0]).toEqual('pnpm install -D test-package');
|
||||
});
|
||||
|
||||
it('should support pre message', async () => {
|
||||
prompt.mockReturnValue({ installConfirm: true });
|
||||
|
||||
getPackageManager.mockReturnValue('npm');
|
||||
|
||||
const preMessage = jest.fn();
|
||||
const promptResult = await promptInstallation('test-package', preMessage);
|
||||
|
||||
expect(promptResult).toBeTruthy();
|
||||
expect(preMessage.mock.calls.length).toEqual(1);
|
||||
expect(prompt.mock.calls.length).toEqual(1);
|
||||
expect(runCommand.mock.calls.length).toEqual(1);
|
||||
expect(stripAnsi(prompt.mock.calls[0][0][0].message)).toContain(
|
||||
"Would you like to install 'test-package' package? (That will run 'npm install -D test-package')",
|
||||
);
|
||||
|
||||
// install the package using npm
|
||||
expect(runCommand.mock.calls[0][0]).toEqual('npm install -D test-package');
|
||||
});
|
||||
|
||||
it('should not install if install is not confirmed', async () => {
|
||||
prompt.mockReturnValue({ installConfirm: false });
|
||||
|
||||
const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {});
|
||||
const promptResult = await promptInstallation('test-package');
|
||||
|
||||
expect(promptResult).toBeUndefined();
|
||||
expect(prompt.mock.calls.length).toEqual(1);
|
||||
// runCommand should not be called, because the installation is not confirmed
|
||||
expect(runCommand.mock.calls.length).toEqual(0);
|
||||
expect(mockExit.mock.calls[0][0]).toEqual(2);
|
||||
|
||||
mockExit.mockRestore();
|
||||
});
|
||||
});
|
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-all-lock/package-lock.json
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-all-lock/package-lock.json
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-all-lock/pnpm-lock.yaml
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-all-lock/pnpm-lock.yaml
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-all-lock/yarn.lock
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-all-lock/yarn.lock
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/package-lock.json
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/package-lock.json
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/pnpm-lock.yaml
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/pnpm-lock.yaml
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/package-lock.json
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/package-lock.json
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/yarn.lock
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/yarn.lock
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-lock/package-lock.json
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-npm-lock/package-lock.json
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-pnpm-lock/pnpm-lock.yaml
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-pnpm-lock/pnpm-lock.yaml
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/pnpm-lock.yaml
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/pnpm-lock.yaml
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/yarn.lock
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/yarn.lock
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-yarn-lock/yarn.lock
generated
vendored
Normal file
0
assets_old/node_modules/webpack-cli/lib/utils/__tests__/test-yarn-lock/yarn.lock
generated
vendored
Normal file
9
assets_old/node_modules/webpack-cli/lib/utils/capitalize-first-letter.js
generated
vendored
Normal file
9
assets_old/node_modules/webpack-cli/lib/utils/capitalize-first-letter.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
const capitalizeFirstLetter = (string) => {
|
||||
if (typeof string !== 'string') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
};
|
||||
|
||||
module.exports = capitalizeFirstLetter;
|
13
assets_old/node_modules/webpack-cli/lib/utils/dynamic-import-loader.js
generated
vendored
Normal file
13
assets_old/node_modules/webpack-cli/lib/utils/dynamic-import-loader.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
function dynamicImportLoader() {
|
||||
let importESM;
|
||||
|
||||
try {
|
||||
importESM = new Function('id', 'return import(id);');
|
||||
} catch (e) {
|
||||
importESM = null;
|
||||
}
|
||||
|
||||
return importESM;
|
||||
}
|
||||
|
||||
module.exports = dynamicImportLoader;
|
65
assets_old/node_modules/webpack-cli/lib/utils/get-package-manager.js
generated
vendored
Normal file
65
assets_old/node_modules/webpack-cli/lib/utils/get-package-manager.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { sync } = require('execa');
|
||||
|
||||
const utils = require('./index');
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the name of package manager to use,
|
||||
* preference order - npm > yarn > pnpm
|
||||
*
|
||||
* @returns {String} - The package manager name
|
||||
*/
|
||||
function getPackageManager() {
|
||||
const hasLocalNpm = fs.existsSync(path.resolve(process.cwd(), 'package-lock.json'));
|
||||
|
||||
if (hasLocalNpm) {
|
||||
return 'npm';
|
||||
}
|
||||
|
||||
const hasLocalYarn = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock'));
|
||||
|
||||
if (hasLocalYarn) {
|
||||
return 'yarn';
|
||||
}
|
||||
|
||||
const hasLocalPnpm = fs.existsSync(path.resolve(process.cwd(), 'pnpm-lock.yaml'));
|
||||
|
||||
if (hasLocalPnpm) {
|
||||
return 'pnpm';
|
||||
}
|
||||
|
||||
try {
|
||||
// the sync function below will fail if npm is not installed,
|
||||
// an error will be thrown
|
||||
if (sync('npm', ['--version'])) {
|
||||
return 'npm';
|
||||
}
|
||||
} catch (e) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
try {
|
||||
// the sync function below will fail if yarn is not installed,
|
||||
// an error will be thrown
|
||||
if (sync('yarn', ['--version'])) {
|
||||
return 'yarn';
|
||||
}
|
||||
} catch (e) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
try {
|
||||
// the sync function below will fail if pnpm is not installed,
|
||||
// an error will be thrown
|
||||
if (sync('pnpm', ['--version'])) {
|
||||
return 'pnpm';
|
||||
}
|
||||
} catch (e) {
|
||||
utils.logger.error('No package manager found.');
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = getPackageManager;
|
49
assets_old/node_modules/webpack-cli/lib/utils/index.js
generated
vendored
Normal file
49
assets_old/node_modules/webpack-cli/lib/utils/index.js
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
module.exports = {
|
||||
get colors() {
|
||||
return require('colorette');
|
||||
},
|
||||
|
||||
get levenshtein() {
|
||||
return require('fastest-levenshtein');
|
||||
},
|
||||
|
||||
get interpret() {
|
||||
return require('interpret');
|
||||
},
|
||||
|
||||
get rechoir() {
|
||||
return require('rechoir');
|
||||
},
|
||||
|
||||
get capitalizeFirstLetter() {
|
||||
return require('./capitalize-first-letter');
|
||||
},
|
||||
|
||||
get dynamicImportLoader() {
|
||||
return require('./dynamic-import-loader');
|
||||
},
|
||||
|
||||
get getPackageManager() {
|
||||
return require('./get-package-manager');
|
||||
},
|
||||
|
||||
get logger() {
|
||||
return require('./logger');
|
||||
},
|
||||
|
||||
get packageExists() {
|
||||
return require('./package-exists');
|
||||
},
|
||||
|
||||
get promptInstallation() {
|
||||
return require('./prompt-installation');
|
||||
},
|
||||
|
||||
get runCommand() {
|
||||
return require('./run-command');
|
||||
},
|
||||
|
||||
get toKebabCase() {
|
||||
return require('./to-kebab-case');
|
||||
},
|
||||
};
|
11
assets_old/node_modules/webpack-cli/lib/utils/logger.js
generated
vendored
Normal file
11
assets_old/node_modules/webpack-cli/lib/utils/logger.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
const utils = require('./index');
|
||||
const util = require('util');
|
||||
|
||||
module.exports = {
|
||||
error: (val) => console.error(`[webpack-cli] ${utils.colors.red(util.format(val))}`),
|
||||
warn: (val) => console.warn(`[webpack-cli] ${utils.colors.yellow(val)}`),
|
||||
info: (val) => console.info(`[webpack-cli] ${utils.colors.cyan(val)}`),
|
||||
success: (val) => console.log(`[webpack-cli] ${utils.colors.green(val)}`),
|
||||
log: (val) => console.log(`[webpack-cli] ${val}`),
|
||||
raw: (val) => console.log(val),
|
||||
};
|
9
assets_old/node_modules/webpack-cli/lib/utils/package-exists.js
generated
vendored
Normal file
9
assets_old/node_modules/webpack-cli/lib/utils/package-exists.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
function packageExists(packageName) {
|
||||
try {
|
||||
return require.resolve(packageName);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = packageExists;
|
58
assets_old/node_modules/webpack-cli/lib/utils/prompt-installation.js
generated
vendored
Normal file
58
assets_old/node_modules/webpack-cli/lib/utils/prompt-installation.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
const { prompt } = require('enquirer');
|
||||
const utils = require('./index');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param packageName
|
||||
* @param preMessage Message to show before the question
|
||||
*/
|
||||
async function promptInstallation(packageName, preMessage) {
|
||||
const packageManager = utils.getPackageManager();
|
||||
|
||||
if (!packageManager) {
|
||||
utils.logger.error("Can't find package manager");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
if (preMessage) {
|
||||
preMessage();
|
||||
}
|
||||
|
||||
// yarn uses 'add' command, rest npm and pnpm both use 'install'
|
||||
const commandToBeRun = `${packageManager} ${[packageManager === 'yarn' ? 'add' : 'install', '-D', packageName].join(' ')}`;
|
||||
const { colors } = utils;
|
||||
|
||||
let installConfirm;
|
||||
|
||||
try {
|
||||
({ installConfirm } = await prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'installConfirm',
|
||||
message: `Would you like to install '${colors.green(packageName)}' package? (That will run '${colors.green(
|
||||
commandToBeRun,
|
||||
)}')`,
|
||||
initial: 'Y',
|
||||
stdout: process.stderr,
|
||||
},
|
||||
]));
|
||||
} catch (error) {
|
||||
utils.logger.error(error);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
if (installConfirm) {
|
||||
try {
|
||||
await utils.runCommand(commandToBeRun);
|
||||
} catch (error) {
|
||||
utils.logger.error(error);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
return utils.packageExists(packageName);
|
||||
}
|
||||
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
module.exports = promptInstallation;
|
13
assets_old/node_modules/webpack-cli/lib/utils/run-command.js
generated
vendored
Normal file
13
assets_old/node_modules/webpack-cli/lib/utils/run-command.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
const execa = require('execa');
|
||||
const utils = require('./index');
|
||||
|
||||
async function runCommand(command, args = []) {
|
||||
try {
|
||||
await execa(command, args, { stdio: 'inherit', shell: true });
|
||||
} catch (error) {
|
||||
utils.logger.error(error.message);
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = runCommand;
|
5
assets_old/node_modules/webpack-cli/lib/utils/to-kebab-case.js
generated
vendored
Normal file
5
assets_old/node_modules/webpack-cli/lib/utils/to-kebab-case.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
const toKebabCase = (str) => {
|
||||
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
||||
};
|
||||
|
||||
module.exports = toKebabCase;
|
1803
assets_old/node_modules/webpack-cli/lib/webpack-cli.js
generated
vendored
Normal file
1803
assets_old/node_modules/webpack-cli/lib/webpack-cli.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue