oak-domain 6.1.0 → 6.1.2
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/es/base-app-domain/ActionDefDict.d.ts +1 -0
- package/es/base-app-domain/ActionDefDict.js +3 -1
- package/es/base-app-domain/EntityDict.d.ts +86 -1
- package/es/base-app-domain/Log/Storage.js +4 -0
- package/es/base-app-domain/Log/_baseSchema.d.ts +5 -0
- package/es/base-app-domain/Storage.js +3 -1
- package/es/base-app-domain/StyleDict.js +3 -1
- package/es/base-app-domain/Version/Action.d.ts +6 -0
- package/es/base-app-domain/Version/Action.js +2 -0
- package/es/base-app-domain/Version/Schema.d.ts +19 -0
- package/es/base-app-domain/Version/Schema.js +1 -0
- package/es/base-app-domain/Version/Storage.d.ts +3 -0
- package/es/base-app-domain/Version/Storage.js +54 -0
- package/es/base-app-domain/Version/Style.d.ts +3 -0
- package/es/base-app-domain/Version/Style.js +6 -0
- package/es/base-app-domain/Version/_baseSchema.d.ts +57 -0
- package/es/base-app-domain/Version/_baseSchema.js +1 -0
- package/es/compiler/dependencyBuilder.d.ts +1 -0
- package/es/compiler/dependencyBuilder.js +173 -55
- package/es/compiler/routerBuilder.d.ts +4 -1
- package/es/compiler/routerBuilder.js +22 -19
- package/es/compiler/schemaBuilder.d.ts +5 -1
- package/es/compiler/schemaBuilder.js +10 -0
- package/es/context/BackendRuntimeContext.d.ts +9 -1
- package/es/context/BackendRuntimeContext.js +13 -1
- package/es/entities/Log.d.ts +2 -0
- package/es/entities/Log.js +2 -0
- package/es/entities/Version.d.ts +14 -0
- package/es/entities/Version.js +42 -0
- package/es/store/AsyncRowStore.d.ts +4 -1
- package/es/store/AsyncRowStore.js +7 -0
- package/es/store/CascadeStore.js +22 -0
- package/es/store/RelationAuth/authorizationFilter.d.ts +11 -0
- package/es/store/RelationAuth/authorizationFilter.js +104 -0
- package/es/store/RelationAuth/continuation.d.ts +9 -0
- package/es/store/RelationAuth/continuation.js +33 -0
- package/es/store/RelationAuth/index.d.ts +141 -0
- package/es/store/RelationAuth/index.js +1440 -0
- package/es/store/RelationAuth/model.d.ts +38 -0
- package/es/store/RelationAuth/model.js +24 -0
- package/es/store/RelationAuth/userLookup.d.ts +21 -0
- package/es/store/RelationAuth/userLookup.js +102 -0
- package/es/store/SyncRowStore.d.ts +2 -1
- package/es/store/SyncRowStore.js +3 -0
- package/es/store/filter.fix.d.ts +128 -0
- package/es/store/filter.fix.js +2862 -0
- package/es/store/filter.js +14 -9
- package/es/store/triggers.js +239 -44
- package/es/types/Context.d.ts +2 -1
- package/es/types/Demand.d.ts +11 -1
- package/es/types/Environment.d.ts +13 -2
- package/es/types/Exception.d.ts +3 -3
- package/es/types/Exception.js +25 -22
- package/es/types/Expression.d.ts +4 -1
- package/es/types/Expression.js +1 -1
- package/es/types/Storage.d.ts +15 -2
- package/es/utils/SimpleConnector.js +5 -2
- package/es/utils/decimal.js +2 -1
- package/es/utils/fetch/index.ali.d.ts +3 -0
- package/es/utils/fetch/index.ali.js +31 -0
- package/es/utils/fetch/index.d.ts +3 -0
- package/es/utils/fetch/index.js +5 -0
- package/es/utils/fetch/index.mp.d.ts +5 -3
- package/es/utils/fetch/index.mp.js +5 -280
- package/es/utils/fetch/index.wechat.d.ts +5 -0
- package/es/utils/fetch/index.wechat.js +174 -0
- package/es/utils/fetch/mini-program.shared.d.ts +37 -0
- package/es/utils/fetch/mini-program.shared.js +85 -0
- package/es/utils/geo.d.ts +1 -1
- package/es/utils/geo.js +1 -1
- package/es/utils/random/random.ali.d.ts +6 -0
- package/es/utils/random/random.ali.js +21 -0
- package/es/utils/random/random.mp.d.ts +5 -1
- package/es/utils/random/random.mp.js +11 -5
- package/es/utils/random/random.native.d.ts +1 -1
- package/es/utils/random/random.native.js +7 -4
- package/es/utils/random/random.wechat.d.ts +1 -0
- package/es/utils/random/random.wechat.js +10 -0
- package/lib/base-app-domain/ActionDefDict.d.ts +1 -0
- package/lib/base-app-domain/ActionDefDict.js +3 -1
- package/lib/base-app-domain/EntityDict.d.ts +86 -1
- package/lib/base-app-domain/Log/Storage.js +4 -0
- package/lib/base-app-domain/Log/_baseSchema.d.ts +5 -0
- package/lib/base-app-domain/Storage.js +3 -1
- package/lib/base-app-domain/StyleDict.js +3 -1
- package/lib/base-app-domain/Version/Action.d.ts +6 -0
- package/lib/base-app-domain/Version/Action.js +5 -0
- package/lib/base-app-domain/Version/Schema.d.ts +19 -0
- package/lib/base-app-domain/Version/Schema.js +4 -0
- package/lib/base-app-domain/Version/Storage.d.ts +3 -0
- package/lib/base-app-domain/Version/Storage.js +57 -0
- package/lib/base-app-domain/Version/Style.d.ts +3 -0
- package/lib/base-app-domain/Version/Style.js +9 -0
- package/lib/base-app-domain/Version/_baseSchema.d.ts +57 -0
- package/lib/base-app-domain/Version/_baseSchema.js +2 -0
- package/lib/compiler/dependencyBuilder.d.ts +1 -0
- package/lib/compiler/dependencyBuilder.js +173 -54
- package/lib/compiler/routerBuilder.d.ts +4 -1
- package/lib/compiler/routerBuilder.js +22 -19
- package/lib/compiler/schemaBuilder.d.ts +5 -1
- package/lib/compiler/schemaBuilder.js +10 -0
- package/lib/context/BackendRuntimeContext.d.ts +9 -1
- package/lib/context/BackendRuntimeContext.js +13 -1
- package/lib/entities/Log.d.ts +2 -0
- package/lib/entities/Log.js +2 -0
- package/lib/entities/Version.d.ts +14 -0
- package/lib/entities/Version.js +43 -0
- package/lib/store/AsyncRowStore.d.ts +4 -1
- package/lib/store/AsyncRowStore.js +7 -0
- package/lib/store/CascadeStore.js +22 -0
- package/lib/store/RelationAuth/authorizationFilter.d.ts +11 -0
- package/lib/store/RelationAuth/authorizationFilter.js +110 -0
- package/lib/store/RelationAuth/continuation.d.ts +9 -0
- package/lib/store/RelationAuth/continuation.js +37 -0
- package/lib/store/RelationAuth/index.d.ts +141 -0
- package/lib/store/RelationAuth/index.js +1445 -0
- package/lib/store/RelationAuth/model.d.ts +38 -0
- package/lib/store/RelationAuth/model.js +27 -0
- package/lib/store/RelationAuth/userLookup.d.ts +21 -0
- package/lib/store/RelationAuth/userLookup.js +105 -0
- package/lib/store/SyncRowStore.d.ts +2 -1
- package/lib/store/SyncRowStore.js +3 -0
- package/lib/store/filter.fix.d.ts +128 -0
- package/lib/store/filter.fix.js +2876 -0
- package/lib/store/filter.js +14 -9
- package/lib/store/triggers.js +239 -44
- package/lib/types/Context.d.ts +2 -1
- package/lib/types/Demand.d.ts +11 -1
- package/lib/types/Environment.d.ts +13 -2
- package/lib/types/Exception.d.ts +3 -3
- package/lib/types/Exception.js +25 -22
- package/lib/types/Expression.d.ts +4 -1
- package/lib/types/Expression.js +1 -1
- package/lib/types/Storage.d.ts +15 -2
- package/lib/utils/SimpleConnector.js +5 -2
- package/lib/utils/decimal.js +2 -1
- package/lib/utils/fetch/index.ali.d.ts +3 -0
- package/lib/utils/fetch/index.ali.js +36 -0
- package/lib/utils/fetch/index.d.ts +3 -0
- package/lib/utils/fetch/index.js +7 -0
- package/lib/utils/fetch/index.mp.d.ts +5 -3
- package/lib/utils/fetch/index.mp.js +5 -282
- package/lib/utils/fetch/index.wechat.d.ts +5 -0
- package/lib/utils/fetch/index.wechat.js +180 -0
- package/lib/utils/fetch/mini-program.shared.d.ts +37 -0
- package/lib/utils/fetch/mini-program.shared.js +96 -0
- package/lib/utils/geo.d.ts +1 -1
- package/lib/utils/geo.js +1 -1
- package/lib/utils/random/random.ali.d.ts +6 -0
- package/lib/utils/random/random.ali.js +24 -0
- package/lib/utils/random/random.mp.d.ts +5 -1
- package/lib/utils/random/random.mp.js +11 -5
- package/lib/utils/random/random.native.d.ts +1 -1
- package/lib/utils/random/random.native.js +7 -5
- package/lib/utils/random/random.wechat.d.ts +1 -0
- package/lib/utils/random/random.wechat.js +13 -0
- package/package.json +8 -5
- package/es/store/RelationAuth.d.ts +0 -115
- package/es/store/RelationAuth.js +0 -1340
- package/lib/store/RelationAuth.d.ts +0 -115
- package/lib/store/RelationAuth.js +0 -1345
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ForeignKey } from "../../types/DataType";
|
|
2
|
+
import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "../../types/Demand";
|
|
3
|
+
import { MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
|
4
|
+
import { Action, ParticularAction } from "./Action";
|
|
5
|
+
import { String } from "../../types/DataType";
|
|
6
|
+
export type OpSchema = EntityShape & {
|
|
7
|
+
entity: String<32>;
|
|
8
|
+
entityId: String<64>;
|
|
9
|
+
name: String<128>;
|
|
10
|
+
operatorId?: ForeignKey<"user"> | null;
|
|
11
|
+
logId?: ForeignKey<"log"> | null;
|
|
12
|
+
iState: "normal" | "rollbacked";
|
|
13
|
+
} & {
|
|
14
|
+
[A in ExpressionKey]?: any;
|
|
15
|
+
};
|
|
16
|
+
export type OpAttr = keyof OpSchema;
|
|
17
|
+
export type OpFilter = {
|
|
18
|
+
id: Q_StringValue;
|
|
19
|
+
$$createAt$$: Q_DateValue;
|
|
20
|
+
$$seq$$: Q_NumberValue;
|
|
21
|
+
$$updateAt$$: Q_DateValue;
|
|
22
|
+
entity: Q_StringValue;
|
|
23
|
+
entityId: Q_StringValue;
|
|
24
|
+
name: Q_StringValue;
|
|
25
|
+
operatorId: Q_StringValue;
|
|
26
|
+
logId: Q_StringValue;
|
|
27
|
+
iState: Q_EnumValue<"normal" | "rollbacked">;
|
|
28
|
+
} & ExprOp<OpAttr | string>;
|
|
29
|
+
export type OpProjection = {
|
|
30
|
+
"#id"?: NodeId;
|
|
31
|
+
[k: string]: any;
|
|
32
|
+
id?: number;
|
|
33
|
+
$$createAt$$?: number;
|
|
34
|
+
$$updateAt$$?: number;
|
|
35
|
+
$$seq$$?: number;
|
|
36
|
+
entity?: number;
|
|
37
|
+
entityId?: number;
|
|
38
|
+
name?: number;
|
|
39
|
+
operatorId?: number;
|
|
40
|
+
logId?: number;
|
|
41
|
+
iState?: number;
|
|
42
|
+
} & Partial<ExprOp<OpAttr | string>>;
|
|
43
|
+
export type OpSortAttr = Partial<{
|
|
44
|
+
id: number;
|
|
45
|
+
$$createAt$$: number;
|
|
46
|
+
$$seq$$: number;
|
|
47
|
+
$$updateAt$$: number;
|
|
48
|
+
entity: number;
|
|
49
|
+
entityId: number;
|
|
50
|
+
name: number;
|
|
51
|
+
operatorId: number;
|
|
52
|
+
logId: number;
|
|
53
|
+
iState: number;
|
|
54
|
+
[k: string]: any;
|
|
55
|
+
} | ExprOp<OpAttr | string>>;
|
|
56
|
+
export type OpAction = OakMakeAction<Action | string>;
|
|
57
|
+
export type OpUpdateAction = "update" | ParticularAction | string;
|
|
@@ -27,6 +27,7 @@ export declare function writeContextCompositionFiles(cwd: string, isModule: bool
|
|
|
27
27
|
export declare function renderFeatureIndexSource(dependencies: string[], briefNames: string[], sourceFile: ts.SourceFile, isModule: boolean, printer?: ts.Printer): string;
|
|
28
28
|
export declare function renderInitializeFeaturesSource(cwd: string, dependencies: string[], briefNames: string[], sourceFile: ts.SourceFile, printer?: ts.Printer): string;
|
|
29
29
|
export declare function resolveDependencyTemplateFile(cwd: string, dependencies: string[], templateFileName: string, fallback: string): string;
|
|
30
|
+
export declare function renderSystemEntitySource(dependencies: string[], cwd: string): string | undefined;
|
|
30
31
|
export declare function initializeDependencyTemplates(cwd?: string, rebuild?: boolean): string[];
|
|
31
32
|
/**
|
|
32
33
|
* 本函数用于构建src/initialize.dev, src/initialize.prod, src/initializeFeatures, src/context/FrontendContext, src/contextBackendContext
|
|
@@ -9,6 +9,7 @@ exports.writeContextCompositionFiles = writeContextCompositionFiles;
|
|
|
9
9
|
exports.renderFeatureIndexSource = renderFeatureIndexSource;
|
|
10
10
|
exports.renderInitializeFeaturesSource = renderInitializeFeaturesSource;
|
|
11
11
|
exports.resolveDependencyTemplateFile = resolveDependencyTemplateFile;
|
|
12
|
+
exports.renderSystemEntitySource = renderSystemEntitySource;
|
|
12
13
|
exports.initializeDependencyTemplates = initializeDependencyTemplates;
|
|
13
14
|
exports.default = buildDependency;
|
|
14
15
|
const tslib_1 = require("tslib");
|
|
@@ -25,11 +26,30 @@ const PROJECT_NAME_PLACEHOLDER = '__OAK_PROJECT_NAME__';
|
|
|
25
26
|
function uniqueDependencies(dependencies) {
|
|
26
27
|
return Array.from(new Set(dependencies.filter((dep) => !!dep)));
|
|
27
28
|
}
|
|
29
|
+
function resolveInstalledPackageDir(fromDir, packageName) {
|
|
30
|
+
let currentDir = fromDir;
|
|
31
|
+
while (true) {
|
|
32
|
+
const packageDir = join(currentDir, 'node_modules', packageName);
|
|
33
|
+
if ((0, fs_1.existsSync)(join(packageDir, 'package.json'))) {
|
|
34
|
+
return packageDir;
|
|
35
|
+
}
|
|
36
|
+
const parentDir = (0, path_1.dirname)(currentDir);
|
|
37
|
+
if (parentDir === currentDir) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
currentDir = parentDir;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function writeGeneratedFile(filename, content) {
|
|
44
|
+
(0, fs_extra_1.mkdirSync)((0, path_1.dirname)(filename), { recursive: true });
|
|
45
|
+
(0, fs_1.writeFileSync)(filename, content, { flag: 'w' });
|
|
46
|
+
}
|
|
28
47
|
function readInstalledPackageManifest(dir, packageName) {
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
48
|
+
const packageDir = resolveInstalledPackageDir(dir, packageName);
|
|
49
|
+
if (!packageDir) {
|
|
31
50
|
return undefined;
|
|
32
51
|
}
|
|
52
|
+
const packageJsonPath = join(packageDir, 'package.json');
|
|
33
53
|
return JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
|
|
34
54
|
}
|
|
35
55
|
function readDependencyConfiguration(dir) {
|
|
@@ -56,10 +76,11 @@ function collectInstalledOakLibDependencies(dir) {
|
|
|
56
76
|
...Object.keys(packageJson.devDependencies || {}),
|
|
57
77
|
]).sort((left, right) => left.localeCompare(right));
|
|
58
78
|
return dependencyNames.filter((dep) => {
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
79
|
+
const packageDir = resolveInstalledPackageDir(dir, dep);
|
|
80
|
+
if (!packageDir) {
|
|
61
81
|
return false;
|
|
62
82
|
}
|
|
83
|
+
const manifestPath = join(packageDir, 'package.json');
|
|
63
84
|
const dependencyManifest = JSON.parse((0, fs_1.readFileSync)(manifestPath, 'utf-8'));
|
|
64
85
|
return (0, OakPackage_1.isOakBusinessModule)(dependencyManifest);
|
|
65
86
|
});
|
|
@@ -156,12 +177,10 @@ function analyzeDepedency(cwd) {
|
|
|
156
177
|
depGraph.dependencies[name][dep] = 1;
|
|
157
178
|
}
|
|
158
179
|
if (!depGraph.nodes[dep]) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
throw new Error(`找不到依赖包${dep}的安装位置,当前包是${dir}`);
|
|
164
|
-
}
|
|
180
|
+
const dir2 = resolveInstalledPackageDir(dir, dep)
|
|
181
|
+
|| resolveInstalledPackageDir(cwd, dep);
|
|
182
|
+
if (!dir2) {
|
|
183
|
+
throw new Error(`找不到依赖包${dep}的安装位置,当前包是${dir}`);
|
|
165
184
|
}
|
|
166
185
|
analyzeOne(dir2, dep);
|
|
167
186
|
}
|
|
@@ -295,7 +314,7 @@ function outputPolyfillDts(dependencies, briefNames, sourceFile, printer, filena
|
|
|
295
314
|
statements2 = [...sourceFile.statements];
|
|
296
315
|
}
|
|
297
316
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
298
|
-
(
|
|
317
|
+
writeGeneratedFile(filename, result);
|
|
299
318
|
console.log(`构建${filename}文件成功`);
|
|
300
319
|
}
|
|
301
320
|
function outputDependentExceptions(dependencies, briefNames, sourceFile, printer, filename, isModule) {
|
|
@@ -337,7 +356,7 @@ function outputDependentExceptions(dependencies, briefNames, sourceFile, printer
|
|
|
337
356
|
});
|
|
338
357
|
}
|
|
339
358
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
340
|
-
(
|
|
359
|
+
writeGeneratedFile(filename, result);
|
|
341
360
|
console.log(`构建${filename}文件成功`);
|
|
342
361
|
}
|
|
343
362
|
function outputRuntimeCxt(dependencies, briefNames, sourceFile, printer, filename) {
|
|
@@ -395,7 +414,7 @@ function outputRuntimeCxt(dependencies, briefNames, sourceFile, printer, filenam
|
|
|
395
414
|
];
|
|
396
415
|
}
|
|
397
416
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
398
|
-
(
|
|
417
|
+
writeGeneratedFile(filename, result);
|
|
399
418
|
console.log(`构建${filename}文件成功`);
|
|
400
419
|
}
|
|
401
420
|
function outputContext(depGraph, sourceFile, printer, filename) {
|
|
@@ -413,11 +432,14 @@ function outputContext(depGraph, sourceFile, printer, filename) {
|
|
|
413
432
|
...statements
|
|
414
433
|
];
|
|
415
434
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
416
|
-
(
|
|
435
|
+
writeGeneratedFile(filename, result);
|
|
417
436
|
console.log(`构建${filename}文件成功`);
|
|
418
437
|
}
|
|
419
438
|
function hasRuntimeContextEntry(cwd, dependency, target) {
|
|
420
|
-
const dependencyDir =
|
|
439
|
+
const dependencyDir = resolveInstalledPackageDir(cwd, dependency);
|
|
440
|
+
if (!dependencyDir) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
421
443
|
const fileName = `${target}RuntimeContext`;
|
|
422
444
|
return [
|
|
423
445
|
join(dependencyDir, 'src', 'context', `${fileName}.ts`),
|
|
@@ -511,7 +533,7 @@ export default ${generatedName};
|
|
|
511
533
|
}
|
|
512
534
|
function outputGeneratedContext(cwd, target, isModule) {
|
|
513
535
|
const fileName = join(cwd, 'src', 'context', `generated${target}.ts`);
|
|
514
|
-
(
|
|
536
|
+
writeGeneratedFile(fileName, renderGeneratedContextSource(cwd, target, isModule));
|
|
515
537
|
console.log(`构建${fileName}文件成功`);
|
|
516
538
|
}
|
|
517
539
|
function outputProjectContextShell(templateFile, targetFile) {
|
|
@@ -519,7 +541,7 @@ function outputProjectContextShell(templateFile, targetFile) {
|
|
|
519
541
|
console.log(`[${targetFile}]文件已经存在,保留项目自定义上下文。`);
|
|
520
542
|
return;
|
|
521
543
|
}
|
|
522
|
-
(
|
|
544
|
+
writeGeneratedFile(targetFile, (0, fs_1.readFileSync)(templateFile, 'utf-8'));
|
|
523
545
|
console.log(`构建${targetFile}文件成功`);
|
|
524
546
|
}
|
|
525
547
|
function writeContextCompositionFiles(cwd, isModule, templates) {
|
|
@@ -546,9 +568,9 @@ function outputIntializeProd(cwd, dependencies, briefNames, sourceFile, printer,
|
|
|
546
568
|
// 所有的import
|
|
547
569
|
const importStatements = [];
|
|
548
570
|
dependencies.forEach((dep, idx) => {
|
|
549
|
-
const depDir =
|
|
550
|
-
if (!
|
|
551
|
-
throw new Error(`依赖模块${dep}
|
|
571
|
+
const depDir = resolveInstalledPackageDir(cwd, dep);
|
|
572
|
+
if (!depDir) {
|
|
573
|
+
throw new Error(`依赖模块${dep}未能找到相应的安装目录`);
|
|
552
574
|
}
|
|
553
575
|
const esDir = join(depDir, 'es');
|
|
554
576
|
const libDir = join(depDir, 'lib');
|
|
@@ -657,7 +679,7 @@ function outputIntializeProd(cwd, dependencies, briefNames, sourceFile, printer,
|
|
|
657
679
|
});
|
|
658
680
|
}
|
|
659
681
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
660
|
-
(
|
|
682
|
+
writeGeneratedFile(filename, result);
|
|
661
683
|
console.log(`构建${filename}文件成功`);
|
|
662
684
|
}
|
|
663
685
|
/**
|
|
@@ -674,9 +696,9 @@ function outputIntializeDev(cwd, dependencies, briefNames, sourceFile, printer,
|
|
|
674
696
|
// 所有的import
|
|
675
697
|
const importStatements = [];
|
|
676
698
|
dependencies.forEach((dep, idx) => {
|
|
677
|
-
const depDir =
|
|
678
|
-
if (!
|
|
679
|
-
throw new Error(`依赖模块${dep}
|
|
699
|
+
const depDir = resolveInstalledPackageDir(cwd, dep);
|
|
700
|
+
if (!depDir) {
|
|
701
|
+
throw new Error(`依赖模块${dep}未能找到相应的安装目录`);
|
|
680
702
|
}
|
|
681
703
|
const esDir = join(depDir, 'es');
|
|
682
704
|
const libDir = join(depDir, 'lib');
|
|
@@ -806,7 +828,7 @@ function outputIntializeDev(cwd, dependencies, briefNames, sourceFile, printer,
|
|
|
806
828
|
});
|
|
807
829
|
}
|
|
808
830
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
809
|
-
(
|
|
831
|
+
writeGeneratedFile(filename, result);
|
|
810
832
|
console.log(`构建${filename}文件成功`);
|
|
811
833
|
}
|
|
812
834
|
function renderFeatureIndexSource(dependencies, briefNames, sourceFile, isModule, printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed })) {
|
|
@@ -880,12 +902,12 @@ function renderFeatureIndexSource(dependencies, briefNames, sourceFile, isModule
|
|
|
880
902
|
*/
|
|
881
903
|
function outputFeatureIndex(dependencies, briefNames, sourceFile, printer, filename, isModule) {
|
|
882
904
|
const result = renderFeatureIndexSource(dependencies, briefNames, sourceFile, isModule, printer);
|
|
883
|
-
(
|
|
905
|
+
writeGeneratedFile(filename, result);
|
|
884
906
|
console.log(`构建${filename}文件成功`);
|
|
885
907
|
}
|
|
886
908
|
function outputIntializeFeatures(cwd, dependencies, briefNames, sourceFile, printer, filename) {
|
|
887
909
|
const result = renderInitializeFeaturesSource(cwd, dependencies, briefNames, sourceFile, printer);
|
|
888
|
-
(
|
|
910
|
+
writeGeneratedFile(filename, result);
|
|
889
911
|
console.log(`构建${filename}文件成功`);
|
|
890
912
|
}
|
|
891
913
|
function renderInitializeFeaturesSource(cwd, dependencies, briefNames, sourceFile, printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed })) {
|
|
@@ -893,9 +915,9 @@ function renderInitializeFeaturesSource(cwd, dependencies, briefNames, sourceFil
|
|
|
893
915
|
const features = [];
|
|
894
916
|
const importStatements = [];
|
|
895
917
|
dependencies.forEach((dep, idx) => {
|
|
896
|
-
const depDir =
|
|
897
|
-
if (!
|
|
898
|
-
throw new Error(`依赖模块${dep}
|
|
918
|
+
const depDir = resolveInstalledPackageDir(cwd, dep);
|
|
919
|
+
if (!depDir) {
|
|
920
|
+
throw new Error(`依赖模块${dep}未能找到相应的安装目录`);
|
|
899
921
|
}
|
|
900
922
|
const esDir = join(depDir, 'es');
|
|
901
923
|
const libDir = join(depDir, 'lib');
|
|
@@ -937,10 +959,15 @@ function renderInitializeFeaturesSource(cwd, dependencies, briefNames, sourceFil
|
|
|
937
959
|
}
|
|
938
960
|
function resolveDependencyTemplateFile(cwd, dependencies, templateFileName, fallback) {
|
|
939
961
|
const rootPlan = resolveDependencyRootPlan(cwd, dependencies);
|
|
940
|
-
const candidates = rootPlan.rootDependencies.map((dependency) =>
|
|
941
|
-
dependency
|
|
942
|
-
|
|
943
|
-
|
|
962
|
+
const candidates = rootPlan.rootDependencies.map((dependency) => {
|
|
963
|
+
const dependencyDir = resolveInstalledPackageDir(cwd, dependency);
|
|
964
|
+
return {
|
|
965
|
+
dependency,
|
|
966
|
+
filePath: dependencyDir
|
|
967
|
+
? join(dependencyDir, 'template', templateFileName)
|
|
968
|
+
: '',
|
|
969
|
+
};
|
|
970
|
+
}).filter(({ filePath }) => (0, fs_1.existsSync)(filePath));
|
|
944
971
|
if (candidates.length > 1) {
|
|
945
972
|
throw new Error(`多个顶层依赖同时提供 template/${templateFileName}:${candidates.map(({ dependency }) => dependency).join(', ')},无法确定使用哪个模板`);
|
|
946
973
|
}
|
|
@@ -949,7 +976,37 @@ function resolveDependencyTemplateFile(cwd, dependencies, templateFileName, fall
|
|
|
949
976
|
function injectDataIndexFile(dataIndexFile, briefNames, printer) {
|
|
950
977
|
const sourceFile = ts.createSourceFile('index.ts', (0, fs_1.readFileSync)(dataIndexFile, 'utf-8'), ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
|
|
951
978
|
const { statements } = sourceFile;
|
|
952
|
-
const
|
|
979
|
+
const existingSpreads = new Set();
|
|
980
|
+
const exportStmt = statements[statements.length - 1];
|
|
981
|
+
(0, assert_1.assert)(ts.isExportAssignment(exportStmt));
|
|
982
|
+
const { expression } = exportStmt;
|
|
983
|
+
(0, assert_1.assert)(ts.isObjectLiteralExpression(expression));
|
|
984
|
+
const { properties } = expression;
|
|
985
|
+
properties.forEach((prop) => {
|
|
986
|
+
if (ts.isSpreadAssignment(prop)) {
|
|
987
|
+
existingSpreads.add(prop.expression.getText());
|
|
988
|
+
}
|
|
989
|
+
});
|
|
990
|
+
// data/index.ts 可能来自项目模板(如 create --template blog 自行 import 了同名数据文件),
|
|
991
|
+
// 注入前按 import 声明与 export 展分别去重,避免注入出重复标识符导致编译失败。
|
|
992
|
+
const injectImports = [];
|
|
993
|
+
const injectSpreads = [];
|
|
994
|
+
briefNames.forEach((ele) => {
|
|
995
|
+
const hasImport = statements.some((stmt) => ts.isImportDeclaration(stmt)
|
|
996
|
+
&& stmt.moduleSpecifier.text === `./${ele}Data`
|
|
997
|
+
&& !!stmt.importClause?.name
|
|
998
|
+
&& stmt.importClause.name.text === `${ele}Data`);
|
|
999
|
+
if (!hasImport) {
|
|
1000
|
+
injectImports.push(ele);
|
|
1001
|
+
}
|
|
1002
|
+
if (!existingSpreads.has(`${ele}Data`)) {
|
|
1003
|
+
injectSpreads.push(ele);
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
if (injectImports.length === 0 && injectSpreads.length === 0) {
|
|
1007
|
+
console.log(`data/index.ts中${briefNames.join('、')}的引用已存在,跳过注入`);
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
953
1010
|
/**
|
|
954
1011
|
* 在文件末尾的这个位置上注入引用
|
|
955
1012
|
export default {
|
|
@@ -960,24 +1017,19 @@ function injectDataIndexFile(dataIndexFile, briefNames, printer) {
|
|
|
960
1017
|
i18n,
|
|
961
1018
|
};
|
|
962
1019
|
*/
|
|
963
|
-
const exportStmt = statements[statements.length - 1];
|
|
964
|
-
(0, assert_1.assert)(ts.isExportAssignment(exportStmt));
|
|
965
|
-
const { expression } = exportStmt;
|
|
966
|
-
(0, assert_1.assert)(ts.isObjectLiteralExpression(expression));
|
|
967
|
-
const { properties } = expression;
|
|
968
1020
|
Object.assign(expression, {
|
|
969
1021
|
properties: [
|
|
970
1022
|
...properties,
|
|
971
|
-
...
|
|
1023
|
+
...injectSpreads.map((ele) => factory.createSpreadAssignment(factory.createIdentifier(`${ele}Data`)))
|
|
972
1024
|
]
|
|
973
1025
|
});
|
|
974
1026
|
const statements2 = [
|
|
975
|
-
...
|
|
1027
|
+
...injectImports.map((ele) => factory.createImportDeclaration(undefined, factory.createImportClause(false, factory.createIdentifier(`${ele}Data`), undefined), factory.createStringLiteral(`./${ele}Data`), undefined)),
|
|
976
1028
|
...statements,
|
|
977
1029
|
];
|
|
978
1030
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
979
|
-
(
|
|
980
|
-
console.log(`注入${dataIndexFile}文件成功,共注入了${
|
|
1031
|
+
writeGeneratedFile(dataIndexFile, result);
|
|
1032
|
+
console.log(`注入${dataIndexFile}文件成功,共注入了${injectImports.length}个 import 与 ${injectSpreads.length} 个 export 引用`);
|
|
981
1033
|
}
|
|
982
1034
|
/**
|
|
983
1035
|
* 将依赖项目的目录去覆盖原来的目录
|
|
@@ -1027,7 +1079,10 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer, rebu
|
|
|
1027
1079
|
const injectDataIndexFileDependencies = [];
|
|
1028
1080
|
const injectDataIndexFileBriefNames = [];
|
|
1029
1081
|
dependencies.forEach((dep, idx) => {
|
|
1030
|
-
const moduleDir =
|
|
1082
|
+
const moduleDir = resolveInstalledPackageDir(cwd, dep);
|
|
1083
|
+
if (!moduleDir) {
|
|
1084
|
+
throw new Error(`依赖模块${dep}未能找到相应的安装目录`);
|
|
1085
|
+
}
|
|
1031
1086
|
const moduleTemplateDir = join(moduleDir, 'template');
|
|
1032
1087
|
if ((0, fs_1.existsSync)(moduleTemplateDir)) {
|
|
1033
1088
|
// data.ts中规定的初始化数据,拷贝到data目录下,并注入到data/index.ts
|
|
@@ -1057,6 +1112,65 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer, rebu
|
|
|
1057
1112
|
injectDataIndexFile(join(cwd, 'src', 'data', 'index.ts'), injectDataIndexFileBriefNames, printer);
|
|
1058
1113
|
}
|
|
1059
1114
|
}
|
|
1115
|
+
function makeSystemAlias(packageName, usedAliases) {
|
|
1116
|
+
const packageBaseName = packageName
|
|
1117
|
+
.replace(/^@/, '')
|
|
1118
|
+
.replace(/[\\/]/g, '-')
|
|
1119
|
+
.split('-')
|
|
1120
|
+
.filter(Boolean)
|
|
1121
|
+
.map((part) => `${part[0].toUpperCase()}${part.slice(1)}`)
|
|
1122
|
+
.join('')
|
|
1123
|
+
.replace(/^Oak/, '')
|
|
1124
|
+
.replace(/Business$/, '') || 'Dependency';
|
|
1125
|
+
const baseAlias = `${packageBaseName}System`;
|
|
1126
|
+
let alias = baseAlias;
|
|
1127
|
+
let index = 2;
|
|
1128
|
+
while (usedAliases.has(alias)) {
|
|
1129
|
+
alias = `${baseAlias}${index}`;
|
|
1130
|
+
index += 1;
|
|
1131
|
+
}
|
|
1132
|
+
usedAliases.add(alias);
|
|
1133
|
+
return alias;
|
|
1134
|
+
}
|
|
1135
|
+
function renderSystemEntitySource(dependencies, cwd) {
|
|
1136
|
+
const usedAliases = new Set();
|
|
1137
|
+
const imports = [];
|
|
1138
|
+
const schemas = [];
|
|
1139
|
+
dependencies.forEach((dependency) => {
|
|
1140
|
+
const dependencyDir = resolveInstalledPackageDir(cwd, dependency);
|
|
1141
|
+
if (!dependencyDir) {
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
const manifestPath = join(dependencyDir, 'package.json');
|
|
1145
|
+
const manifest = JSON.parse((0, fs_1.readFileSync)(manifestPath, 'utf-8'));
|
|
1146
|
+
if (!(0, OakPackage_1.isOakBusinessModule)(manifest)) {
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
const systemDeclaration = join(dependencyDir, 'es', 'entities', 'System.d.ts');
|
|
1150
|
+
if (!(0, fs_1.existsSync)(systemDeclaration)) {
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
const alias = makeSystemAlias(dependency, usedAliases);
|
|
1154
|
+
imports.push(`import { Schema as ${alias} } from '${makeOakImport(dependency, 'entities/System')}';`);
|
|
1155
|
+
schemas.push(alias);
|
|
1156
|
+
});
|
|
1157
|
+
if (schemas.length === 0) {
|
|
1158
|
+
return undefined;
|
|
1159
|
+
}
|
|
1160
|
+
return `${imports.join('\n')}\nimport { EntityDesc } from '@oak-domain/types';\n\nexport interface Schema extends ${schemas.join(', ')} {}\n\nexport type Relation = 'owner' | 'manager';\n\nexport const entityDesc: EntityDesc<Schema, '', Relation> = {\n locales: {\n zh_CN: {\n name: '系统',\n attr: {\n name: '名称',\n description: '描述',\n config: '设置',\n platform: '平台',\n super: '超级系统',\n folder: '代码目录名',\n style: '样式',\n entity: '关联对象',\n entityId: '关联对象id',\n oldestVersion: '最早支持版本',\n },\n r: {\n owner: '所有者',\n manager: '管理员',\n },\n },\n },\n};\n`;
|
|
1161
|
+
}
|
|
1162
|
+
function ensureSystemEntity(cwd, dependencies, rebuild) {
|
|
1163
|
+
const systemFile = join(cwd, 'src', 'entities', 'System.ts');
|
|
1164
|
+
if ((0, fs_1.existsSync)(systemFile) && !rebuild) {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
const source = renderSystemEntitySource(dependencies, cwd);
|
|
1168
|
+
if (!source) {
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
writeGeneratedFile(systemFile, source);
|
|
1172
|
+
console.log(`${rebuild ? '重建' : '生成'}${systemFile}`);
|
|
1173
|
+
}
|
|
1060
1174
|
function resolveDependencyBuildContext(cwd) {
|
|
1061
1175
|
const webDir = join(cwd, 'web');
|
|
1062
1176
|
const isModule = !(0, fs_1.existsSync)(webDir); // 如果没有web目录,说明是module,不需要处理应用模板注入
|
|
@@ -1083,6 +1197,7 @@ function initializeDependencyTemplates(cwd = process.cwd(), rebuild) {
|
|
|
1083
1197
|
}
|
|
1084
1198
|
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
|
|
1085
1199
|
tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer, rebuild);
|
|
1200
|
+
ensureSystemEntity(cwd, dependencies, rebuild);
|
|
1086
1201
|
return dependencies;
|
|
1087
1202
|
}
|
|
1088
1203
|
/**
|
|
@@ -1114,7 +1229,7 @@ function injectInitializeToFeatureIndex(cwd, dependencies, briefNames, printer)
|
|
|
1114
1229
|
], undefined, factory.createBlock([], true))
|
|
1115
1230
|
];
|
|
1116
1231
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
1117
|
-
(
|
|
1232
|
+
writeGeneratedFile(featureIndexFile, result);
|
|
1118
1233
|
console.log(`注入${featureIndexFile}文件成功,用户可以自己修正initialize函数的参数和逻辑`);
|
|
1119
1234
|
}
|
|
1120
1235
|
}
|
|
@@ -1125,19 +1240,23 @@ function injectInitializeToFeatureIndex(cwd, dependencies, briefNames, printer)
|
|
|
1125
1240
|
function buildDependency(rebuild) {
|
|
1126
1241
|
const cwd = process.cwd();
|
|
1127
1242
|
const { depGraph, dependencies, briefNames, isModule, } = resolveDependencyBuildContext(cwd);
|
|
1243
|
+
const oakCliDir = resolveInstalledPackageDir(cwd, env_1.OAK_CLI_MODULE_NAME);
|
|
1244
|
+
if (!oakCliDir) {
|
|
1245
|
+
throw new Error(`找不到依赖包${env_1.OAK_CLI_MODULE_NAME}的安装位置,当前包是${cwd}`);
|
|
1246
|
+
}
|
|
1128
1247
|
const defaultTemplateFiles = {
|
|
1129
|
-
initializeServer: join(
|
|
1130
|
-
initializeFeatures: join(
|
|
1131
|
-
runtimeCxt: join(
|
|
1132
|
-
dependentExceptions: join(
|
|
1133
|
-
polyfillDts: join(
|
|
1134
|
-
featureIndex: join(
|
|
1248
|
+
initializeServer: join(oakCliDir, 'scaffold', 'fragments', 'initialize.server.ts'),
|
|
1249
|
+
initializeFeatures: join(oakCliDir, 'scaffold', 'fragments', 'initializeFeatures.ts'),
|
|
1250
|
+
runtimeCxt: join(oakCliDir, 'scaffold', 'fragments', 'RuntimeCxt.ts'),
|
|
1251
|
+
dependentExceptions: join(oakCliDir, 'scaffold', 'fragments', 'DependentExceptions.ts'),
|
|
1252
|
+
polyfillDts: join(oakCliDir, 'scaffold', 'fragments', 'polyfill.d.ts'),
|
|
1253
|
+
featureIndex: join(oakCliDir, 'scaffold', 'fragments', !isModule && dependencies.length === 0
|
|
1135
1254
|
? 'features/index.standalone.ts'
|
|
1136
1255
|
: 'features/index.ts'),
|
|
1137
|
-
backendRuntimeContext: join(
|
|
1256
|
+
backendRuntimeContext: join(oakCliDir, 'scaffold', 'fragments', dependencies.length === 0
|
|
1138
1257
|
? 'BackendRuntimeContext.standalone.ts'
|
|
1139
1258
|
: 'BackendRuntimeContext.ts'),
|
|
1140
|
-
frontendRuntimeContext: join(
|
|
1259
|
+
frontendRuntimeContext: join(oakCliDir, 'scaffold', 'fragments', dependencies.length === 0
|
|
1141
1260
|
? 'FrontendRuntimeContext.standalone.ts'
|
|
1142
1261
|
: 'FrontendRuntimeContext.ts'),
|
|
1143
1262
|
};
|
|
@@ -24,14 +24,17 @@ type NamespaceConfig = {
|
|
|
24
24
|
params?: Record<string, string>;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
type RouterPlatform = 'web' | 'native' | 'miniProgram' | 'wechatMp';
|
|
27
28
|
type BuildRouterOptions = {
|
|
29
|
+
/** `wechatMp` is retained as a compatibility alias for `miniProgram`. */
|
|
30
|
+
platform: RouterPlatform;
|
|
28
31
|
useOutlet?: boolean;
|
|
29
32
|
onWarning?: (message: string) => void;
|
|
30
33
|
getPageConfig?: (pageDirectoryPath: string) => PageConfig | undefined;
|
|
31
34
|
getNamespaceConfig?: (namespaceDirectoryPath: string, namespace: string) => NamespaceConfig | undefined;
|
|
32
35
|
};
|
|
33
36
|
declare function closeCurrentWatchSession(): void;
|
|
34
|
-
export declare function buildRouter(projectDir: string, startupDir: string, watch
|
|
37
|
+
export declare function buildRouter(projectDir: string, startupDir: string, watch: boolean, options: BuildRouterOptions): {
|
|
35
38
|
close: typeof closeCurrentWatchSession;
|
|
36
39
|
} | undefined;
|
|
37
40
|
export {};
|
|
@@ -17,15 +17,20 @@ const DESKTOP_PAGE_RENDER_FILES = [
|
|
|
17
17
|
'render.macos.tsx',
|
|
18
18
|
'render.linux.tsx',
|
|
19
19
|
];
|
|
20
|
+
const MINI_PROGRAM_PAGE_RENDER_FILES = [
|
|
21
|
+
'index.xml',
|
|
22
|
+
'index.wechat.xml',
|
|
23
|
+
'index.ali.xml',
|
|
24
|
+
];
|
|
20
25
|
const PAGE_RENDER_FILES = [
|
|
21
26
|
...WEB_PAGE_RENDER_FILES,
|
|
22
27
|
...DESKTOP_PAGE_RENDER_FILES,
|
|
23
28
|
'render.native.tsx',
|
|
24
29
|
'render.ios.tsx',
|
|
25
30
|
'render.android.tsx',
|
|
26
|
-
|
|
31
|
+
...MINI_PROGRAM_PAGE_RENDER_FILES,
|
|
27
32
|
];
|
|
28
|
-
const PAGE_WATCH_FILTER = /(?:^|[\\/])(?:web\.tsx|web\.pc\.tsx|web\.mobile\.tsx|index\.json|index\.config\.(?:ts|mts|cts|js|mjs|cjs)|index
|
|
33
|
+
const PAGE_WATCH_FILTER = /(?:^|[\\/])(?:web\.tsx|web\.pc\.tsx|web\.mobile\.tsx|index\.json|index\.config\.(?:ts|mts|cts|js|mjs|cjs)|index(?:\.wechat|\.ali)?\.xml|render\.(?:desktop|windows|macos|linux|native|ios|android)\.tsx)$/;
|
|
29
34
|
const NAMESPACE_WATCH_FILTER = /(?:^|[\\/])(?:index\.json|index\.config\.(?:ts|mts|cts|js|mjs|cjs))$/;
|
|
30
35
|
const VALID_PAGE_DIR_NAME = /^[A-Za-z0-9_-]+$/;
|
|
31
36
|
function normalizePath(path) {
|
|
@@ -49,9 +54,6 @@ function isDesktopRenderProfile() {
|
|
|
49
54
|
return process.env.OAK_RENDER === 'tauri'
|
|
50
55
|
|| process.env.OAK_RENDER === 'electron';
|
|
51
56
|
}
|
|
52
|
-
function isWebStartupDir(startupDir) {
|
|
53
|
-
return startupDir.startsWith('web') || isDesktopRenderProfile();
|
|
54
|
-
}
|
|
55
57
|
function getInvalidPageDirPath(relativePath) {
|
|
56
58
|
const segments = normalizeRelativePath(relativePath).split('/').filter(Boolean);
|
|
57
59
|
const validSegments = [];
|
|
@@ -85,7 +87,7 @@ function hasPageDescChanged(prev, next) {
|
|
|
85
87
|
|| prev.oakDisablePulldownRefresh !== next.oakDisablePulldownRefresh
|
|
86
88
|
|| prev.hasWeb !== next.hasWeb
|
|
87
89
|
|| prev.hasNative !== next.hasNative
|
|
88
|
-
|| prev.
|
|
90
|
+
|| prev.hasMiniProgram !== next.hasMiniProgram
|
|
89
91
|
|| JSON.stringify(prev.access) !== JSON.stringify(next.access);
|
|
90
92
|
}
|
|
91
93
|
function getNamespaceFromFilepath(rootDir, filepath) {
|
|
@@ -115,7 +117,7 @@ function checkPageDir(dir, relativePath, ns, type) {
|
|
|
115
117
|
const subdirs = [];
|
|
116
118
|
let hasNative = false;
|
|
117
119
|
let hasWeb = false;
|
|
118
|
-
let
|
|
120
|
+
let hasMiniProgram = false;
|
|
119
121
|
const files = (0, fs_extra_1.readdirSync)(dir);
|
|
120
122
|
files.forEach((file) => {
|
|
121
123
|
const filepath = (0, path_1.join)(dir, file);
|
|
@@ -129,8 +131,8 @@ function checkPageDir(dir, relativePath, ns, type) {
|
|
|
129
131
|
&& DESKTOP_PAGE_RENDER_FILES.includes(file))) {
|
|
130
132
|
hasWeb = true;
|
|
131
133
|
}
|
|
132
|
-
else if (file
|
|
133
|
-
|
|
134
|
+
else if (MINI_PROGRAM_PAGE_RENDER_FILES.includes(file)) {
|
|
135
|
+
hasMiniProgram = true;
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
else if (stat.isDirectory()) {
|
|
@@ -143,7 +145,7 @@ function checkPageDir(dir, relativePath, ns, type) {
|
|
|
143
145
|
}
|
|
144
146
|
});
|
|
145
147
|
let nextPageDesc;
|
|
146
|
-
if (hasNative || hasWeb ||
|
|
148
|
+
if (hasNative || hasWeb || hasMiniProgram) {
|
|
147
149
|
const indexJsonFile = (0, path_1.join)(dir, 'index.json');
|
|
148
150
|
let oakDisablePulldownRefresh = false;
|
|
149
151
|
let routePath;
|
|
@@ -176,7 +178,7 @@ function checkPageDir(dir, relativePath, ns, type) {
|
|
|
176
178
|
oakDisablePulldownRefresh,
|
|
177
179
|
hasNative,
|
|
178
180
|
hasWeb,
|
|
179
|
-
|
|
181
|
+
hasMiniProgram,
|
|
180
182
|
access,
|
|
181
183
|
};
|
|
182
184
|
}
|
|
@@ -551,7 +553,7 @@ function makeWebAllRouters(namespaceDir, projectDir, routerFileDir, options) {
|
|
|
551
553
|
oakDisablePulldownRefresh: false,
|
|
552
554
|
hasWeb: true,
|
|
553
555
|
hasNative: false,
|
|
554
|
-
|
|
556
|
+
hasMiniProgram: false,
|
|
555
557
|
};
|
|
556
558
|
children.push(factory.createObjectLiteralExpression([
|
|
557
559
|
factory.createPropertyAssignment('path', factory.createStringLiteral('*')),
|
|
@@ -748,7 +750,7 @@ function watchDir(projectDir, startupDir, type) {
|
|
|
748
750
|
BuildRouterContext.watchHandles.push(handle);
|
|
749
751
|
}
|
|
750
752
|
};
|
|
751
|
-
if (
|
|
753
|
+
if (type === 'web') {
|
|
752
754
|
const srcAppDir = (0, path_1.join)(projectDir, startupDir, 'src', 'app');
|
|
753
755
|
const namespaceDir = (0, path_1.join)(srcAppDir, 'namespaces');
|
|
754
756
|
const tryOutputAppDir = (ns) => {
|
|
@@ -831,11 +833,12 @@ function buildRouter(projectDir, startupDir, watch, options) {
|
|
|
831
833
|
BuildRouterContext.options = options;
|
|
832
834
|
BuildRouterContext.warnedInvalidDirs = new Set();
|
|
833
835
|
BuildRouterContext.warnedRouteConflicts = new Set();
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
(
|
|
838
|
-
|
|
836
|
+
const platform = options.platform === 'wechatMp'
|
|
837
|
+
? 'miniProgram'
|
|
838
|
+
: options.platform;
|
|
839
|
+
traversePageDir(projectDir, platform);
|
|
840
|
+
(0, assert_1.assert)((0, fs_extra_1.existsSync)((0, path_1.join)(projectDir, startupDir)));
|
|
841
|
+
if (platform === 'web') {
|
|
839
842
|
outputInWebDir((0, path_1.join)(projectDir, startupDir));
|
|
840
843
|
}
|
|
841
844
|
// todo native
|
|
@@ -848,7 +851,7 @@ function buildRouter(projectDir, startupDir, watch, options) {
|
|
|
848
851
|
markerFile,
|
|
849
852
|
};
|
|
850
853
|
(0, fs_extra_1.writeFileSync)(BuildRouterContext.watchSession.markerFile, JSON.stringify({ token: BuildRouterContext.watchSession.token }), 'utf-8');
|
|
851
|
-
watchDir(projectDir, startupDir,
|
|
854
|
+
watchDir(projectDir, startupDir, platform);
|
|
852
855
|
return {
|
|
853
856
|
close: closeCurrentWatchSession,
|
|
854
857
|
};
|
|
@@ -44,11 +44,15 @@ type ParsedIndexAttribute = {
|
|
|
44
44
|
};
|
|
45
45
|
type ParsedIndexConfig = {
|
|
46
46
|
unique?: boolean;
|
|
47
|
-
type?: string;
|
|
48
47
|
parser?: string;
|
|
49
48
|
tsConfig?: string | string[];
|
|
50
49
|
chineseParser?: string;
|
|
51
50
|
include?: string[];
|
|
51
|
+
type?: 'fulltext' | 'btree' | 'hash' | 'spatial';
|
|
52
|
+
spatial?: {
|
|
53
|
+
distanceModel: 'planar' | 'geodesic';
|
|
54
|
+
srid?: number;
|
|
55
|
+
};
|
|
52
56
|
};
|
|
53
57
|
type ParsedIndex = {
|
|
54
58
|
name: string;
|