forked from datyin/axios-parallel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,702 additions
and
3,160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/* | ||
node_modules/* | ||
compiler/* | ||
example/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2019, | ||
sourceType: 'module' | ||
}, | ||
env: { | ||
node: true, | ||
browser: false | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier/@typescript-eslint', | ||
'plugin:prettier/recommended' | ||
], | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 'off' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
.DS_Store | ||
.thumbs.db | ||
node_modules/ | ||
example.response.json | ||
dist/ | ||
|
||
# Log files | ||
/logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Editor directories and files | ||
.idea | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Defaults | ||
.*.swp | ||
._* | ||
.DS_Store | ||
.git | ||
.hg | ||
.npmrc | ||
.lock-wscript | ||
.svn | ||
.wafpickle-* | ||
config.gypi | ||
CVS | ||
npm-debug.log | ||
|
||
.vscode/ | ||
node_modules/ | ||
src/ | ||
dist/ | ||
compiler/ | ||
compiler.js | ||
tsconfig.json | ||
webpack.config.js | ||
.eslintignore | ||
.eslintrc.* | ||
.prettierrc* | ||
prettier.config.* | ||
_config.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
semi: true, | ||
tabWidth: 2, | ||
trailingComma: 'none', | ||
endOfLine: 'lf', | ||
printWidth: 100, | ||
singleQuote: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"files.eol": "\n" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-cayman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const yargs = require('yargs/yargs'); | ||
const webpack = require('webpack'); | ||
const config = require('./compiler/config'); | ||
const execute = require('./compiler/execute'); | ||
|
||
const args = yargs(process.argv).argv; | ||
const webpackConfig = config.webpack(args); | ||
|
||
webpack(webpackConfig, (err, stats) => { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
|
||
const statsInfo = stats.toJson(); | ||
|
||
console.log( | ||
stats.toString({ | ||
chunks: false, | ||
colors: true | ||
}) | ||
); | ||
|
||
if (args.dev) { | ||
execute(args, statsInfo); | ||
} else { | ||
config.package(args, statsInfo); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const { isPlainObject, clone } = require('lodash'); | ||
const { resolve } = require('path'); | ||
const { writeJsonSync } = require('fs-extra'); | ||
const webpackConfig = require('../webpack.config'); | ||
const package = require('../package.json'); | ||
|
||
function generateWebpackConfig(args) { | ||
if (!isPlainObject(webpackConfig)) { | ||
return { | ||
target: 'node12.19', | ||
mode: 'development', | ||
node: { | ||
global: false, | ||
__filename: false, | ||
__dirname: false | ||
} | ||
}; | ||
} | ||
|
||
if (args.dev) { | ||
webpackConfig.mode = 'development'; | ||
webpackConfig.watch = true; | ||
|
||
if (!webpackConfig.watchOptions) { | ||
webpackConfig.watchOptions = { | ||
aggregateTimeout: 200, | ||
ignored: ['node_modules/**', 'compiler.js'] | ||
}; | ||
} else { | ||
if (!webpackConfig.watchOptions.ignored) { | ||
webpackConfig.watchOptions.ignored = ['node_modules/**', 'compiler.js']; | ||
} | ||
} | ||
} else { | ||
webpackConfig.mode = 'production'; | ||
webpackConfig.watch = false; | ||
} | ||
|
||
if (!webpackConfig.output || !webpackConfig.path) { | ||
webpackConfig.output = { | ||
path: resolve(__dirname, '..', 'dist'), | ||
filename: '[name].js', | ||
libraryTarget: 'commonjs2' | ||
}; | ||
} | ||
|
||
return webpackConfig; | ||
} | ||
|
||
function generatePackage(args, stats) { | ||
const productionPackage = clone(package); | ||
|
||
if (productionPackage.scripts) delete productionPackage.scripts; | ||
if (productionPackage.dependencies) delete productionPackage.dependencies; | ||
if (productionPackage.devDependencies) delete productionPackage.devDependencies; | ||
|
||
const externalModules = stats.modules | ||
.filter((m) => m.identifier && m.identifier.startsWith('external ')) | ||
.map((m) => m.name.replace('external ', '').replace(/"/g, '')); | ||
|
||
const dependencies = {}; | ||
|
||
externalModules.forEach((p) => { | ||
if (package.dependencies && package.dependencies[p]) { | ||
dependencies[p] = package.dependencies[p]; | ||
} | ||
}); | ||
|
||
productionPackage.dependencies = dependencies; | ||
|
||
try { | ||
writeJsonSync(`${stats.outputPath}/package.json`, productionPackage, { | ||
spaces: 2, | ||
encoding: 'utf8' | ||
}); | ||
} catch (error) { | ||
console.log('Failed to write package.json', error.message); | ||
} | ||
} | ||
|
||
module.exports.webpack = generateWebpackConfig; | ||
module.exports.package = generatePackage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const chalk = require('chalk'); | ||
const { spawn } = require('child_process'); | ||
const { pathExistsSync } = require('fs-extra'); | ||
const { trim, forEach } = require('lodash'); | ||
const { resolve, normalize } = require('path'); | ||
|
||
const prefix = chalk`[{magenta Execute}]`; | ||
const errorPrefix = chalk`[{red ERROR}]`; | ||
|
||
let child = null; | ||
|
||
module.exports = async function (args, stats) { | ||
let entry = trim(args.entry); | ||
|
||
if (entry && !entry.endsWith('.js')) { | ||
entry = `${entry}.js`; | ||
} | ||
|
||
let path = ''; | ||
|
||
if (entry && pathExistsSync(`${stats.outputPath}/${entry}`)) { | ||
path = `${stats.outputPath}/${entry}`; | ||
} else if (pathExistsSync(`${stats.outputPath}/index.js`)) { | ||
path = `${stats.outputPath}/index.js`; | ||
} else if (pathExistsSync(`${stats.outputPath}/main.js`)) { | ||
path = `${stats.outputPath}/main.js`; | ||
} else if (pathExistsSync(`${stats.outputPath}/app.js`)) { | ||
path = `${stats.outputPath}/app.js`; | ||
} | ||
|
||
if (!path) { | ||
console.log(prefix, errorPrefix, 'Failed to find entry point to be executed!'); | ||
return; | ||
} | ||
|
||
path = normalize(path); | ||
|
||
if (child) { | ||
console.log(prefix, chalk`Restarting script {greenBright.bold ${path}}`); | ||
child.stdin.pause(); | ||
child.kill(); | ||
} else { | ||
console.log(prefix, chalk`Starting script {greenBright.bold ${path}}`); | ||
} | ||
|
||
const arguments = [path]; | ||
|
||
forEach(args, (value, index) => { | ||
if (index !== '_' && index !== '$0') { | ||
arguments.push(`--${index}=${value}`); | ||
} | ||
}); | ||
|
||
child = spawn(args._[0], arguments, { | ||
cwd: resolve(__dirname, '..'), | ||
encoding: 'utf8' | ||
}); | ||
|
||
child.stderr.on('data', (data) => | ||
console.log(prefix, errorPrefix, chalk`{red ${data.toString()}}`) | ||
); | ||
|
||
child.stdout.on('data', (data) => console.log(prefix, data.toString())); | ||
child.on('close', (code) => console.log(prefix, `Process closed with code ${code}`)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.