chore: 去掉一些lerna 项目中不需要的文件

This commit is contained in:
牧毅 2021-12-20 17:07:38 +08:00
parent 1cd6561497
commit c94a4fb1df
9 changed files with 2 additions and 198 deletions

View File

@ -1,13 +0,0 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
quote_type = single
[*.md]
trim_trailing_whitespace = false

View File

@ -1,16 +0,0 @@
# 忽略目录
node_modules/
build/
dist/
test-cases/
test/
tests/
output/
es/
lib/
coverage/
# 忽略文件
**/*.min.js
**/*-min.js
**/*.bundle.js

View File

@ -1,8 +0,0 @@
module.exports = {
extends: 'eslint-config-ali/typescript/react',
rules: {
'max-len': ['error', { code: 200 }],
'function-paren-newline': 'off',
'@typescript-eslint/indent': 'off',
},
};

View File

@ -1,13 +0,0 @@
{
"assets": {
"type": "command",
"command": {
"cmd": [
"tnpm install",
"node scripts/fixDefVersion ./package.json",
"tnpm run build",
"node scripts/move-files-to-build-dest"
]
}
}
}

View File

@ -1,3 +0,0 @@
module.exports = {
extends: ['ali'],
};

View File

@ -1,9 +0,0 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transformIgnorePatterns: ['/node_modules/(?!core-js)/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!**/node_modules/**', '!**/vendor/**'],
testMatch: ['<rootDir>/tests/**/*.test.ts'],
};

View File

@ -1,80 +0,0 @@
#!/usr/bin/env node
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-require-imports */
// @ts-check - check the types to avoid silly mistakes
// This is a script to fix the version in package.json during DEF publishing.
// Test this file:
//
// $ BUILD_GIT_BRANCH=release/1.1.3 BUILD_ARGV_STR=--def_publish_env=daily node scripts/fixDefVersion ./package.json
// --> should fix the package.json version to 1.1.3-beta.xxxx
//
// $ BUILD_GIT_BRANCH=release/1.1.3 BUILD_ARGV_STR=--def_publish_env=prod node scripts/fixDefVersion ./package.json
// --> should fix the package.json version to 1.1.3
const fs = require('fs');
const moment = require('moment');
const program = require('commander');
const parseArgs = require('yargs-parser');
program
.description('Fix version for def publishing TNPM packages')
.option('--no-beta', 'no beta version', false)
.arguments('package.json file path (only one is needed)')
.parse(process.argv);
try {
const packageJsonFilePath = program.args[0];
if (!packageJsonFilePath) {
program.help();
process.exit(2);
}
const destVersion = fixVersion({
packageJsonFilePath,
env: process.env,
beta: program.opts().beta,
});
console.log(`Fixed version to: ${destVersion}`);
} catch (err) {
console.error('Got error: ', err);
process.exit(1);
}
function fixVersion({ packageJsonFilePath, env = process.env, beta = true }) {
if (!env.BUILD_GIT_BRANCH) {
throw new Error('env.BUILD_GIT_BRANCH is required');
}
if (!env.BUILD_ARGV_STR) {
throw new Error('env.BUILD_ARGV_STR is required');
}
const gitBranchVersion = parseBuildBranchVersion(env.BUILD_GIT_BRANCH);
const buildArgs = parseArgs(env.BUILD_ARGV_STR);
const buildEnv = buildArgs.def_publish_env; // daily | prod
const destVersion =
buildEnv === 'prod' || !beta
? gitBranchVersion
: `${gitBranchVersion}-beta.${moment().format('MMDDHHmm').replace(/^0+/, '')}`;
const packageJson = JSON.parse(fs.readFileSync(packageJsonFilePath, 'utf-8'));
packageJson.version = destVersion;
if (env.BUILD_GIT_COMMITID) {
packageJson.gitHead = env.BUILD_GIT_COMMITID;
}
fs.writeFileSync(packageJsonFilePath, `${JSON.stringify(packageJson, null, 2)}\n`, {
encoding: 'utf8',
});
return destVersion;
}
function parseBuildBranchVersion(branchName) {
const m = `${branchName}`.match(/\d+\.\d+\.\d+/);
return (m && m[0]) || '';
}

View File

@ -1,24 +0,0 @@
/* eslint-disable @typescript-eslint/no-require-imports */
const fs = require('fs');
const { spawnSync } = require('child_process');
const BUILD_DEST = process.env.BUILD_DEST || '.package';
fs.mkdirSync(BUILD_DEST, { recursive: true });
const distFiles = [...require('../package.json').files, 'package.json'];
distFiles.forEach((file) => {
console.log('mv %s', file);
if (file === BUILD_DEST) {
fs.mkdirSync(`${BUILD_DEST}/${file}`, { recursive: true });
spawnSync('mv', [`${file}/*`, `${BUILD_DEST}/${file}/`], { shell: true, stdio: 'inherit' });
}
});
distFiles.forEach((file) => {
console.log('mv %s', file);
if (file !== BUILD_DEST) {
spawnSync('mv', [file, `${BUILD_DEST}/${file}`], { shell: true, stdio: 'inherit' });
}
});

View File

@ -1,37 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"lib": ["ES6", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020"],
// Target latest version of ECMAScript.
"target": "es5",
// Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.
"module": "commonjs",
// Search under node_modules for non-relative imports.
"moduleResolution": "node",
// Enable strictest settings like strictNullChecks & noImplicitAny.
"strict": true,
"strictPropertyInitialization": false,
// Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
"allowSyntheticDefaultImports": true,
// Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'.
"esModuleInterop": true,
// Import emit helpers (e.g. __extends, __rest, etc..) from tslib
"importHelpers": true,
// Enables experimental support for ES7 decorators.
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
// Generates corresponding .map file.
"sourceMap": true,
// Disallow inconsistently-cased references to the same file.
"forceConsistentCasingInFileNames": true,
// Allow json import
"resolveJsonModule": true,
// skip type checking of declaration files
"skipLibCheck": true,
"types": ["jest", "node"],
"baseUrl": "." /* Base directory to resolve non-absolute module names. */,
"outDir": "lib"
},
"include": ["src/**/*"],
"exclude": ["**/test", "**/lib", "**/es", "node_modules"]
"include": ["./src/"]
}