@azure-net/cli 5.1.1 → 6.0.0-next.3

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.
Files changed (180) hide show
  1. package/README.md +201 -0
  2. package/bin/azure-net.js +236 -221
  3. package/dist/bin/azure-net.d.ts +2 -0
  4. package/dist/src/checks/architecture.d.ts +20 -0
  5. package/dist/src/checks/checkDomain.d.ts +1 -0
  6. package/dist/src/checks/checkFoldersStructure.d.ts +1 -0
  7. package/dist/src/checks/checkHooks.d.ts +1 -0
  8. package/dist/src/checks/checkImports.d.ts +1 -0
  9. package/dist/src/checks/checkInternal.d.ts +1 -0
  10. package/dist/src/checks/checkLayerBoundaries.d.ts +1 -0
  11. package/dist/src/checks/checkLayerImports.d.ts +1 -0
  12. package/dist/src/checks/checkPresenterNames.d.ts +1 -0
  13. package/dist/src/checks/checkProject.d.ts +1 -0
  14. package/dist/src/checks/checkProviderGraph.d.ts +1 -0
  15. package/dist/src/checks/checkProviderNames.d.ts +1 -0
  16. package/dist/src/generate/layers/generateRepository.d.ts +1 -0
  17. package/dist/src/generate/layers/generateRepositoryMethod.d.ts +1 -0
  18. package/dist/src/generate/layers/generateUseCases.d.ts +1 -0
  19. package/dist/src/generate/module/generateDomain.d.ts +8 -0
  20. package/dist/src/generate/module/generateModule.d.ts +1 -0
  21. package/dist/src/generate/module/generateModulePreset.d.ts +1 -0
  22. package/dist/src/generate/module/generatePresenter.d.ts +29 -0
  23. package/dist/src/generate/module/generateRepository.d.ts +15 -0
  24. package/dist/src/generate/module/generateRepositoryMethod.d.ts +2 -0
  25. package/dist/src/generate/module/generateSchemaFromType.d.ts +9 -0
  26. package/dist/src/generate/module/generateStore.d.ts +1 -0
  27. package/dist/src/generate/module/generateTypesJson.d.ts +2 -0
  28. package/dist/src/generate/module/generateUseCases.d.ts +1 -0
  29. package/dist/src/generate/module/repositoryModuleShared.d.ts +89 -0
  30. package/dist/src/generate/routes/generateRoutes.d.ts +14 -0
  31. package/dist/src/generate/ui/generateComponent.d.ts +1 -0
  32. package/dist/src/generate/ui/generateDesignComponent.d.ts +1 -0
  33. package/dist/src/generate/ui/generateWidget.d.ts +1 -0
  34. package/dist/src/git/commit.d.ts +23 -0
  35. package/dist/src/git/push.d.ts +11 -0
  36. package/dist/src/git/runGit.d.ts +2 -0
  37. package/dist/src/init/initAliases.d.ts +12 -0
  38. package/dist/src/init/initEdges.d.ts +2 -0
  39. package/dist/src/init/initStructure.d.ts +1 -0
  40. package/dist/src/install/configureCommitTools.d.ts +1 -0
  41. package/dist/src/install/installFresh.d.ts +1 -0
  42. package/dist/src/migrate/migrate.d.ts +22 -0
  43. package/dist/src/migrate/presenterFactories.d.ts +9 -0
  44. package/dist/src/migrate/presenters.d.ts +13 -0
  45. package/dist/src/migrate/translations.d.ts +8 -0
  46. package/dist/src/plugins/addLint.d.ts +5 -0
  47. package/dist/src/scaffolds/createCoreSchema.d.ts +1 -0
  48. package/dist/src/scaffolds/createDatasource.d.ts +1 -0
  49. package/dist/src/scaffolds/createProgram.d.ts +1 -0
  50. package/dist/src/scaffolds/createResponse.d.ts +1 -0
  51. package/dist/src/scaffolds/createSchemaRule.d.ts +1 -0
  52. package/dist/src/scaffolds/createTranslationManager.d.ts +1 -0
  53. package/{src/scaffolds/index.ts → dist/src/scaffolds/index.d.ts} +0 -2
  54. package/dist/src/scaffolds/registerDatasource.d.ts +2 -0
  55. package/dist/src/scaffolds/updateDefaultFactoryConfig.d.ts +1 -0
  56. package/dist/src/utils/architecture.d.ts +31 -0
  57. package/dist/src/utils/contextUtils.d.ts +6 -0
  58. package/dist/src/utils/fileUtils.d.ts +5 -0
  59. package/dist/src/utils/flattenConfig.d.ts +2 -0
  60. package/dist/src/utils/legacyAliases.d.ts +1 -0
  61. package/dist/src/utils/loadConfig.d.ts +16 -0
  62. package/dist/src/utils/packageImports.d.ts +4 -0
  63. package/dist/src/utils/sharedFoundation.d.ts +20 -0
  64. package/dist/src/utils/viteConfig.d.ts +9 -0
  65. package/package.json +17 -7
  66. package/src/checks/architecture.js +154 -0
  67. package/src/checks/checkDomain.js +124 -154
  68. package/src/checks/checkFoldersStructure.js +64 -52
  69. package/src/checks/checkHooks.js +12 -12
  70. package/src/checks/checkImports.js +26 -142
  71. package/src/checks/checkInternal.js +27 -24
  72. package/src/checks/checkLayerBoundaries.js +22 -197
  73. package/src/checks/checkLayerImports.js +14 -134
  74. package/src/checks/checkPresenterNames.js +156 -143
  75. package/src/checks/checkProject.js +27 -26
  76. package/src/checks/checkProviderGraph.js +182 -166
  77. package/src/checks/checkProviderNames.js +123 -112
  78. package/src/generate/layers/generateRepository.js +1 -109
  79. package/src/generate/layers/generateRepositoryMethod.js +1 -90
  80. package/src/generate/layers/generateUseCases.js +1 -44
  81. package/src/generate/module/generateDomain.js +81 -105
  82. package/src/generate/module/generateModule.js +34 -68
  83. package/src/generate/module/generateModulePreset.js +188 -248
  84. package/src/generate/module/generatePresenter.js +441 -369
  85. package/src/generate/module/generateRepository.js +102 -121
  86. package/src/generate/module/generateRepositoryMethod.js +117 -0
  87. package/src/generate/module/generateSchemaFromType.js +283 -280
  88. package/src/generate/module/generateStore.js +41 -0
  89. package/src/generate/module/generateTypesJson.js +196 -195
  90. package/src/generate/module/generateUseCases.js +47 -55
  91. package/src/generate/module/repositoryModuleShared.js +480 -459
  92. package/src/generate/routes/generateRoutes.js +4 -7
  93. package/src/generate/ui/generateComponent.js +44 -64
  94. package/src/generate/ui/generateDesignComponent.js +21 -41
  95. package/src/generate/ui/generateWidget.js +21 -41
  96. package/src/git/commit.js +67 -0
  97. package/src/git/push.js +19 -0
  98. package/src/git/runGit.js +11 -0
  99. package/src/init/initAliases.js +19 -135
  100. package/src/init/initEdges.js +79 -54
  101. package/src/init/initStructure.js +31 -145
  102. package/src/install/configureCommitTools.js +1 -0
  103. package/src/install/installFresh.js +39 -68
  104. package/src/migrate/migrate.js +1027 -0
  105. package/src/migrate/presenterFactories.js +189 -0
  106. package/src/migrate/presenters.js +373 -0
  107. package/src/migrate/translations.js +213 -0
  108. package/src/plugins/addLint.js +52 -219
  109. package/src/scaffolds/createCoreSchema.js +65 -91
  110. package/src/scaffolds/createDatasource.js +67 -101
  111. package/src/scaffolds/createProgram.js +8 -8
  112. package/src/scaffolds/createResponse.js +29 -29
  113. package/src/scaffolds/createSchemaRule.js +19 -19
  114. package/src/scaffolds/createTranslationManager.js +84 -37
  115. package/src/scaffolds/index.js +0 -2
  116. package/src/scaffolds/registerDatasource.js +59 -0
  117. package/src/scaffolds/updateDefaultFactoryConfig.js +31 -0
  118. package/src/utils/architecture.js +145 -0
  119. package/src/utils/contextUtils.js +32 -65
  120. package/src/utils/fileUtils.js +69 -50
  121. package/src/utils/flattenConfig.js +38 -0
  122. package/src/utils/legacyAliases.js +75 -0
  123. package/src/utils/loadConfig.js +76 -40
  124. package/src/utils/packageImports.js +63 -0
  125. package/src/utils/sharedFoundation.js +36 -42
  126. package/src/utils/viteConfig.js +295 -0
  127. package/.prettierrc +0 -7
  128. package/bin/azure-net.ts +0 -308
  129. package/eslint.config.js +0 -34
  130. package/src/checks/checkDomain.ts +0 -223
  131. package/src/checks/checkFoldersStructure.ts +0 -85
  132. package/src/checks/checkHooks.ts +0 -22
  133. package/src/checks/checkImports.ts +0 -193
  134. package/src/checks/checkInternal.ts +0 -48
  135. package/src/checks/checkLayerBoundaries.ts +0 -255
  136. package/src/checks/checkLayerImports.ts +0 -185
  137. package/src/checks/checkPresenterNames.ts +0 -203
  138. package/src/checks/checkProject.ts +0 -45
  139. package/src/checks/checkProviderGraph.ts +0 -234
  140. package/src/checks/checkProviderNames.ts +0 -165
  141. package/src/generate/layers/generateRepository.ts +0 -123
  142. package/src/generate/layers/generateRepositoryMethod.ts +0 -102
  143. package/src/generate/layers/generateUseCases.ts +0 -50
  144. package/src/generate/layers/repositoryShared.js +0 -506
  145. package/src/generate/layers/repositoryShared.ts +0 -662
  146. package/src/generate/module/generateDomain.ts +0 -147
  147. package/src/generate/module/generateModule.ts +0 -84
  148. package/src/generate/module/generateModulePreset.ts +0 -338
  149. package/src/generate/module/generatePresenter.ts +0 -498
  150. package/src/generate/module/generateRepository.ts +0 -158
  151. package/src/generate/module/generateSchemaFromType.ts +0 -368
  152. package/src/generate/module/generateTypesJson.ts +0 -259
  153. package/src/generate/module/generateUseCases.ts +0 -67
  154. package/src/generate/module/repositoryModuleShared.ts +0 -669
  155. package/src/generate/routes/generateRoutes.ts +0 -275
  156. package/src/generate/ui/generateComponent.ts +0 -100
  157. package/src/generate/ui/generateDesignComponent.ts +0 -71
  158. package/src/generate/ui/generateWidget.ts +0 -71
  159. package/src/init/initAliases.ts +0 -172
  160. package/src/init/initEdges.ts +0 -74
  161. package/src/init/initStructure.ts +0 -172
  162. package/src/install/installFresh.ts +0 -93
  163. package/src/plugins/addLint.ts +0 -274
  164. package/src/scaffolds/createCoreSchema.ts +0 -130
  165. package/src/scaffolds/createDatasource.ts +0 -161
  166. package/src/scaffolds/createDatasourceProvider.js +0 -127
  167. package/src/scaffolds/createDatasourceProvider.ts +0 -161
  168. package/src/scaffolds/createPresenterFactory.js +0 -83
  169. package/src/scaffolds/createPresenterFactory.ts +0 -102
  170. package/src/scaffolds/createProgram.ts +0 -19
  171. package/src/scaffolds/createResponse.ts +0 -66
  172. package/src/scaffolds/createSchemaRule.ts +0 -44
  173. package/src/scaffolds/createTranslationManager.ts +0 -80
  174. package/src/utils/contextUtils.ts +0 -88
  175. package/src/utils/fileUtils.ts +0 -74
  176. package/src/utils/loadConfig.ts +0 -68
  177. package/src/utils/sharedFoundation.ts +0 -70
  178. package/tsconfig.json +0 -19
  179. /package/{src/checks/index.ts → dist/src/checks/index.d.ts} +0 -0
  180. /package/{src/plugins/index.ts → dist/src/plugins/index.d.ts} +0 -0
@@ -0,0 +1,9 @@
1
+ type InterfaceField = {
2
+ name: string;
3
+ optional: boolean;
4
+ type: string;
5
+ };
6
+ export declare const extractInterfaceFields: (body: string) => InterfaceField[];
7
+ export declare const updateRulesObject: (content: string, fields: InterfaceField[]) => string | null;
8
+ export default function generateSchemaFromType(): Promise<void>;
9
+ export {};
@@ -0,0 +1 @@
1
+ export default function generateStore(): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare const parseObjectInput: (rawValue: unknown) => Record<string, unknown>;
2
+ export default function generateTypesJson(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function generateUseCases(): Promise<void>;
@@ -0,0 +1,89 @@
1
+ type ContextConfig = {
2
+ name: string;
3
+ alias: string;
4
+ };
5
+ type TypeLayer = 'Ports' | 'Entities' | 'Enums';
6
+ type ResponseKind = 'domain' | 'primitive';
7
+ type RepositoryMeta = {
8
+ className: string;
9
+ baseName: string;
10
+ repositoryInterfaceName: string;
11
+ useCasesClassName: string;
12
+ repositoryDependencyName: string;
13
+ };
14
+ type DomainType = {
15
+ name: string;
16
+ layer: TypeLayer;
17
+ fileName?: string;
18
+ };
19
+ type MethodTypeRef = {
20
+ name: string;
21
+ layer: TypeLayer;
22
+ };
23
+ type MethodResponseRef = {
24
+ kind: ResponseKind;
25
+ type: string;
26
+ layer: TypeLayer | null;
27
+ };
28
+ type RepositoryMethod = {
29
+ name: string;
30
+ httpMethod: string;
31
+ route: string;
32
+ response: MethodResponseRef;
33
+ queryType: MethodTypeRef | null;
34
+ bodyType: MethodTypeRef | null;
35
+ pathParamType: string | null;
36
+ };
37
+ type DatasourceInfo = {
38
+ name: string;
39
+ importPath: string;
40
+ };
41
+ export declare const ensureRepositoryName: (rawName: unknown) => string;
42
+ export declare const getRepositoryMeta: (repositoryName: unknown) => RepositoryMeta;
43
+ export declare const getConfigState: () => Promise<{
44
+ contexts: ContextConfig[];
45
+ sharedAlias: string;
46
+ sharedContextName: string;
47
+ }>;
48
+ export declare const selectContext: (message?: string) => Promise<string | null>;
49
+ export declare const resolveContextAlias: (_contexts: ContextConfig[], contextName: string) => string;
50
+ export declare const resolveRepositoriesPath: (contextName: string) => string;
51
+ export declare const resolveDatasourcesPath: (...compatibility: [contextName?: string]) => string;
52
+ export declare const resolveSharedDatasourcesPath: () => Promise<string>;
53
+ export declare const resolveDomainRootPath: (contextName: string, ...compatibility: [domainName?: string]) => string;
54
+ export declare const resolveUseCasesPath: (contextName: string) => string;
55
+ export declare const getAvailableTsNames: (targetPath: string) => Promise<string[]>;
56
+ export declare const selectDatasource: (...compatibility: [contextName?: string]) => Promise<DatasourceInfo | null>;
57
+ export declare const selectDomain: (contextName: string) => Promise<string>;
58
+ export declare const getDomainTypes: (contextName: string, domainName?: string) => Promise<DomainType[]>;
59
+ export declare const promptMethodDefinition: (domainTypes: DomainType[]) => Promise<RepositoryMethod | null>;
60
+ export declare const buildRepositoryMethodCode: (method: RepositoryMethod) => string;
61
+ export declare const buildRepositoryContent: ({ meta, contextAlias, datasource, domainTypes, methods }: {
62
+ meta: RepositoryMeta;
63
+ contextAlias: string;
64
+ domainName: string;
65
+ domainTypes?: DomainType[];
66
+ datasource: DatasourceInfo;
67
+ methods: RepositoryMethod[];
68
+ }) => string;
69
+ export declare const writeRepositoryInterface: ({ contextName, domainName, meta, methods }: {
70
+ contextName: string;
71
+ domainName: string;
72
+ meta: RepositoryMeta;
73
+ methods: RepositoryMethod[];
74
+ }) => Promise<boolean>;
75
+ export declare const createUseCasesForRepository: ({ contextName, contextAlias, domainName, repositoryName }: {
76
+ contextName: string;
77
+ contextAlias: string;
78
+ domainName: string;
79
+ repositoryName: string;
80
+ }) => Promise<boolean>;
81
+ export declare const resolveDomainForRepository: ({ contextName, contextAlias, repositoryName }: {
82
+ contextName: string;
83
+ contextAlias: string;
84
+ repositoryName: string;
85
+ }) => Promise<string | null>;
86
+ export declare const promptMethodsBatch: (domainTypes: DomainType[], count: number) => Promise<RepositoryMethod[] | null>;
87
+ export declare const ensureDomainScaffold: (contextName: string) => Promise<void>;
88
+ export declare const printApplicationProviderWiring: (contextName: string, repositoryName: string, datasourceName: string) => void;
89
+ export {};
@@ -0,0 +1,14 @@
1
+ export type RouteGenerationMeta = {
2
+ url: string;
3
+ routeDir: string;
4
+ relativeDir: string;
5
+ segments: string[];
6
+ dynamicParams: string[];
7
+ rootGroup?: string;
8
+ groupStack: string[];
9
+ depth: number;
10
+ hasChildren: boolean;
11
+ hasPage: boolean;
12
+ hasServer: boolean;
13
+ };
14
+ export default function generateRoutes(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function generateComponent(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function generateDesignComponent(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function generateWidget(): Promise<void>;
@@ -0,0 +1,23 @@
1
+ import prompts from 'prompts';
2
+ import { type GitRunner } from './runGit.js';
3
+ export declare const commitTypes: {
4
+ value: string;
5
+ title: string;
6
+ }[];
7
+ export declare class CommitCancelledError extends Error {
8
+ constructor();
9
+ }
10
+ export declare function validateSubject(value: string): true | string;
11
+ export interface CommitAnswers {
12
+ type: string;
13
+ subject: string;
14
+ body?: string;
15
+ breaking?: string;
16
+ footer?: string;
17
+ }
18
+ export declare function formatCommitMessage(answers: CommitAnswers): string;
19
+ export interface CommitDependencies {
20
+ prompt?: typeof prompts;
21
+ git?: GitRunner;
22
+ }
23
+ export default function commit(dependencies?: CommitDependencies): Promise<void>;
@@ -0,0 +1,11 @@
1
+ import { type CommitDependencies } from './commit.js';
2
+ export interface PushOptions {
3
+ check?: boolean;
4
+ }
5
+ export interface PushDependencies extends CommitDependencies {
6
+ loadConfig?: () => Promise<{
7
+ runChecksBeforePush?: unknown;
8
+ }>;
9
+ checkProject?: () => Promise<void>;
10
+ }
11
+ export default function push(options?: PushOptions, dependencies?: PushDependencies): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export type GitRunner = (args: string[]) => Promise<void>;
2
+ export declare const runGit: GitRunner;
@@ -0,0 +1,12 @@
1
+ type ContextConfig = {
2
+ name: string;
3
+ alias: string;
4
+ };
5
+ /** Compatibility only: architecture discovery never reads configured contexts. */
6
+ export declare function normalizeContexts(raw: unknown): ContextConfig[];
7
+ export declare function generateAliases(): {
8
+ contexts: ContextConfig[];
9
+ aliases: Record<string, string>;
10
+ };
11
+ export { mergeAliasesInSvelteConfig } from '../utils/legacyAliases.js';
12
+ export default function initAliases(): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function configureAzureNetPlugin(content: string): string;
2
+ export default function initEdges(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function initStructure(): Promise<void>;
@@ -0,0 +1 @@
1
+ export { default } from '../plugins/addLint.js';
@@ -0,0 +1 @@
1
+ export default function installFresh(): Promise<void>;
@@ -0,0 +1,22 @@
1
+ export type MigrationIssue = {
2
+ file: string;
3
+ reason: string;
4
+ };
5
+ export type MigrationPlan = {
6
+ root: string;
7
+ moves: {
8
+ from: string;
9
+ to: string;
10
+ }[];
11
+ issues: MigrationIssue[];
12
+ writes: Map<string, Buffer>;
13
+ originals: Map<string, Buffer>;
14
+ removes: string[];
15
+ workspaces: string[];
16
+ };
17
+ export declare function planMigration(root?: string): Promise<MigrationPlan>;
18
+ export declare function applyMigration(plan: MigrationPlan): Promise<string>;
19
+ export default function migrate(options?: {
20
+ dryRun?: boolean;
21
+ yes?: boolean;
22
+ }): Promise<void>;
@@ -0,0 +1,9 @@
1
+ export interface FactoryDefinition {
2
+ name: string;
3
+ exportName: string;
4
+ keys: Set<string>;
5
+ helpers: Set<string>;
6
+ }
7
+ /** Only evaluate syntax. Never import or execute the application's factory/configuration. */
8
+ export declare function inspectFactories(input: string, file: string): FactoryDefinition[];
9
+ export declare function replaceFactory(input: string, file: string, definition: FactoryDefinition, keepLegacy: boolean): string;
@@ -0,0 +1,13 @@
1
+ export declare function migrateAsyncHelpers(input: string, file: string): string;
2
+ export interface PresenterDependencies {
3
+ source: string;
4
+ exportName: string;
5
+ keys: Set<string>;
6
+ helpers: Set<string>;
7
+ }
8
+ /** Preserve lexical behavior while moving instance creation and dependencies to RegisterProvider. */
9
+ export declare function migratePresenterSource(input: string, file: string, factories: Set<string>, dependencies?: Map<string, PresenterDependencies>): {
10
+ content: string;
11
+ converted: Map<string, string>;
12
+ issues: string[];
13
+ };
@@ -0,0 +1,8 @@
1
+ /** A conservative migration of known translation wiring, never a project-wide textual replacement. */
2
+ export declare function migrateTranslationsSources(sources: Map<string, string>, resolve: (from: string, specifier: string) => string | undefined): {
3
+ updates: Map<string, string>;
4
+ issues: {
5
+ file: string;
6
+ reason: string;
7
+ }[];
8
+ };
@@ -0,0 +1,5 @@
1
+ interface AddLintOptions {
2
+ manager?: 'pnpm' | 'npm' | 'yarn' | 'bun';
3
+ }
4
+ export default function addLint(_options?: AddLintOptions): Promise<void>;
5
+ export {};
@@ -0,0 +1 @@
1
+ export default function createCoreSchema(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function createDatasource(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function createProgram(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function createResponse(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function createSchemaRule(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function createTranslationManager(): Promise<void>;
@@ -1,8 +1,6 @@
1
1
  export { default as createCoreSchema } from './createCoreSchema.js';
2
2
  export { default as createTranslationManager } from './createTranslationManager.js';
3
- export { default as createPresenterFactory } from './createPresenterFactory.js';
4
3
  export { default as createSchemaRule } from './createSchemaRule.js';
5
4
  export { default as createResponse } from './createResponse.js';
6
5
  export { default as createDatasource } from './createDatasource.js';
7
- export { default as createDatasourceProvider } from './createDatasourceProvider.js';
8
6
  export { default as createProgram } from './createProgram.js';
@@ -0,0 +1,2 @@
1
+ /** Only initialize an empty generated DI; never replace application-specific registrations. */
2
+ export declare function registerDatasource(className: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function updateDefaultFactoryConfig(content: string, key: 'defaultSchemaFactory', name: string): string;
@@ -0,0 +1,31 @@
1
+ export declare const SHARED_CONTEXT = "SharedKernel";
2
+ export declare const SHARED_WORKSPACE = "Shared";
3
+ export declare const ARCHITECTURE_ALIASES: {
4
+ readonly '#contexts': "./src/app/Contexts";
5
+ readonly '#presentation': "./src/app/Presentation";
6
+ readonly '#platform': "./src/app/Platform";
7
+ };
8
+ export declare const CONTEXT_DIRS: readonly ["Domain/Entities", "Domain/Ports", "Domain/Enums", "Application/UseCases", "Infrastructure/Repositories"];
9
+ export declare const PRESENTATION_DIRS: readonly ["Ui", "Scopes", "Shell"];
10
+ export declare function normalizePascalName(value: string): string;
11
+ export declare const getAppPath: (cwd?: string) => string;
12
+ export declare const getContextsPath: (cwd?: string) => string;
13
+ export declare const getContextPath: (context: string, cwd?: string) => string;
14
+ export declare const getPresentationPath: (workspace?: string, cwd?: string) => string;
15
+ export declare const getPlatformPath: (cwd?: string) => string;
16
+ export declare const getContextImportPath: (context: string) => string;
17
+ export declare const getPresentationImportPath: (workspace?: string) => string;
18
+ export declare const discoverContexts: (cwd?: string) => Promise<string[]>;
19
+ export declare const discoverPresentationWorkspaces: (cwd?: string) => Promise<string[]>;
20
+ export declare function ensureContextStructure(context: string, cwd?: string): Promise<string>;
21
+ export declare function ensurePresentationStructure(workspace?: string, cwd?: string): Promise<void>;
22
+ export declare function selectContext(message?: string): Promise<string | null>;
23
+ /** null means cancelled; undefined means the flat Presentation layout. */
24
+ export declare function selectPresentationWorkspace(message?: string): Promise<string | null | undefined>;
25
+ export type PresentationWorkspace = {
26
+ name: string;
27
+ path: string;
28
+ alias: string;
29
+ };
30
+ export declare function selectWorkspace(): Promise<PresentationWorkspace | null>;
31
+ export declare function selectScope(workspace: PresentationWorkspace): Promise<string | null>;
@@ -0,0 +1,6 @@
1
+ export { getContextPath, selectContext, selectPresentationWorkspace, discoverContexts, discoverPresentationWorkspaces, normalizePascalName } from './architecture.js';
2
+ export declare function getAvailableFiles(dir: string, pattern?: string): Promise<string[]>;
3
+ export declare function getApplicationProviderServices(): Promise<string[]>;
4
+ export declare function toPascalCase(str: string): string;
5
+ export declare function toCamelCase(str: string): string;
6
+ export declare function toKebabCase(str: string): string;
@@ -0,0 +1,5 @@
1
+ export declare function writeIfNotExists(filepath: string, content: string): Promise<boolean>;
2
+ export declare function appendBarrelExports(filepath: string, sources: string[]): Promise<void>;
3
+ export declare function updateIndexTs(dir: string, filePattern?: string, ignore?: string[]): Promise<void>;
4
+ export declare function ensureIndexExports(layerPath: string): Promise<void>;
5
+ export declare function injectIntoFile(filepath: string, searchPattern: string, newContent: string, position?: 'after' | 'before'): Promise<boolean>;
@@ -0,0 +1,2 @@
1
+ /** Flatten literal-only spreads without evaluating user configuration or duplicating effects. */
2
+ export declare function flattenConfigLiterals(content: string): string;
@@ -0,0 +1 @@
1
+ export declare function mergeAliasesInSvelteConfig(content: string, aliases: Record<string, string>): string;
@@ -0,0 +1,16 @@
1
+ export type AzureNetConfig = {
2
+ presentationWorkspaces?: string[];
3
+ runChecksBeforePush?: boolean;
4
+ packageManager?: string;
5
+ defaultSchemaFactory?: string;
6
+ groupRoutesFunc?: unknown;
7
+ [key: string]: unknown;
8
+ };
9
+ export declare function resolveConfigFile(cwd?: string): {
10
+ exists: boolean;
11
+ filepath: string;
12
+ type: 'ts' | 'js';
13
+ };
14
+ export declare function loadUserConfig(cwd?: string): Promise<AzureNetConfig>;
15
+ /** Add the default without rewriting or dropping legacy/user configuration. */
16
+ export declare function initializeConfigDefaults(cwd?: string): Promise<void>;
@@ -0,0 +1,4 @@
1
+ export declare const PACKAGE_IMPORTS: any;
2
+ export declare function mergePackageImports(content: string): Promise<string>;
3
+ export declare function initializePackageImports(): Promise<void>;
4
+ export declare function resolvePackageImport(imports: Record<string, unknown>, specifier: string, root: string): string | null;
@@ -0,0 +1,20 @@
1
+ export type FoundationConstruct = 'datasource' | 'presenter' | 'provider' | 'response' | 'schema';
2
+ export type ContextConfig = {
3
+ name: string;
4
+ alias: string;
5
+ };
6
+ export declare const SHARED_ESSENTIALS_DIR_NAME = "Platform";
7
+ export declare function getSharedState(): Promise<{
8
+ contexts: ContextConfig[];
9
+ sharedAlias: string;
10
+ sharedContext: ContextConfig;
11
+ }>;
12
+ export declare const hasSharedAliasConfig: () => Promise<boolean>;
13
+ export declare const getSharedContextRootPath: (name?: string) => string;
14
+ export declare const getSharedEssentialsPath: (...compatibility: [name?: string]) => string;
15
+ export declare const getFoundationRootPath: (...compatibility: [name?: string]) => string;
16
+ export declare const getFoundationConstructPath: (name: string, construct: FoundationConstruct) => string;
17
+ export declare const getFoundationConstructImportPath: (_alias: string, construct: FoundationConstruct) => string;
18
+ export declare const getLocalizationPath: (...compatibility: [name?: string]) => string;
19
+ export declare const getLocalizationImportPath: (...compatibility: [alias?: string]) => string;
20
+ export declare const getConfigFileLabel: () => string;
@@ -0,0 +1,9 @@
1
+ export declare const VITE_CONFIGS: string[];
2
+ export declare const SVELTE_CONFIGS: string[];
3
+ /** Pure config edit; never evaluates a project's configuration. */
4
+ export declare function mergeKitViteConfig(content: string, aliases: Record<string, string>, legacy?: string): string;
5
+ export declare function formatConfig(content: string, file: string): Promise<string>;
6
+ export declare function configureKitProject(): Promise<void>;
7
+ export declare function readStaticAliases(content: string): Record<string, string>;
8
+ /** Hydratable needs Svelte async mode. Preserve all unrelated literal options. */
9
+ export declare function enableHydratable(content: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "5.1.1",
3
+ "version": "6.0.0-next.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -12,11 +12,13 @@
12
12
  "registry": "https://registry.npmjs.org/"
13
13
  },
14
14
  "peerDependencies": {
15
- "@azure-net/kit": ">=5.0.0-4"
15
+ "@azure-net/kit": ">=6.0.0-next.1"
16
16
  },
17
17
  "dependencies": {
18
18
  "commander": "^11",
19
- "prompts": "^2"
19
+ "prompts": "^2",
20
+ "typescript": "^5",
21
+ "prettier": "^3.6.2"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@eslint/js": "^9.31.0",
@@ -24,14 +26,22 @@
24
26
  "@types/prompts": "^2.4.9",
25
27
  "env-cmd": "^11.0.0",
26
28
  "eslint": "^9.31.0",
27
- "prettier": "^3.6.2",
28
- "typescript": "^5",
29
29
  "typescript-eslint": "^8.36.0"
30
30
  },
31
+ "files": [
32
+ "bin/*.js",
33
+ "src/**/*.js",
34
+ "dist/**/*.d.ts",
35
+ "README.md"
36
+ ],
37
+ "engines": {
38
+ "node": ">=22.15.0"
39
+ },
31
40
  "scripts": {
32
- "build": "tsc -p tsconfig.json",
41
+ "build": "node scripts/clean-build.mjs && tsc -p tsconfig.json && node scripts/sync-build.mjs",
33
42
  "typecheck": "tsc --noEmit -p tsconfig.json",
34
43
  "lint": "eslint \"bin/**/*.ts\" \"src/**/*.ts\"",
35
- "format": "prettier --write ."
44
+ "format": "prettier --write .",
45
+ "test": "pnpm build && node --test tests/*.test.mjs"
36
46
  }
37
47
  }
@@ -0,0 +1,154 @@
1
+ import { resolvePackageImport } from '../utils/packageImports.js';
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { readStaticAliases, VITE_CONFIGS, SVELTE_CONFIGS } from '../utils/viteConfig.js';
5
+ import ts from 'typescript';
6
+ export const appRoot = () => path.join(process.cwd(), 'src', 'app');
7
+ export const directories = async (root) => (await fs.readdir(root, { withFileTypes: true }))
8
+ .filter((entry) => entry.isDirectory() && entry.name !== '.backup')
9
+ .map((entry) => entry.name);
10
+ export async function sourceFiles(root) {
11
+ const files = [];
12
+ for (const entry of await fs.readdir(root, { withFileTypes: true })) {
13
+ if (['.backup', 'node_modules', '.git', '.svelte-kit', 'dist'].includes(entry.name))
14
+ continue;
15
+ const file = path.join(root, entry.name);
16
+ if (entry.isDirectory())
17
+ files.push(...(await sourceFiles(file)));
18
+ else if (/\.(?:[cm]?[jt]sx?|svelte)$/.test(entry.name))
19
+ files.push(file);
20
+ }
21
+ return files;
22
+ }
23
+ export function parseSource(content, filename = 'Source.ts') {
24
+ // Mask markup while retaining offsets for accurate Svelte script diagnostics.
25
+ if (filename.endsWith('.svelte')) {
26
+ const pieces = [];
27
+ let end = 0;
28
+ const scripts = /<!--[^]*?-->|<script\b[^>]*>([^]*?)<\/script\s*>/gi;
29
+ for (const match of content.matchAll(scripts)) {
30
+ if (match[1] === undefined)
31
+ continue;
32
+ const start = match.index + match[0].indexOf('>') + 1;
33
+ pieces.push(content.slice(end, start).replace(/[^\r\n]/g, ' '), match[1]);
34
+ end = start + match[1].length;
35
+ }
36
+ pieces.push(content.slice(end).replace(/[^\r\n]/g, ' '));
37
+ content = pieces.join('');
38
+ }
39
+ return ts.createSourceFile(filename, content, ts.ScriptTarget.Latest, true, /\.[jt]sx$/.test(filename) ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
40
+ }
41
+ export function dependencies(content, filename = 'Source.ts') {
42
+ const result = [];
43
+ const sourceFile = parseSource(content, filename);
44
+ const add = (literal, node, kind) => {
45
+ if (!literal || (!ts.isStringLiteral(literal) && !ts.isNoSubstitutionTemplateLiteral(literal)))
46
+ return;
47
+ result.push({ source: literal.text, line: sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1, kind });
48
+ };
49
+ const visit = (node) => {
50
+ if (ts.isImportDeclaration(node)) {
51
+ const clause = node.importClause;
52
+ const bindings = clause?.namedBindings;
53
+ const inlineTypes = !clause?.name &&
54
+ bindings &&
55
+ ts.isNamedImports(bindings) &&
56
+ bindings.elements.length > 0 &&
57
+ bindings.elements.every((element) => element.isTypeOnly);
58
+ add(node.moduleSpecifier, node, !clause ? 'side-effect' : clause.isTypeOnly || inlineTypes ? 'type' : 'value');
59
+ }
60
+ else if (ts.isExportDeclaration(node))
61
+ add(node.moduleSpecifier, node, 'export');
62
+ else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword)
63
+ add(node.arguments[0], node, 'dynamic');
64
+ else if (ts.isImportTypeNode(node) && ts.isLiteralTypeNode(node.argument))
65
+ add(node.argument.literal, node, 'dynamic');
66
+ else if (ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference))
67
+ add(node.moduleReference.expression, node, node.isTypeOnly ? 'type' : 'value');
68
+ ts.forEachChild(node, visit);
69
+ };
70
+ visit(sourceFile);
71
+ return result;
72
+ }
73
+ export function exportOnly(content) {
74
+ return parseSource(content).statements.every((node) => ts.isExportDeclaration(node) || ts.isEmptyStatement(node));
75
+ }
76
+ export async function importResolver() {
77
+ const aliases = {
78
+ '#contexts': 'src/app/Contexts',
79
+ '#presentation': 'src/app/Presentation',
80
+ '#platform': 'src/app/Platform',
81
+ $lib: 'src/lib',
82
+ '#lib': 'src/lib'
83
+ };
84
+ for (const name of [...VITE_CONFIGS, ...SVELTE_CONFIGS]) {
85
+ const configPath = path.join(process.cwd(), name);
86
+ try {
87
+ await fs.access(configPath);
88
+ }
89
+ catch {
90
+ continue;
91
+ }
92
+ Object.assign(aliases, readStaticAliases(await fs.readFile(configPath, 'utf8')));
93
+ break;
94
+ }
95
+ let imports = {};
96
+ try {
97
+ imports = JSON.parse(await fs.readFile(path.join(process.cwd(), 'package.json'), 'utf8')).imports ?? {};
98
+ }
99
+ catch (error) {
100
+ if (error.code !== 'ENOENT')
101
+ throw error;
102
+ }
103
+ const entries = Object.entries(aliases).sort(([a], [b]) => b.length - a.length);
104
+ return (file, source) => {
105
+ const clean = source[0] + source.slice(1).split(/[?#]/)[0];
106
+ const imported = resolvePackageImport(imports, clean, process.cwd());
107
+ if (imported)
108
+ return imported;
109
+ if (clean.startsWith('.'))
110
+ return path.resolve(path.dirname(file), clean);
111
+ if (path.isAbsolute(clean))
112
+ return path.resolve(clean);
113
+ for (const [key, target] of entries) {
114
+ const alias = key.replace(/\/\*$/, '');
115
+ if (clean !== alias && !clean.startsWith(`${alias}/`))
116
+ continue;
117
+ return path.resolve(process.cwd(), target.replace(/\/\*$/, ''), clean.slice(alias.length).replace(/^\//, ''));
118
+ }
119
+ return null;
120
+ };
121
+ }
122
+ export function location(file) {
123
+ return path.relative(appRoot(), file).split(path.sep);
124
+ }
125
+ export function report(label, issues) {
126
+ if (!issues.length) {
127
+ console.log(`${label} check passed.`);
128
+ return;
129
+ }
130
+ console.error(`${label} check failed:`);
131
+ for (const issue of issues)
132
+ console.error(`${path.relative(process.cwd(), issue.file)}:${issue.line} - ${issue.message}`);
133
+ process.exitCode = 1;
134
+ }
135
+ export async function checkDependencies(label, rule) {
136
+ const issues = [];
137
+ try {
138
+ const resolve = await importResolver();
139
+ for (const file of await sourceFiles(appRoot())) {
140
+ for (const entry of dependencies(await fs.readFile(file, 'utf8'), file)) {
141
+ const target = resolve(file, entry.source);
142
+ if (!target)
143
+ continue;
144
+ const message = rule(location(file), location(target));
145
+ if (message)
146
+ issues.push({ file, line: entry.line, message: `${message} (${entry.source})` });
147
+ }
148
+ }
149
+ }
150
+ catch (error) {
151
+ issues.push({ file: appRoot(), line: 1, message: String(error) });
152
+ }
153
+ report(label, issues);
154
+ }