@azure-net/cli 5.1.1 → 6.0.0-next.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/README.md +189 -0
- package/bin/azure-net.js +236 -221
- package/dist/bin/azure-net.d.ts +2 -0
- package/dist/src/checks/architecture.d.ts +20 -0
- package/dist/src/checks/checkDomain.d.ts +1 -0
- package/dist/src/checks/checkFoldersStructure.d.ts +1 -0
- package/dist/src/checks/checkHooks.d.ts +1 -0
- package/dist/src/checks/checkImports.d.ts +1 -0
- package/dist/src/checks/checkInternal.d.ts +1 -0
- package/dist/src/checks/checkLayerBoundaries.d.ts +1 -0
- package/dist/src/checks/checkLayerImports.d.ts +1 -0
- package/dist/src/checks/checkPresenterNames.d.ts +1 -0
- package/dist/src/checks/checkProject.d.ts +1 -0
- package/dist/src/checks/checkProviderGraph.d.ts +1 -0
- package/dist/src/checks/checkProviderNames.d.ts +1 -0
- package/dist/src/generate/layers/generateRepository.d.ts +1 -0
- package/dist/src/generate/layers/generateRepositoryMethod.d.ts +1 -0
- package/dist/src/generate/layers/generateUseCases.d.ts +1 -0
- package/dist/src/generate/module/generateDomain.d.ts +8 -0
- package/dist/src/generate/module/generateModule.d.ts +1 -0
- package/dist/src/generate/module/generateModulePreset.d.ts +1 -0
- package/dist/src/generate/module/generatePresenter.d.ts +29 -0
- package/dist/src/generate/module/generateRepository.d.ts +15 -0
- package/dist/src/generate/module/generateRepositoryMethod.d.ts +2 -0
- package/dist/src/generate/module/generateSchemaFromType.d.ts +9 -0
- package/dist/src/generate/module/generateStore.d.ts +1 -0
- package/dist/src/generate/module/generateTypesJson.d.ts +2 -0
- package/dist/src/generate/module/generateUseCases.d.ts +1 -0
- package/dist/src/generate/module/repositoryModuleShared.d.ts +89 -0
- package/dist/src/generate/routes/generateRoutes.d.ts +14 -0
- package/dist/src/generate/ui/generateComponent.d.ts +1 -0
- package/dist/src/generate/ui/generateDesignComponent.d.ts +1 -0
- package/dist/src/generate/ui/generateWidget.d.ts +1 -0
- package/dist/src/git/commit.d.ts +23 -0
- package/dist/src/git/push.d.ts +11 -0
- package/dist/src/git/runGit.d.ts +2 -0
- package/dist/src/init/initAliases.d.ts +12 -0
- package/dist/src/init/initEdges.d.ts +2 -0
- package/dist/src/init/initStructure.d.ts +1 -0
- package/dist/src/install/configureCommitTools.d.ts +1 -0
- package/dist/src/install/installFresh.d.ts +1 -0
- package/dist/src/migrate/migrate.d.ts +22 -0
- package/dist/src/migrate/presenters.d.ts +7 -0
- package/dist/src/plugins/addLint.d.ts +5 -0
- package/dist/src/scaffolds/createCoreSchema.d.ts +1 -0
- package/dist/src/scaffolds/createDatasource.d.ts +1 -0
- package/dist/src/scaffolds/createProgram.d.ts +1 -0
- package/dist/src/scaffolds/createResponse.d.ts +1 -0
- package/dist/src/scaffolds/createSchemaRule.d.ts +1 -0
- package/dist/src/scaffolds/createTranslationManager.d.ts +1 -0
- package/{src/scaffolds/index.ts → dist/src/scaffolds/index.d.ts} +0 -2
- package/dist/src/scaffolds/registerDatasource.d.ts +2 -0
- package/dist/src/scaffolds/updateDefaultFactoryConfig.d.ts +1 -0
- package/dist/src/utils/architecture.d.ts +31 -0
- package/dist/src/utils/contextUtils.d.ts +6 -0
- package/dist/src/utils/fileUtils.d.ts +5 -0
- package/dist/src/utils/flattenConfig.d.ts +2 -0
- package/dist/src/utils/legacyAliases.d.ts +1 -0
- package/dist/src/utils/loadConfig.d.ts +16 -0
- package/dist/src/utils/packageImports.d.ts +4 -0
- package/dist/src/utils/sharedFoundation.d.ts +20 -0
- package/dist/src/utils/viteConfig.d.ts +9 -0
- package/package.json +48 -36
- package/src/checks/architecture.js +154 -0
- package/src/checks/checkDomain.js +124 -154
- package/src/checks/checkFoldersStructure.js +64 -52
- package/src/checks/checkHooks.js +12 -12
- package/src/checks/checkImports.js +26 -142
- package/src/checks/checkInternal.js +27 -24
- package/src/checks/checkLayerBoundaries.js +22 -197
- package/src/checks/checkLayerImports.js +14 -134
- package/src/checks/checkPresenterNames.js +156 -143
- package/src/checks/checkProject.js +27 -26
- package/src/checks/checkProviderGraph.js +182 -166
- package/src/checks/checkProviderNames.js +123 -112
- package/src/generate/layers/generateRepository.js +1 -109
- package/src/generate/layers/generateRepositoryMethod.js +1 -90
- package/src/generate/layers/generateUseCases.js +1 -44
- package/src/generate/module/generateDomain.js +81 -105
- package/src/generate/module/generateModule.js +34 -68
- package/src/generate/module/generateModulePreset.js +188 -248
- package/src/generate/module/generatePresenter.js +441 -369
- package/src/generate/module/generateRepository.js +102 -121
- package/src/generate/module/generateRepositoryMethod.js +117 -0
- package/src/generate/module/generateSchemaFromType.js +283 -280
- package/src/generate/module/generateStore.js +41 -0
- package/src/generate/module/generateTypesJson.js +196 -195
- package/src/generate/module/generateUseCases.js +47 -55
- package/src/generate/module/repositoryModuleShared.js +480 -459
- package/src/generate/routes/generateRoutes.js +4 -7
- package/src/generate/ui/generateComponent.js +44 -64
- package/src/generate/ui/generateDesignComponent.js +21 -41
- package/src/generate/ui/generateWidget.js +21 -41
- package/src/git/commit.js +67 -0
- package/src/git/push.js +19 -0
- package/src/git/runGit.js +11 -0
- package/src/init/initAliases.js +19 -135
- package/src/init/initEdges.js +79 -54
- package/src/init/initStructure.js +31 -145
- package/src/install/configureCommitTools.js +1 -0
- package/src/install/installFresh.js +39 -68
- package/src/migrate/migrate.js +914 -0
- package/src/migrate/presenters.js +265 -0
- package/src/plugins/addLint.js +52 -219
- package/src/scaffolds/createCoreSchema.js +65 -91
- package/src/scaffolds/createDatasource.js +67 -101
- package/src/scaffolds/createProgram.js +8 -8
- package/src/scaffolds/createResponse.js +29 -29
- package/src/scaffolds/createSchemaRule.js +19 -19
- package/src/scaffolds/createTranslationManager.js +84 -37
- package/src/scaffolds/index.js +0 -2
- package/src/scaffolds/registerDatasource.js +59 -0
- package/src/scaffolds/updateDefaultFactoryConfig.js +31 -0
- package/src/utils/architecture.js +145 -0
- package/src/utils/contextUtils.js +32 -65
- package/src/utils/fileUtils.js +69 -50
- package/src/utils/flattenConfig.js +38 -0
- package/src/utils/legacyAliases.js +75 -0
- package/src/utils/loadConfig.js +76 -40
- package/src/utils/packageImports.js +63 -0
- package/src/utils/sharedFoundation.js +36 -42
- package/src/utils/viteConfig.js +295 -0
- package/.prettierrc +0 -7
- package/bin/azure-net.ts +0 -308
- package/eslint.config.js +0 -34
- package/src/checks/checkDomain.ts +0 -223
- package/src/checks/checkFoldersStructure.ts +0 -85
- package/src/checks/checkHooks.ts +0 -22
- package/src/checks/checkImports.ts +0 -193
- package/src/checks/checkInternal.ts +0 -48
- package/src/checks/checkLayerBoundaries.ts +0 -255
- package/src/checks/checkLayerImports.ts +0 -185
- package/src/checks/checkPresenterNames.ts +0 -203
- package/src/checks/checkProject.ts +0 -45
- package/src/checks/checkProviderGraph.ts +0 -234
- package/src/checks/checkProviderNames.ts +0 -165
- package/src/generate/layers/generateRepository.ts +0 -123
- package/src/generate/layers/generateRepositoryMethod.ts +0 -102
- package/src/generate/layers/generateUseCases.ts +0 -50
- package/src/generate/layers/repositoryShared.js +0 -506
- package/src/generate/layers/repositoryShared.ts +0 -662
- package/src/generate/module/generateDomain.ts +0 -147
- package/src/generate/module/generateModule.ts +0 -84
- package/src/generate/module/generateModulePreset.ts +0 -338
- package/src/generate/module/generatePresenter.ts +0 -498
- package/src/generate/module/generateRepository.ts +0 -158
- package/src/generate/module/generateSchemaFromType.ts +0 -368
- package/src/generate/module/generateTypesJson.ts +0 -259
- package/src/generate/module/generateUseCases.ts +0 -67
- package/src/generate/module/repositoryModuleShared.ts +0 -669
- package/src/generate/routes/generateRoutes.ts +0 -275
- package/src/generate/ui/generateComponent.ts +0 -100
- package/src/generate/ui/generateDesignComponent.ts +0 -71
- package/src/generate/ui/generateWidget.ts +0 -71
- package/src/init/initAliases.ts +0 -172
- package/src/init/initEdges.ts +0 -74
- package/src/init/initStructure.ts +0 -172
- package/src/install/installFresh.ts +0 -93
- package/src/plugins/addLint.ts +0 -274
- package/src/scaffolds/createCoreSchema.ts +0 -130
- package/src/scaffolds/createDatasource.ts +0 -161
- package/src/scaffolds/createDatasourceProvider.js +0 -127
- package/src/scaffolds/createDatasourceProvider.ts +0 -161
- package/src/scaffolds/createPresenterFactory.js +0 -83
- package/src/scaffolds/createPresenterFactory.ts +0 -102
- package/src/scaffolds/createProgram.ts +0 -19
- package/src/scaffolds/createResponse.ts +0 -66
- package/src/scaffolds/createSchemaRule.ts +0 -44
- package/src/scaffolds/createTranslationManager.ts +0 -80
- package/src/utils/contextUtils.ts +0 -88
- package/src/utils/fileUtils.ts +0 -74
- package/src/utils/loadConfig.ts +0 -68
- package/src/utils/sharedFoundation.ts +0 -70
- package/tsconfig.json +0 -19
- /package/{src/checks/index.ts → dist/src/checks/index.d.ts} +0 -0
- /package/{src/plugins/index.ts → dist/src/plugins/index.d.ts} +0 -0
package/src/init/initEdges.js
CHANGED
|
@@ -1,59 +1,84 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
-
import fsSync from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
import { VITE_CONFIGS, formatConfig, enableHydratable } from '../utils/viteConfig.js';
|
|
5
|
+
export function configureAzureNetPlugin(content) {
|
|
6
|
+
const source = ts.createSourceFile('vite.config.ts', content, ts.ScriptTarget.Latest, true);
|
|
7
|
+
const edits = [];
|
|
8
|
+
let pluginName = 'AzureNetPlugin';
|
|
9
|
+
let imported = false;
|
|
10
|
+
const legacyNames = new Set();
|
|
11
|
+
for (const statement of source.statements) {
|
|
12
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))
|
|
13
|
+
continue;
|
|
14
|
+
const bindings = statement.importClause?.namedBindings;
|
|
15
|
+
if (!bindings || !ts.isNamedImports(bindings))
|
|
16
|
+
continue;
|
|
17
|
+
if (statement.moduleSpecifier.text === '@azure-net/kit/plugin') {
|
|
18
|
+
for (const item of bindings.elements)
|
|
19
|
+
if ((item.propertyName?.text ?? item.name.text) === 'AzureNetPlugin') {
|
|
20
|
+
pluginName = item.name.text;
|
|
21
|
+
imported = true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (statement.moduleSpecifier.text === '@azure-net/kit/edges/plugin') {
|
|
25
|
+
for (const item of bindings.elements)
|
|
26
|
+
if ((item.propertyName?.text ?? item.name.text) === 'edgesPlugin')
|
|
27
|
+
legacyNames.add(item.name.text);
|
|
28
|
+
if (bindings.elements.some((item) => (item.propertyName?.text ?? item.name.text) !== 'edgesPlugin'))
|
|
29
|
+
throw new Error('Remove unsupported legacy edges/plugin imports from Vite config first.');
|
|
30
|
+
edits.push({ start: statement.getStart(source), end: statement.end, text: '' });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let plugins;
|
|
34
|
+
const visit = (node) => {
|
|
35
|
+
if (ts.isPropertyAssignment(node) &&
|
|
36
|
+
(ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) &&
|
|
37
|
+
node.name.text === 'plugins' &&
|
|
38
|
+
ts.isArrayLiteralExpression(node.initializer))
|
|
39
|
+
plugins ??= node.initializer;
|
|
40
|
+
ts.forEachChild(node, visit);
|
|
41
|
+
};
|
|
42
|
+
visit(source);
|
|
43
|
+
if (!plugins)
|
|
44
|
+
throw new Error('Cannot safely configure AzureNetPlugin: use a literal plugins array in vite.config.');
|
|
45
|
+
const existing = plugins.elements.some((element) => ts.isCallExpression(element) && ts.isIdentifier(element.expression) && element.expression.text === pluginName);
|
|
46
|
+
let replacedLegacy = false;
|
|
47
|
+
for (const element of plugins.elements) {
|
|
48
|
+
if (!ts.isCallExpression(element) || !ts.isIdentifier(element.expression) || !legacyNames.has(element.expression.text))
|
|
49
|
+
continue;
|
|
50
|
+
if (existing || replacedLegacy)
|
|
51
|
+
throw new Error('Both legacy and AzureNet plugins are configured. Remove the legacy plugin call first.');
|
|
52
|
+
edits.push({ start: element.getStart(source), end: element.end, text: `${pluginName}()` });
|
|
53
|
+
replacedLegacy = true;
|
|
54
|
+
}
|
|
55
|
+
if (!existing && !replacedLegacy) {
|
|
56
|
+
const last = plugins.elements.at(-1);
|
|
57
|
+
edits.push({ start: plugins.end - 1, end: plugins.end - 1, text: `\n${pluginName}()\n` });
|
|
58
|
+
if (last && !plugins.elements.hasTrailingComma)
|
|
59
|
+
edits.push({ start: last.end, end: last.end, text: ',' });
|
|
60
|
+
}
|
|
61
|
+
for (const edit of edits.sort((a, b) => b.start - a.start))
|
|
62
|
+
content = content.slice(0, edit.start) + edit.text + content.slice(edit.end);
|
|
63
|
+
if (!imported)
|
|
64
|
+
content = `import { AzureNetPlugin } from '@azure-net/kit/plugin';\n${content}`;
|
|
65
|
+
return enableHydratable(content);
|
|
47
66
|
}
|
|
48
67
|
export default async function initEdges() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
for (const name of VITE_CONFIGS) {
|
|
69
|
+
const file = path.resolve(name);
|
|
70
|
+
let content;
|
|
71
|
+
try {
|
|
72
|
+
content = await fs.readFile(file, 'utf8');
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error.code === 'ENOENT')
|
|
76
|
+
continue;
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
await fs.writeFile(file, await formatConfig(configureAzureNetPlugin(content), file));
|
|
80
|
+
console.log(`AzureNetPlugin configured in ${name}`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw new Error('vite.config.(ts|js|mjs) was not found. Initialize a SvelteKit project first.');
|
|
59
84
|
}
|
|
@@ -1,149 +1,35 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { loadUserConfig } from '../utils/loadConfig.js';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const APP_ROOT = path.join(ROOT, 'app');
|
|
8
|
-
const CONTEXT_DIRS = [
|
|
9
|
-
'ui',
|
|
10
|
-
'layers',
|
|
11
|
-
'layers/domain',
|
|
12
|
-
'layers/application',
|
|
13
|
-
'layers/application/providers',
|
|
14
|
-
'layers/application/use-cases',
|
|
15
|
-
'layers/infrastructure',
|
|
16
|
-
'layers/infrastructure/providers',
|
|
17
|
-
'layers/infrastructure/http',
|
|
18
|
-
'layers/infrastructure/http/repositories',
|
|
19
|
-
'layers/presentation'
|
|
20
|
-
];
|
|
21
|
-
const SHARED_ESSENTIALS_DIRS = [
|
|
22
|
-
'',
|
|
23
|
-
'foundation',
|
|
24
|
-
'foundation/abstracts',
|
|
25
|
-
'foundation/constants',
|
|
26
|
-
'foundation/constructs',
|
|
27
|
-
'foundation/constructs/datasource',
|
|
28
|
-
'foundation/constructs/presenter',
|
|
29
|
-
'foundation/constructs/provider',
|
|
30
|
-
'foundation/constructs/response',
|
|
31
|
-
'foundation/constructs/schema',
|
|
32
|
-
'foundation/constructs/schema/custom-rules',
|
|
33
|
-
'foundation/helpers',
|
|
34
|
-
'localization',
|
|
35
|
-
'pipelines'
|
|
36
|
-
];
|
|
37
|
-
const ensureDir = async (dirPath) => {
|
|
38
|
-
try {
|
|
39
|
-
await fs.mkdir(dirPath, { recursive: true });
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.warn(`⚠️ Failed to create directory: ${dirPath}`, error);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const ensureFile = async (filePath, content) => {
|
|
45
|
-
try {
|
|
46
|
-
await fs.access(filePath);
|
|
47
|
-
return;
|
|
48
|
-
} catch {
|
|
49
|
-
// File is missing
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
53
|
-
await fs.writeFile(filePath, content, 'utf-8');
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.warn(`⚠️ Failed to create file: ${filePath}`, error);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const toPascalCase = (value) =>
|
|
59
|
-
value
|
|
60
|
-
.split(/[-_\s]+/)
|
|
61
|
-
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
62
|
-
.join('');
|
|
63
|
-
const createInfrastructureProvider = (contextName) => `import { createBoundaryProvider } from '@azure-net/kit';
|
|
64
|
-
|
|
65
|
-
export const ${contextName}InfrastructureProvider = createBoundaryProvider('${contextName}InfrastructureProvider', {
|
|
66
|
-
\tregister: () => ({})
|
|
67
|
-
});
|
|
68
|
-
`;
|
|
69
|
-
const createApplicationProvider = (contextName) => `import { createBoundaryProvider } from '@azure-net/kit';
|
|
70
|
-
import { ${contextName}InfrastructureProvider } from '../../infrastructure/providers';
|
|
71
|
-
|
|
72
|
-
export const ${contextName}ApplicationProvider = createBoundaryProvider('${contextName}ApplicationProvider', {
|
|
73
|
-
\tdependsOn: { ${contextName}InfrastructureProvider },
|
|
74
|
-
\tregister: () => ({})
|
|
75
|
-
});
|
|
76
|
-
`;
|
|
77
|
-
const printContextsError = () => {
|
|
78
|
-
console.error('❌ Cannot generate folders structure: `contexts` is missing or empty in azure-net.config.ts/js');
|
|
79
|
-
console.error('Add contexts first, for example:');
|
|
80
|
-
console.error('export default {');
|
|
81
|
-
console.error("\tcontexts: ['web', 'admin']");
|
|
82
|
-
console.error('\t// or');
|
|
83
|
-
console.error("\t// contexts: [{ name: 'web', alias: '$web' }, { name: 'admin', alias: '$admin' }]");
|
|
84
|
-
console.error('};');
|
|
85
|
-
};
|
|
86
|
-
const printSharedAliasError = () => {
|
|
87
|
-
console.error('❌ Cannot generate folders structure: `sharedAlias` is missing in azure-net.config.ts/js');
|
|
88
|
-
console.error('Add shared context and alias first, for example:');
|
|
89
|
-
console.error('export default {');
|
|
90
|
-
console.error("\tsharedAlias: '$shared-kernel',");
|
|
91
|
-
console.error("\tcontexts: [{ name: 'shared-kernel', alias: '$shared-kernel' }, 'public']");
|
|
92
|
-
console.error('};');
|
|
93
|
-
};
|
|
94
|
-
const ensureSharedEssentialsStructure = async (contexts, sharedAlias) => {
|
|
95
|
-
const normalizedSharedAlias = sharedAlias.startsWith('$') ? sharedAlias : `$${sharedAlias}`;
|
|
96
|
-
const sharedContext = contexts.find((context) => context.alias === normalizedSharedAlias);
|
|
97
|
-
if (!sharedContext) {
|
|
98
|
-
console.error(`❌ sharedAlias "${normalizedSharedAlias}" does not point to any configured context.`);
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
const essentialsRoot = getSharedEssentialsPath(sharedContext.name);
|
|
102
|
-
for (const dir of SHARED_ESSENTIALS_DIRS) {
|
|
103
|
-
await ensureDir(path.join(essentialsRoot, dir));
|
|
104
|
-
}
|
|
105
|
-
return true;
|
|
106
|
-
};
|
|
107
|
-
const ensureContextStructure = async (context) => {
|
|
108
|
-
const contextRoot = path.join(APP_ROOT, context.name);
|
|
109
|
-
for (const dir of CONTEXT_DIRS) {
|
|
110
|
-
await ensureDir(path.join(contextRoot, dir));
|
|
111
|
-
}
|
|
112
|
-
const contextName = toPascalCase(context.name);
|
|
113
|
-
const infraProviderPath = path.join(contextRoot, 'layers', 'infrastructure', 'providers', 'InfrastructureProvider.ts');
|
|
114
|
-
const infraProviderIndex = path.join(contextRoot, 'layers', 'infrastructure', 'providers', 'index.ts');
|
|
115
|
-
const appProviderPath = path.join(contextRoot, 'layers', 'application', 'providers', 'ApplicationProvider.ts');
|
|
116
|
-
const appProviderIndex = path.join(contextRoot, 'layers', 'application', 'providers', 'index.ts');
|
|
117
|
-
const repositoriesIndex = path.join(contextRoot, 'layers', 'infrastructure', 'http', 'repositories', 'index.ts');
|
|
118
|
-
const useCasesIndex = path.join(contextRoot, 'layers', 'application', 'use-cases', 'index.ts');
|
|
119
|
-
await ensureFile(infraProviderPath, createInfrastructureProvider(contextName));
|
|
120
|
-
await ensureFile(infraProviderIndex, `export * from './InfrastructureProvider';\n`);
|
|
121
|
-
await ensureFile(appProviderPath, createApplicationProvider(contextName));
|
|
122
|
-
await ensureFile(appProviderIndex, `export * from './ApplicationProvider';\n`);
|
|
123
|
-
await ensureFile(repositoriesIndex, '');
|
|
124
|
-
await ensureFile(useCasesIndex, '');
|
|
125
|
-
};
|
|
3
|
+
import { initializeConfigDefaults, loadUserConfig } from '../utils/loadConfig.js';
|
|
4
|
+
import { discoverContexts, discoverPresentationWorkspaces, ensureContextStructure, ensurePresentationStructure, getPlatformPath, getPresentationPath, normalizePascalName, SHARED_CONTEXT, SHARED_WORKSPACE } from '../utils/architecture.js';
|
|
5
|
+
import { writeIfNotExists } from '../utils/fileUtils.js';
|
|
6
|
+
import initAliases from './initAliases.js';
|
|
126
7
|
export default async function initStructure() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
8
|
+
await initializeConfigDefaults();
|
|
9
|
+
const config = await loadUserConfig();
|
|
10
|
+
for (const name of new Set([SHARED_CONTEXT, ...(await discoverContexts())]))
|
|
11
|
+
await ensureContextStructure(name);
|
|
12
|
+
let initial = false;
|
|
13
|
+
try {
|
|
14
|
+
initial = (await fs.readdir(getPresentationPath())).length === 0;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error.code !== 'ENOENT')
|
|
18
|
+
throw error;
|
|
19
|
+
initial = true;
|
|
20
|
+
}
|
|
21
|
+
const workspaces = initial ? (config.presentationWorkspaces ?? []).map(normalizePascalName) : await discoverPresentationWorkspaces();
|
|
22
|
+
if (workspaces.length) {
|
|
23
|
+
for (const workspace of new Set([...workspaces, SHARED_WORKSPACE]))
|
|
24
|
+
await ensurePresentationStructure(workspace);
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
await ensurePresentationStructure();
|
|
28
|
+
const platform = getPlatformPath();
|
|
29
|
+
for (const dir of ['Foundation/Datasource', 'Foundation/Response', 'Foundation/Schema/CustomRules', 'Foundation/DI', 'Bootstrap'])
|
|
30
|
+
await fs.mkdir(path.join(platform, dir), { recursive: true });
|
|
31
|
+
await writeIfNotExists(path.join(platform, 'Foundation/DI/ApplicationProvider.ts'), `import { CreateDiContainer } from '@azure-net/kit';\n\nexport const ApplicationProvider = CreateDiContainer('ApplicationProvider', {\n\tregister: () => ({})\n});\n`);
|
|
32
|
+
await writeIfNotExists(path.join(platform, 'Foundation/DI/index.ts'), "export * from './ApplicationProvider';\n");
|
|
33
|
+
await initAliases();
|
|
34
|
+
console.log('Folders structure initialized');
|
|
149
35
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../plugins/addLint.js';
|
|
@@ -1,77 +1,48 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
|
-
import
|
|
2
|
+
import configureCommitTools from './configureCommitTools.js';
|
|
3
3
|
import initEdges from '../init/initEdges.js';
|
|
4
4
|
import initStructure from '../init/initStructure.js';
|
|
5
|
-
import {
|
|
6
|
-
import { loadUserConfig } from '../utils/loadConfig.js';
|
|
7
|
-
import {
|
|
8
|
-
createCoreSchema,
|
|
9
|
-
createDatasource,
|
|
10
|
-
createDatasourceProvider,
|
|
11
|
-
createPresenterFactory,
|
|
12
|
-
createProgram,
|
|
13
|
-
createResponse,
|
|
14
|
-
createTranslationManager
|
|
15
|
-
} from '../scaffolds/index.js';
|
|
16
|
-
const printContextsError = () => {
|
|
17
|
-
console.error('❌ Cannot run "install fresh": `contexts` is missing or empty in azure-net.config.ts/js');
|
|
18
|
-
console.error('Add contexts first, for example:');
|
|
19
|
-
console.error('export default {');
|
|
20
|
-
console.error("\tcontexts: ['web', 'admin']");
|
|
21
|
-
console.error('\t// or');
|
|
22
|
-
console.error("\t// contexts: [{ name: 'web', alias: '$web' }, { name: 'admin', alias: '$admin' }]");
|
|
23
|
-
console.error('};');
|
|
24
|
-
};
|
|
5
|
+
import { createCoreSchema, createDatasource, createProgram, createResponse, createTranslationManager } from '../scaffolds/index.js';
|
|
25
6
|
const askConfirm = async (message) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
7
|
+
const result = await prompts({
|
|
8
|
+
type: 'confirm',
|
|
9
|
+
name: 'confirmed',
|
|
10
|
+
message,
|
|
11
|
+
initial: true
|
|
12
|
+
});
|
|
13
|
+
return Boolean(result.confirmed);
|
|
33
14
|
};
|
|
34
15
|
const runOptionalStep = async (question, action) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
16
|
+
const shouldRun = await askConfirm(question);
|
|
17
|
+
if (!shouldRun)
|
|
18
|
+
return;
|
|
19
|
+
try {
|
|
20
|
+
await action();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new Error(`Step failed: ${question}`, { cause: error });
|
|
24
|
+
}
|
|
25
|
+
if (process.exitCode)
|
|
26
|
+
throw new Error(`Step failed: ${question}`);
|
|
43
27
|
};
|
|
44
28
|
export default async function installFresh() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
await runOptionalStep('Create API response?', async () => {
|
|
65
|
-
await createResponse();
|
|
66
|
-
});
|
|
67
|
-
await runOptionalStep('Create datasource?', async () => {
|
|
68
|
-
await createDatasource();
|
|
69
|
-
});
|
|
70
|
-
await runOptionalStep('Create datasource provider?', async () => {
|
|
71
|
-
await createDatasourceProvider();
|
|
72
|
-
});
|
|
73
|
-
await runOptionalStep('Create translation manager (i18n)?', async () => {
|
|
74
|
-
await createTranslationManager();
|
|
75
|
-
});
|
|
76
|
-
console.log('✅ install fresh completed');
|
|
29
|
+
await initStructure();
|
|
30
|
+
await initEdges();
|
|
31
|
+
await createProgram();
|
|
32
|
+
await runOptionalStep('Add commit tools (lint/commit conventions)?', async () => {
|
|
33
|
+
await configureCommitTools();
|
|
34
|
+
});
|
|
35
|
+
await runOptionalStep('Create schema factory?', async () => {
|
|
36
|
+
await createCoreSchema();
|
|
37
|
+
});
|
|
38
|
+
await runOptionalStep('Create API response?', async () => {
|
|
39
|
+
await createResponse();
|
|
40
|
+
});
|
|
41
|
+
await runOptionalStep('Create datasource?', async () => {
|
|
42
|
+
await createDatasource();
|
|
43
|
+
});
|
|
44
|
+
await runOptionalStep('Create translation manager (i18n)?', async () => {
|
|
45
|
+
await createTranslationManager();
|
|
46
|
+
});
|
|
47
|
+
console.log('✅ install fresh completed');
|
|
77
48
|
}
|