@oinone/kunlun-compile 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import e from"fs";import s from"path";import t from"@rollup/plugin-commonjs";import i from"@rollup/plugin-json";import r from"@rollup/plugin-node-resolve";import n from"@rollup/plugin-replace";import u from"@rollup/plugin-terser";import o from"@rollup/plugin-typescript";import p from"rollup-plugin-copy";import l from"rollup-plugin-scss";import c from"rollup-plugin-sourcemaps";import a from"rollup-plugin-typescript2";import d from"rollup-plugin-vue";function h(e,s,t,i){return new(t||(t=Promise))(function(r,n){function u(e){try{p(i.next(e))}catch(e){n(e)}}function o(e){try{p(i.throw(e))}catch(e){n(e)}}function p(e){var s;e.done?r(e.value):(s=e.value,s instanceof t?s:new t(function(e){e(s)})).then(u,o)}p((i=i.apply(e,s||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class m{static config(e){const s=new m;return s._debug=e,s}prefix(e,s="oinone-"){const t=e.replace("@","").replace("/","-"),i=t.substring(s.length),r=t.replace(/-(\w)/g,(e,s)=>s.toUpperCase());return this._libraryName=t,this._pathName=i,this._camelCaseName=r,this}get libraryName(){return this._libraryName}set libraryName(e){this._libraryName=e}setLibraryName(e){return this._libraryName=e,this}get pathName(){return this._pathName}set pathName(e){this._pathName=e}setPathName(e){return this._pathName=e,this}get camelCaseName(){return this._camelCaseName}set camelCaseName(e){this._camelCaseName=e}setCamelCaseName(e){return this._camelCaseName=e,this}get isDebug(){return!!this._debug}external(e){return Array.isArray(e)?this._external=[/node_modules/,...e]:this._external=[/node_modules/,e],this}singleModule(){return this._pluginBuilder=new g(this),this._pluginBuilder}multipleModule(){return this._pluginBuilder=new y(this),this._pluginBuilder}build(e,s){const{_libraryName:t,_external:i}=this;return{input:"index.ts",output:(null==e?void 0:e.outputOverride)||[Object.assign({file:`dist/${t}.esm.js`,format:"esm",sourcemap:!1},null==e?void 0:e.output)],onwarn(e){"THIS_IS_UNDEFINED"===e.code||/Circular/.test(e.message)||console.error(e.message)},preserveSymlinks:!1,makeAbsoluteExternalsRelative:"ifRelativeSource",external:i,plugins:s}}}class _{constructor(e){this.defaultTypescriptCompilerOptions={outDir:"dist",declaration:!0,declarationDir:"dist/types",moduleResolution:"Bundler",incremental:!1,sourceMap:!1},this._builder=e}get libraryName(){return this._builder.libraryName}get pathName(){return this._builder.pathName}get camelCaseName(){return this._builder.camelCaseName}replace(e=!0){return this.$$setPluginOptions(e=>this._replace=e,e,{"process.env.NODE_ENV":JSON.stringify("development"),preventAssignment:!0,__VUE_OPTIONS_API__:!0,__VUE_PROD_DEVTOOLS__:!1,__VUE_PROD_HYDRATION_MISMATCH_DETAILS__:!1})}scss(e=!0){const{libraryName:s}=this._builder;return this.$$setPluginOptions(e=>this._scss=e,e,{fileName:`${s}.scss`,output:"dist",sourceMap:!1,outputStyle:"compressed"})}vue(e=!0){return this.$$setPluginOptions(e=>this._vue=e,e,{})}nodeResolve(e=!0){return this.$$setPluginOptions(e=>this._nodeResolve=e,e,{})}commonjs(e=!0){return this.$$setPluginOptions(e=>this._commonjs=e,e,{})}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{})}typescript2(e=!0){return this.$$setPluginOptions(e=>this._typescript2=e,e,{})}json(e=!0){return this.$$setPluginOptions(e=>this._json=e,e,{})}terser(e=!0){return this.$$setPluginOptions(e=>this._terser=e,e,{})}sourcemaps(e=!0){return this.$$setPluginOptions(e=>this._sourcemaps=e,e,{})}copy(e=!0){return this.$$setPluginOptions(e=>this._copy=e,e,{})}copyTypeFiles(t,i){this._plugins||(this._plugins=[]);const r=p({hook:"writeBundle",targets:[{src:`dist/types/${t}`,dest:"dist/types"}]}),n=process.cwd(),u=[];return Array.isArray(i)?u.push(...i.map(e=>s.resolve(n,`dist/types/${e}`))):u.push(s.resolve(n,`dist/types/${i}`)),this._plugins.push({name:"copy-and-delete-type-files",hook:"writeBundle",writeBundle:()=>h(this,void 0,void 0,function*(){var s;yield null===(s=r.writeBundle)||void 0===s?void 0:s.call(r);for(const s of u)e.existsSync(s)&&e.statSync(s).isDirectory()&&e.rm(s,{recursive:!0,force:!0},()=>{})})}),this}plugins(e){return this._plugins||(this._plugins=[]),Array.isArray(e)?this._plugins.push(...e):this._plugins.push(e),this}$$setPluginOptions(e,s,t){return(e=e.bind(this))("boolean"==typeof s?s?Object.assign({},t):void 0:Object.assign(Object.assign({},t),s)),this}build(e){return this._builder.build(e,this.buildPlugins())}buildPlugins(){const{_replace:e,_scss:s,_vue:h,_nodeResolve:m,_commonjs:_,_typescript:g,_typescript2:y,_json:f,_copy:b,_terser:O,_sourcemaps:$,_plugins:N}=this,v=[];return e&&v.push(n(e)),h&&v.push(d(h)),m&&v.push(r(m)),_&&v.push(t(_)),s&&v.push(l(s)),y?v.push(a(y)):g&&v.push(o(g)),f&&v.push(i(f)),O&&v.push(u(O)),$&&v.push(c($)),b&&v.push(p(b)),N&&v.push(...N),v}}class g extends _{constructor(e){super(e)}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["**/__tests__/**/*.ts"]})}typescript2(e=!0){const t=s.resolve(process.cwd(),"./");let i={};return this._builder.isDebug&&(i={clean:!0,abortOnError:!1}),this.$$setPluginOptions(e=>this._typescript2=e,e,Object.assign(Object.assign({cwd:t,useTsconfigDeclarationDir:!0},i),{tsconfigOverride:{compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]},include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]}))}}class y extends _{constructor(e){super(e)}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{tsconfig:"../../tsconfig.json",compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["node_modules","**/__tests__/**/*.ts"]})}typescript2(e=!0){const t=s.resolve(process.cwd(),"../../"),i=`packages/${this._builder.pathName}`;let r={};return this._builder.isDebug&&(r={clean:!0,abortOnError:!1}),this.$$setPluginOptions(e=>this._typescript2=e,e,Object.assign(Object.assign({cwd:t,useTsconfigDeclarationDir:!0},r),{tsconfigOverride:{compilerOptions:Object.assign(Object.assign({},this.defaultTypescriptCompilerOptions),{outDir:`${i}/dist`,declarationDir:`${i}/dist/types`}),include:[`${i}/index.ts`,`${i}/src/**/*.ts`],exclude:["**/node_modules/**/*","**/__tests__/**/*"]},include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]}))}}const f=({pkg:e,prefix:s="oinone-kunlun-",includeExternal:t,excludeExternal:i,hasVue:r=!0,hasSCSS:n=!0,ugly:u=!0,keep_classnames:o=!0,extendPlugins:p,outputEntryFiles:l=!1,copyTypeFiles:c,debug:a})=>{const d=[];O(d,Object.keys(e.dependencies||{})),O(d,Object.keys(e.devDependencies||{}));const h=[...new Set([...d,...t||[]]).difference(new Set([...i||[]]))],_=m.config(a).prefix(e.name,s).external(h).multipleModule().replace().nodeResolve().commonjs().json().plugins(p);return r?_.vue().typescript2():_.typescript2(),n&&_.scss(),u&&_.terser({keep_classnames:o}),c&&_.copyTypeFiles(c.typesDir,c.deleteDir),l?_.build({outputOverride:{dir:"dist",entryFileNames:`${_.libraryName}.esm.js`,format:"esm",sourcemap:!1}}):_.build()};function b(e){return e.replace(/[\\^$.*+?|()[\]{}]/g,"\\$&")}function O(e,s){for(const t of s)e.push(t),e.push(new RegExp(`^${b(t)}`))}export{m as default,f as rollupConfig};
@@ -0,0 +1,3 @@
1
+ import { CompileConfigBuilder, rollupConfig } from './src';
2
+ export { rollupConfig };
3
+ export default CompileConfigBuilder;
@@ -0,0 +1,97 @@
1
+ import { type RollupCommonJSOptions } from '@rollup/plugin-commonjs';
2
+ import { type RollupJsonOptions } from '@rollup/plugin-json';
3
+ import { type RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
4
+ import { type RollupReplaceOptions } from '@rollup/plugin-replace';
5
+ import { type Options as RollupTerserPluginOptions } from '@rollup/plugin-terser';
6
+ import { type RollupTypescriptPluginOptions } from '@rollup/plugin-typescript';
7
+ import { type RollupOptions, type OutputOptions as RollupOutputOptions, type Plugin as RollupPlugin } from 'rollup';
8
+ import { type CopyOptions as RollupCopyPluginOptions } from 'rollup-plugin-copy';
9
+ import { type CSSPluginOptions as SCSSPluginOptions } from 'rollup-plugin-scss';
10
+ import { type SourcemapsPluginOptions } from 'rollup-plugin-sourcemaps';
11
+ import { type RPT2Options as RollupTypescript2PluginOptions } from 'rollup-plugin-typescript2';
12
+ import { type Options as VuePluginOptions } from 'rollup-plugin-vue';
13
+ type RollupExternalType = string | RegExp | ((id: string) => boolean);
14
+ type RollupExternalTypes = RollupExternalType | RollupExternalType[];
15
+ type RollupBuildOptions = {
16
+ debug?: boolean;
17
+ output?: RollupOutputOptions;
18
+ outputOverride?: RollupOutputOptions | RollupOutputOptions[];
19
+ };
20
+ export declare class CompileConfigBuilder {
21
+ private _debug;
22
+ private _libraryName;
23
+ private _pathName;
24
+ private _camelCaseName;
25
+ private _external;
26
+ private _pluginBuilder;
27
+ static config(debug?: boolean): CompileConfigBuilder;
28
+ prefix(packageJsonName: string, prefix?: string): CompileConfigBuilder;
29
+ get libraryName(): string | undefined;
30
+ set libraryName(val: string);
31
+ setLibraryName(val: string): CompileConfigBuilder;
32
+ get pathName(): string | undefined;
33
+ set pathName(val: string | undefined);
34
+ setPathName(val: string | undefined): CompileConfigBuilder;
35
+ get camelCaseName(): string | undefined;
36
+ set camelCaseName(val: string | undefined);
37
+ setCamelCaseName(val: string | undefined): CompileConfigBuilder;
38
+ get isDebug(): boolean;
39
+ external(val: RollupExternalTypes): CompileConfigBuilder;
40
+ singleModule(): RollupSingleModulePluginBuilder;
41
+ multipleModule(): RollupMultipleModulePluginBuilder;
42
+ build(options?: RollupBuildOptions, plugins?: RollupPlugin[]): RollupOptions;
43
+ }
44
+ declare class AbstractPluginBuilder {
45
+ protected readonly _builder: CompileConfigBuilder;
46
+ protected constructor(builder: CompileConfigBuilder);
47
+ protected _replace: RollupReplaceOptions | undefined;
48
+ protected _scss: SCSSPluginOptions | undefined;
49
+ protected _vue: VuePluginOptions | undefined;
50
+ protected _nodeResolve: RollupNodeResolveOptions | undefined;
51
+ protected _commonjs: RollupCommonJSOptions | undefined;
52
+ protected _typescript: RollupTypescriptPluginOptions | undefined;
53
+ protected _typescript2: RollupTypescript2PluginOptions | undefined;
54
+ protected _json: RollupJsonOptions | undefined;
55
+ protected _copy: RollupCopyPluginOptions | undefined;
56
+ protected _terser: RollupTerserPluginOptions | undefined;
57
+ protected _sourcemaps: SourcemapsPluginOptions | undefined;
58
+ protected _plugins: RollupPlugin[] | undefined;
59
+ get libraryName(): string | undefined;
60
+ get pathName(): string | undefined;
61
+ get camelCaseName(): string | undefined;
62
+ replace(config?: boolean | RollupReplaceOptions): typeof this;
63
+ scss(config?: boolean | SCSSPluginOptions): typeof this;
64
+ vue(config?: boolean | Partial<VuePluginOptions>): typeof this;
65
+ nodeResolve(config?: boolean | RollupNodeResolveOptions): typeof this;
66
+ commonjs(config?: boolean | RollupCommonJSOptions): typeof this;
67
+ typescript(config?: boolean | RollupTypescriptPluginOptions): typeof this;
68
+ typescript2(config?: boolean | RollupTypescript2PluginOptions): typeof this;
69
+ json(config?: boolean | RollupJsonOptions): typeof this;
70
+ terser(config?: boolean | RollupTerserPluginOptions): typeof this;
71
+ sourcemaps(config?: boolean | SourcemapsPluginOptions): typeof this;
72
+ copy(config?: boolean | RollupCopyPluginOptions): typeof this;
73
+ copyTypeFiles(typesDir: string, deleteDir: string | string[]): typeof this;
74
+ plugins(val: RollupPlugin | RollupPlugin[]): this;
75
+ protected $$setPluginOptions<V>(setter: (val: V | undefined) => void, config: boolean | V, defaultConfig: V): typeof this;
76
+ build(options?: RollupBuildOptions): RollupOptions;
77
+ protected defaultTypescriptCompilerOptions: {
78
+ outDir: string;
79
+ declaration: boolean;
80
+ declarationDir: string;
81
+ moduleResolution: string;
82
+ incremental: boolean;
83
+ sourceMap: boolean;
84
+ };
85
+ private buildPlugins;
86
+ }
87
+ declare class RollupSingleModulePluginBuilder extends AbstractPluginBuilder {
88
+ constructor(builder: CompileConfigBuilder);
89
+ typescript(val?: boolean | RollupTypescriptPluginOptions): typeof this;
90
+ typescript2(val?: boolean | RollupTypescript2PluginOptions): typeof this;
91
+ }
92
+ declare class RollupMultipleModulePluginBuilder extends AbstractPluginBuilder {
93
+ constructor(builder: CompileConfigBuilder);
94
+ typescript(config?: boolean | RollupTypescriptPluginOptions): typeof this;
95
+ typescript2(config?: boolean | RollupTypescript2PluginOptions): typeof this;
96
+ }
97
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './builder';
2
+ export * from './quick-builder';
@@ -0,0 +1,25 @@
1
+ import type { Plugin as RollupPlugin } from 'rollup';
2
+ interface QuickBuilderOptions {
3
+ pkg: {
4
+ name: string;
5
+ version: string;
6
+ dependencies?: Record<string, unknown>;
7
+ devDependencies?: Record<string, unknown>;
8
+ };
9
+ prefix?: string;
10
+ includeExternal?: string[];
11
+ excludeExternal?: string[];
12
+ hasVue?: boolean;
13
+ hasSCSS?: boolean;
14
+ ugly?: boolean;
15
+ keep_classnames?: boolean;
16
+ extendPlugins?: RollupPlugin[];
17
+ outputEntryFiles?: boolean;
18
+ copyTypeFiles?: {
19
+ typesDir: string;
20
+ deleteDir: string | string[];
21
+ };
22
+ debug?: boolean;
23
+ }
24
+ export declare const rollupConfig: ({ pkg, prefix, includeExternal, excludeExternal, hasVue, hasSCSS, ugly, keep_classnames, extendPlugins, outputEntryFiles, copyTypeFiles, debug }: QuickBuilderOptions) => import("rollup").RollupOptions;
25
+ export {};
@@ -0,0 +1,29 @@
1
+ const common = {
2
+ name: 'oinone/common-rules',
3
+ files: ['**/*.{ts,mts,tsx,vue}'],
4
+ rules: {
5
+ '@typescript-eslint/no-explicit-any': 'warn',
6
+ '@typescript-eslint/no-duplicate-enum-values': 'warn',
7
+ '@typescript-eslint/no-unused-expressions': 'warn',
8
+ '@typescript-eslint/no-unused-vars': 'warn',
9
+ 'prefer-rest-params': 'warn',
10
+ 'vue/no-unused-components': 'warn',
11
+ 'vue/multi-word-component-names': 'warn',
12
+ 'vue/block-lang': 'warn',
13
+ 'vue/no-reserved-component-names': 'warn',
14
+ 'vue/no-unused-vars': 'warn',
15
+ 'vue/require-v-for-key': 'warn',
16
+ 'vue/valid-next-tick': 'warn',
17
+ 'vue/valid-v-for': 'warn',
18
+ 'vue/valid-v-on': 'warn',
19
+
20
+ '@typescript-eslint/no-namespace': 'off',
21
+ '@typescript-eslint/no-unsafe-function-type': 'off',
22
+ '@typescript-eslint/no-wrapper-object-types': 'off',
23
+ 'vue/no-dupe-keys': 'off',
24
+ 'vue/no-mutating-props': 'off',
25
+ 'vue/prefer-import-from-vue': 'off'
26
+ }
27
+ };
28
+
29
+ export default common;
@@ -0,0 +1,50 @@
1
+ import pluginImport from 'eslint-plugin-import';
2
+ import pluginUnusedImports from 'eslint-plugin-unused-imports';
3
+
4
+ const importExportRules = {
5
+ name: 'oinone/import-export-rules',
6
+ plugins: {
7
+ import: pluginImport,
8
+ unusedImports: pluginUnusedImports
9
+ },
10
+ settings: {
11
+ 'import/resolver': {
12
+ typescript: true,
13
+ node: true
14
+ }
15
+ },
16
+ rules: {
17
+ 'import/no-duplicates': 'error',
18
+ 'import/newline-after-import': [
19
+ 'error',
20
+ {
21
+ count: 1,
22
+ exactCount: false,
23
+ considerComments: true
24
+ }
25
+ ],
26
+ 'import/order': [
27
+ 'error',
28
+ {
29
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
30
+ 'newlines-between': 'never',
31
+ alphabetize: {
32
+ order: 'asc',
33
+ caseInsensitive: true
34
+ }
35
+ }
36
+ ],
37
+ 'sort-imports': [
38
+ 'error',
39
+ {
40
+ ignoreCase: true,
41
+ ignoreDeclarationSort: true,
42
+ ignoreMemberSort: false,
43
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single']
44
+ }
45
+ ],
46
+ 'unusedImports/no-unused-imports': 'error'
47
+ }
48
+ };
49
+
50
+ export default importExportRules;
@@ -0,0 +1,9 @@
1
+ import common from './common.cjs';
2
+ import importExportRules from './importExportRules.cjs';
3
+
4
+ const pluginOinone = {
5
+ common,
6
+ importExportRules
7
+ };
8
+
9
+ export default pluginOinone;
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@oinone/kunlun-compile",
3
+ "version": "7.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.min.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "scripts": {
8
+ "prebuild": "rimraf dist node_modules/.cache",
9
+ "build": "rollup -c",
10
+ "deploy": "npm publish --exact"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "eslint",
15
+ "scripts",
16
+ "tsconfig"
17
+ ],
18
+ "dependencies": {
19
+ "@commitlint/cli": "20.2.0",
20
+ "@commitlint/config-conventional": "20.2.0",
21
+ "@playwright/test": "1.57.0",
22
+ "@rollup/plugin-commonjs": "29.0.0",
23
+ "@rollup/plugin-json": "6.1.0",
24
+ "@rollup/plugin-node-resolve": "16.0.3",
25
+ "@rollup/plugin-replace": "6.0.3",
26
+ "@rollup/plugin-terser": "0.4.4",
27
+ "@rollup/plugin-typescript": "12.3.0",
28
+ "@types/node": "24.10.4",
29
+ "@typescript-eslint/eslint-plugin": "8.50.0",
30
+ "@typescript-eslint/parser": "8.50.0",
31
+ "@vue/eslint-config-typescript": "14.6.0",
32
+ "@vue/compiler-sfc": "3.5.26",
33
+ "esbuild": "0.27.2",
34
+ "eslint": "9.39.2",
35
+ "eslint-config-prettier": "10.1.8",
36
+ "eslint-import-resolver-typescript": "4.4.4",
37
+ "eslint-plugin-import": "2.32.0",
38
+ "eslint-plugin-prettier": "5.5.4",
39
+ "eslint-plugin-unused-imports": "4.3.0",
40
+ "eslint-plugin-vue": "10.5.1",
41
+ "husky": "9.1.7",
42
+ "jiti": "2.6.1",
43
+ "lerna": "9.0.3",
44
+ "less": "4.5.1",
45
+ "less-loader": "12.3.0",
46
+ "lint-staged": "10.4.2",
47
+ "playwright": "1.57.0",
48
+ "postcss": "8.5.6",
49
+ "postcss-pxtorem": "6.1.0",
50
+ "prettier": "3.6.2",
51
+ "rimraf": "6.1.2",
52
+ "rollup": "4.53.5",
53
+ "rollup-plugin-copy": "3.4.0",
54
+ "rollup-plugin-esbuild": "6.2.1",
55
+ "rollup-plugin-postcss": "4.0.2",
56
+ "rollup-plugin-scss": "4.0.1",
57
+ "rollup-plugin-sourcemaps": "0.6.3",
58
+ "rollup-plugin-typescript2": "0.36.0",
59
+ "rollup-plugin-visualizer": "6.0.5",
60
+ "rollup-plugin-vue": "6.0.0",
61
+ "sass": "1.97.0",
62
+ "sass-loader": "16.0.6",
63
+ "tslib": "2.8.1",
64
+ "typescript": "5.9.3",
65
+ "vue-eslint-parser": "10.2.0",
66
+ "vue-tsc": "3.1.8"
67
+ }
68
+ }
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ const logger = console;
4
+
5
+ const { execSync } = require('child_process');
6
+ const fs = require('fs');
7
+
8
+ const fieldNames = execSync('git diff --name-only --cached')
9
+ .toString('utf8')
10
+ .trim()
11
+ .split('\n')
12
+ .filter((name) => name && !name.startsWith('scripts/') && !name.includes('__tests__/') && fs.existsSync(name));
13
+
14
+ const checkKeyword = (content) => {
15
+ // 字符串的debugger 不需要处理
16
+ if (content.includes(`'debugger'`)) {
17
+ return false;
18
+ }
19
+
20
+ if (content.includes(`debugger`)) {
21
+ return true;
22
+ }
23
+
24
+ if (content.includes(`console.log`)) {
25
+ return true;
26
+ }
27
+
28
+ if (content.includes(`alert(`)) {
29
+ return true;
30
+ }
31
+
32
+ return false;
33
+ };
34
+
35
+ for (let index = 0; index < fieldNames.length; index++) {
36
+ const path = fieldNames[index];
37
+ const field = fs
38
+ .readFileSync(path, {
39
+ encoding: 'utf-8'
40
+ })
41
+ .toString()
42
+ .trim();
43
+
44
+ if (checkKeyword(field)) {
45
+ logger.log('\x1B[31m%s\x1B[0m', `${path} 文件存在 ['debugger', 'console.log', 'alert'],请删除后再提交.`);
46
+ process.exit(1);
47
+ break;
48
+ }
49
+ }
@@ -0,0 +1,13 @@
1
+ /* eslint-disable import/no-dynamic-require */
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const url = path.resolve(process.cwd(), 'package.json');
6
+ const packageJSON = require(url);
7
+
8
+ packageJSON.main = 'index.ts';
9
+ delete packageJSON.module;
10
+ delete packageJSON.typings;
11
+ delete packageJSON.files;
12
+
13
+ fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2) + '\n');
@@ -0,0 +1,24 @@
1
+ /* eslint-disable import/no-dynamic-require */
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const url = path.resolve(process.cwd(), 'package.json');
6
+ const packageJSON = require(url);
7
+
8
+ const libName = packageJSON.name.replace('@', '').replace('/', '-');
9
+
10
+ packageJSON.main = `dist/${libName}.esm.js`;
11
+ packageJSON.module = `dist/${libName}.esm.js`;
12
+ const typings = 'dist/types/index.d.ts';
13
+ packageJSON.typings = typings;
14
+
15
+ const typingsUrl = path.resolve(process.cwd(), typings);
16
+ const dir = fs.existsSync(typingsUrl);
17
+
18
+ if (!dir) {
19
+ packageJSON.typings = 'dist/index.d.ts';
20
+ }
21
+
22
+ packageJSON.files = ['dist', 'index.ts', 'src'];
23
+
24
+ fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2));
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "experimentalDecorators": true,
4
+ "emitDecoratorMetadata": true,
5
+ "allowJs": true,
6
+ "target": "ES6",
7
+ "module": "esnext",
8
+ "strict": true,
9
+ "importHelpers": true,
10
+ "moduleResolution": "node",
11
+ "esModuleInterop": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "sourceMap": true,
14
+ "skipLibCheck": true,
15
+ "baseUrl": ".",
16
+ "paths": {},
17
+ "lib": ["ES2020", "ESNext", "DOM", "DOM.Iterable", "ScriptHost"],
18
+ "noImplicitAny": false,
19
+ "incremental": true,
20
+ "resolveJsonModule": true
21
+ },
22
+ "include": ["packages", "eslint.config.ts"],
23
+ "exclude": ["node_modules", "dist"]
24
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "experimentalDecorators": true,
4
+ "emitDecoratorMetadata": true,
5
+ "allowJs": true,
6
+ "target": "ES6",
7
+ "module": "esnext",
8
+ "strict": true,
9
+ "importHelpers": true,
10
+ "moduleResolution": "node",
11
+ "esModuleInterop": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "sourceMap": true,
14
+ "skipLibCheck": true,
15
+ "baseUrl": ".",
16
+ "paths": {},
17
+ "lib": ["ES2020", "ESNext", "DOM", "DOM.Iterable", "ScriptHost"],
18
+ "noImplicitAny": false,
19
+ "incremental": true,
20
+ "resolveJsonModule": true
21
+ },
22
+ "include": ["index.ts", "src/**/*.ts", "src/**/*.vue", "eslint.config.ts"],
23
+ "exclude": ["node_modules", "dist"]
24
+ }