@nocobase/build 0.7.0-alpha.56
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.
- package/LICENSE +201 -0
- package/README.md +0 -0
- package/bin/nocobase-build.js +71 -0
- package/lib/babel.js +252 -0
- package/lib/build.js +351 -0
- package/lib/es5ImcompatibleVersions.js +51 -0
- package/lib/getBabelConfig.js +75 -0
- package/lib/getRollupConfig.js +320 -0
- package/lib/getUserConfig.js +99 -0
- package/lib/importLibToEs.js +38 -0
- package/lib/index.js +13 -0
- package/lib/normalizeBundleOpts.js +35 -0
- package/lib/randomColor.js +32 -0
- package/lib/registerBabel.js +38 -0
- package/lib/rollup.js +144 -0
- package/lib/schema.js +213 -0
- package/lib/types.d.js +1 -0
- package/lib/utils/getLernaPackages/index.js +63 -0
- package/lib/utils/index.js +48 -0
- package/package.json +78 -0
- package/src/babel.ts +257 -0
- package/src/build.ts +260 -0
- package/src/es5ImcompatibleVersions.ts +33 -0
- package/src/getBabelConfig.ts +95 -0
- package/src/getRollupConfig.ts +343 -0
- package/src/getUserConfig.ts +87 -0
- package/src/importLibToEs.js +26 -0
- package/src/index.ts +3 -0
- package/src/normalizeBundleOpts.ts +24 -0
- package/src/randomColor.ts +34 -0
- package/src/registerBabel.ts +23 -0
- package/src/rollup.ts +77 -0
- package/src/schema.ts +175 -0
- package/src/types.d.ts +118 -0
- package/src/utils/getLernaPackages/fixtures/customize/core/core1/package.json +7 -0
- package/src/utils/getLernaPackages/fixtures/customize/core/core1/src/index.js +2 -0
- package/src/utils/getLernaPackages/fixtures/customize/core/core2/package.json +5 -0
- package/src/utils/getLernaPackages/fixtures/customize/core/core2/src/index.js +2 -0
- package/src/utils/getLernaPackages/fixtures/customize/lerna.json +6 -0
- package/src/utils/getLernaPackages/fixtures/customize/package.json +4 -0
- package/src/utils/getLernaPackages/fixtures/customize/packages/bar/package.json +4 -0
- package/src/utils/getLernaPackages/fixtures/customize/packages/bar/src/index.js +2 -0
- package/src/utils/getLernaPackages/fixtures/customize/packages/foo/package.json +7 -0
- package/src/utils/getLernaPackages/fixtures/customize/packages/foo/src/index.js +2 -0
- package/src/utils/getLernaPackages/fixtures/default/lerna.json +1 -0
- package/src/utils/getLernaPackages/fixtures/default/package.json +4 -0
- package/src/utils/getLernaPackages/fixtures/default/packages/bar/package.json +4 -0
- package/src/utils/getLernaPackages/fixtures/default/packages/bar/src/index.js +2 -0
- package/src/utils/getLernaPackages/fixtures/default/packages/foo/package.json +7 -0
- package/src/utils/getLernaPackages/fixtures/default/packages/foo/src/index.js +2 -0
- package/src/utils/getLernaPackages/index.ts +57 -0
- package/src/utils/index.ts +13 -0
- package/template/tsconfig.json +23 -0
package/src/schema.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
const noEmptyStr = { type: 'string', minLength: 1 };
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
type: 'object',
|
|
5
|
+
additionalProperties: false,
|
|
6
|
+
properties: {
|
|
7
|
+
entry: {
|
|
8
|
+
oneOf: [noEmptyStr, { type: 'array', items: noEmptyStr }],
|
|
9
|
+
},
|
|
10
|
+
file: { type: 'string' },
|
|
11
|
+
esm: {
|
|
12
|
+
oneOf: [
|
|
13
|
+
noEmptyStr,
|
|
14
|
+
{ type: 'boolean' },
|
|
15
|
+
{
|
|
16
|
+
type: 'object',
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
properties: {
|
|
19
|
+
type: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
pattern: '^(rollup|babel)$',
|
|
22
|
+
},
|
|
23
|
+
file: noEmptyStr,
|
|
24
|
+
mjs: { type: 'boolean' },
|
|
25
|
+
minify: { type: 'boolean' },
|
|
26
|
+
importLibToEs: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
},
|
|
29
|
+
dir: noEmptyStr
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
cjs: {
|
|
35
|
+
oneOf: [
|
|
36
|
+
noEmptyStr,
|
|
37
|
+
{ type: 'boolean' },
|
|
38
|
+
{
|
|
39
|
+
type: 'object',
|
|
40
|
+
additionalProperties: false,
|
|
41
|
+
properties: {
|
|
42
|
+
type: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
pattern: '^(rollup|babel)$',
|
|
45
|
+
},
|
|
46
|
+
file: noEmptyStr,
|
|
47
|
+
minify: { type: 'boolean' },
|
|
48
|
+
lazy: { type: 'boolean' },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
umd: {
|
|
54
|
+
oneOf: [
|
|
55
|
+
{ type: 'boolean' },
|
|
56
|
+
{
|
|
57
|
+
type: 'object',
|
|
58
|
+
additionalProperties: false,
|
|
59
|
+
properties: {
|
|
60
|
+
globals: { type: 'object' },
|
|
61
|
+
file: noEmptyStr,
|
|
62
|
+
name: noEmptyStr,
|
|
63
|
+
minFile: { type: 'boolean' },
|
|
64
|
+
sourcemap: {
|
|
65
|
+
oneOf: [
|
|
66
|
+
{ type: 'boolean' },
|
|
67
|
+
{ type: 'string', pattern: '^(inline|hidden)$', },
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
extraBabelPlugins: {
|
|
75
|
+
type: 'array',
|
|
76
|
+
},
|
|
77
|
+
extraBabelPresets: {
|
|
78
|
+
type: 'array',
|
|
79
|
+
},
|
|
80
|
+
extraPostCSSPlugins: {
|
|
81
|
+
type: 'array',
|
|
82
|
+
},
|
|
83
|
+
extraRollupPlugins: {
|
|
84
|
+
type: 'array',
|
|
85
|
+
},
|
|
86
|
+
extraExternals: {
|
|
87
|
+
type: 'array',
|
|
88
|
+
},
|
|
89
|
+
externalsExclude: {
|
|
90
|
+
type: 'array',
|
|
91
|
+
},
|
|
92
|
+
cssModules: {
|
|
93
|
+
oneOf: [{ type: 'boolean' }, { type: 'object' }],
|
|
94
|
+
},
|
|
95
|
+
extractCSS: {
|
|
96
|
+
type: 'boolean',
|
|
97
|
+
},
|
|
98
|
+
injectCSS: {
|
|
99
|
+
oneOf: [{ type: 'boolean' }, { instanceof: 'Function' }],
|
|
100
|
+
},
|
|
101
|
+
autoprefixer: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
},
|
|
104
|
+
include: {
|
|
105
|
+
oneOf: [
|
|
106
|
+
{ type: 'string' },
|
|
107
|
+
{ type: 'object' },
|
|
108
|
+
{ type: 'array' },
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
runtimeHelpers: {
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
},
|
|
114
|
+
overridesByEntry: {
|
|
115
|
+
type: 'object',
|
|
116
|
+
},
|
|
117
|
+
nodeResolveOpts: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
},
|
|
120
|
+
target: noEmptyStr,
|
|
121
|
+
doc: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
},
|
|
124
|
+
replace: {
|
|
125
|
+
type: 'object',
|
|
126
|
+
},
|
|
127
|
+
inject: {
|
|
128
|
+
type: 'object',
|
|
129
|
+
},
|
|
130
|
+
lessInRollupMode: {
|
|
131
|
+
type: 'object'
|
|
132
|
+
},
|
|
133
|
+
sassInRollupMode: {
|
|
134
|
+
type: 'object'
|
|
135
|
+
},
|
|
136
|
+
lessInBabelMode: {
|
|
137
|
+
oneOf: [
|
|
138
|
+
{ type: 'boolean' },
|
|
139
|
+
{ type: 'object' },
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
browserFiles: {
|
|
143
|
+
type: 'array',
|
|
144
|
+
},
|
|
145
|
+
nodeFiles: {
|
|
146
|
+
type: 'array',
|
|
147
|
+
},
|
|
148
|
+
nodeVersion: {
|
|
149
|
+
type: 'number',
|
|
150
|
+
},
|
|
151
|
+
disableTypeCheck: {
|
|
152
|
+
type: 'boolean',
|
|
153
|
+
},
|
|
154
|
+
preCommit: {
|
|
155
|
+
type: 'object',
|
|
156
|
+
additionalProperties: false,
|
|
157
|
+
properties: {
|
|
158
|
+
eslint: { type: 'boolean' },
|
|
159
|
+
prettier: { type: 'boolean' },
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
typescriptOpts: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
},
|
|
165
|
+
pkgs: {
|
|
166
|
+
type: 'array',
|
|
167
|
+
},
|
|
168
|
+
excludePkgs: {
|
|
169
|
+
type: 'array',
|
|
170
|
+
},
|
|
171
|
+
pkgFilter: {
|
|
172
|
+
type: 'object',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
};
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export type BundleType = 'rollup' | 'babel';
|
|
2
|
+
|
|
3
|
+
interface IBundleTypeOutput {
|
|
4
|
+
type: BundleType;
|
|
5
|
+
file?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ICjs extends IBundleTypeOutput {
|
|
9
|
+
minify?: boolean;
|
|
10
|
+
lazy?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface IEsm extends IBundleTypeOutput {
|
|
14
|
+
mjs?: boolean;
|
|
15
|
+
minify?: boolean;
|
|
16
|
+
importLibToEs?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface IStringObject {
|
|
20
|
+
[prop: string]: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface IUmd {
|
|
24
|
+
globals?: IStringObject;
|
|
25
|
+
name?: string;
|
|
26
|
+
minFile?: boolean;
|
|
27
|
+
file?: string;
|
|
28
|
+
sourcemap?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface IBundleOptions {
|
|
32
|
+
entry?: string | string[];
|
|
33
|
+
file?: string;
|
|
34
|
+
esm?: BundleType | IEsm | false;
|
|
35
|
+
cjs?: BundleType | ICjs | false;
|
|
36
|
+
umd?: IUmd | false;
|
|
37
|
+
extraBabelPlugins?: any[];
|
|
38
|
+
extraBabelPresets?: any[];
|
|
39
|
+
extraPostCSSPlugins?: any[];
|
|
40
|
+
extraRollupPlugins?: any[];
|
|
41
|
+
extraExternals?: string[];
|
|
42
|
+
externalsExclude?: string[];
|
|
43
|
+
cssModules?: boolean | Object;
|
|
44
|
+
extractCSS?: boolean;
|
|
45
|
+
injectCSS?: boolean | ((varname: string, filename: string) => string);
|
|
46
|
+
inject?: Object;
|
|
47
|
+
autoprefixer?: Object;
|
|
48
|
+
include?: string | RegExp;
|
|
49
|
+
runtimeHelpers?: boolean;
|
|
50
|
+
target?: 'node' | 'browser';
|
|
51
|
+
overridesByEntry?: {
|
|
52
|
+
[entry: string]: any;
|
|
53
|
+
};
|
|
54
|
+
replace?: {
|
|
55
|
+
[value: string]: any;
|
|
56
|
+
};
|
|
57
|
+
browserFiles?: {
|
|
58
|
+
[value: string]: any;
|
|
59
|
+
};
|
|
60
|
+
nodeFiles?: {
|
|
61
|
+
[value: string]: any;
|
|
62
|
+
};
|
|
63
|
+
nodeVersion?: number;
|
|
64
|
+
disableTypeCheck?: boolean;
|
|
65
|
+
preCommit?: {
|
|
66
|
+
eslint?: boolean;
|
|
67
|
+
prettier?: boolean;
|
|
68
|
+
};
|
|
69
|
+
lessInBabelMode?:
|
|
70
|
+
| boolean
|
|
71
|
+
| {
|
|
72
|
+
paths?: any[];
|
|
73
|
+
plugins?: any[];
|
|
74
|
+
};
|
|
75
|
+
typescriptOpts?: {
|
|
76
|
+
[value: string]: any;
|
|
77
|
+
};
|
|
78
|
+
nodeResolveOpts?: {
|
|
79
|
+
[value: string]: any;
|
|
80
|
+
};
|
|
81
|
+
lessInRollupMode?: {
|
|
82
|
+
[opt: string]: any;
|
|
83
|
+
};
|
|
84
|
+
sassInRollupMode?: {
|
|
85
|
+
[opt: string]: any;
|
|
86
|
+
};
|
|
87
|
+
pkgs?: string[];
|
|
88
|
+
excludePkgs?: string[];
|
|
89
|
+
/** 处理 lerna 包 */
|
|
90
|
+
pkgFilter?: {
|
|
91
|
+
/** 指定包含的包 */
|
|
92
|
+
include?: string[];
|
|
93
|
+
/** 指定排除的包 */
|
|
94
|
+
exclude?: string[];
|
|
95
|
+
/**
|
|
96
|
+
* 跳过私有的包 package.json private
|
|
97
|
+
* @default false
|
|
98
|
+
* */
|
|
99
|
+
skipPrivate?: boolean;
|
|
100
|
+
};
|
|
101
|
+
config?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface IOpts {
|
|
105
|
+
cwd: string;
|
|
106
|
+
watch?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* 构建时清空outputDir
|
|
109
|
+
* @default true
|
|
110
|
+
* */
|
|
111
|
+
clean?: boolean;
|
|
112
|
+
buildArgs?: IBundleOptions;
|
|
113
|
+
rootConfig?: IBundleOptions;
|
|
114
|
+
rootPath?: string;
|
|
115
|
+
packages?: string[];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type Dispose = () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getPackagesSync } from '@lerna/project';
|
|
2
|
+
import { QueryGraph } from '@lerna/query-graph';
|
|
3
|
+
import { filterPackages } from '@lerna/filter-packages';
|
|
4
|
+
|
|
5
|
+
export interface Options {
|
|
6
|
+
/** 指定包含的包 */
|
|
7
|
+
include?: string[];
|
|
8
|
+
/** 指定排除的包 */
|
|
9
|
+
exclude?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* 跳过私有的包
|
|
12
|
+
* @default false
|
|
13
|
+
* */
|
|
14
|
+
skipPrivate?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取lerna项目包集合
|
|
19
|
+
* @param cwd
|
|
20
|
+
*/
|
|
21
|
+
export async function getLernaPackages(cwd: string, ops: Options = {}): Promise<any[]> {
|
|
22
|
+
const {
|
|
23
|
+
include = [],
|
|
24
|
+
exclude = [],
|
|
25
|
+
skipPrivate = false,
|
|
26
|
+
} = ops;
|
|
27
|
+
|
|
28
|
+
const allPkgs = getPackagesSync(cwd) ?? [];
|
|
29
|
+
|
|
30
|
+
const pkgs = filterPackages(allPkgs, include, exclude, !skipPrivate, true);
|
|
31
|
+
|
|
32
|
+
return await getStreamPackages(pkgs);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getStreamPackages(pkgs: any[]): Promise<any[]> {
|
|
36
|
+
const graph = new QueryGraph(pkgs, 'allDependencies', true);
|
|
37
|
+
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
const returnValues: any[] = [];
|
|
40
|
+
|
|
41
|
+
const queueNextAvailablePackages = () =>
|
|
42
|
+
graph.getAvailablePackages()
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
.forEach(({ pkg, name }) => {
|
|
45
|
+
graph.markAsTaken(name);
|
|
46
|
+
|
|
47
|
+
Promise.resolve(pkg)
|
|
48
|
+
.then((value) => returnValues.push(value))
|
|
49
|
+
.then(() => graph.markAsDone(pkg))
|
|
50
|
+
.then(() => queueNextAvailablePackages())
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
queueNextAvailablePackages();
|
|
54
|
+
|
|
55
|
+
setTimeout(() => { resolve(returnValues); }, 0);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
export function getExistFile({ cwd, files, returnRelative }) {
|
|
5
|
+
for (const file of files) {
|
|
6
|
+
const absFilePath = join(cwd, file);
|
|
7
|
+
if (existsSync(absFilePath)) {
|
|
8
|
+
return returnRelative ? file : absFilePath;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { getLernaPackages } from './getLernaPackages';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowSyntheticDefaultImports": true,
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"target": "esnext",
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"jsx": "react"
|
|
9
|
+
},
|
|
10
|
+
"include": ["./src", "./typings/"],
|
|
11
|
+
"typings": "./typings/index.d.ts",
|
|
12
|
+
"exclude": [
|
|
13
|
+
"node_modules",
|
|
14
|
+
"build",
|
|
15
|
+
"scripts",
|
|
16
|
+
"acceptance-tests",
|
|
17
|
+
"webpack",
|
|
18
|
+
"jest",
|
|
19
|
+
"src/setupTests.ts",
|
|
20
|
+
"tslint:latest",
|
|
21
|
+
"tslint-config-prettier"
|
|
22
|
+
]
|
|
23
|
+
}
|