@sixbell-telco/sdk-tools 0.0.0 → 0.1.1
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/CHANGELOG.md +38 -0
- package/README.md +277 -2
- package/data/security-floors.json +47 -0
- package/package.json +40 -4
- package/recipes/README.md +53 -0
- package/recipes/crud-list.md +21 -0
- package/recipes/custom-component.md +35 -0
- package/recipes/detail-page.md +19 -0
- package/recipes/form-dialog.md +17 -0
- package/recipes/parts/crud-list/i18n.json +83 -0
- package/recipes/parts/crud-list/src/app/features/__name__/__name__.routes.ts.tpl +30 -0
- package/recipes/parts/crud-list/src/app/features/__name__/pages/__name__-list/__name__-list.component.html.tpl +102 -0
- package/recipes/parts/crud-list/src/app/features/__name__/pages/__name__-list/__name__-list.component.spec.ts.tpl +101 -0
- package/recipes/parts/crud-list/src/app/features/__name__/pages/__name__-list/__name__-list.component.ts.tpl +143 -0
- package/recipes/parts/detail-page/i18n.json +32 -0
- package/recipes/parts/detail-page/src/app/features/__name__/pages/__name__-detail/__name__-detail.component.html.tpl +35 -0
- package/recipes/parts/detail-page/src/app/features/__name__/pages/__name__-detail/__name__-detail.component.spec.ts.tpl +58 -0
- package/recipes/parts/detail-page/src/app/features/__name__/pages/__name__-detail/__name__-detail.component.ts.tpl +68 -0
- package/recipes/parts/entity/i18n.json +5 -0
- package/recipes/parts/entity/src/app/features/__name__/__name__.model.ts.tpl +9 -0
- package/recipes/parts/entity/src/app/features/__name__/__name__.service.spec.ts.tpl +29 -0
- package/recipes/parts/entity/src/app/features/__name__/__name__.service.ts.tpl +33 -0
- package/recipes/parts/form-dialog/i18n.json +35 -0
- package/recipes/parts/form-dialog/src/app/features/__name__/components/__name__-form-dialog/__name__-form-dialog.component.html.tpl +33 -0
- package/recipes/parts/form-dialog/src/app/features/__name__/components/__name__-form-dialog/__name__-form-dialog.component.spec.ts.tpl +69 -0
- package/recipes/parts/form-dialog/src/app/features/__name__/components/__name__-form-dialog/__name__-form-dialog.component.ts.tpl +73 -0
- package/src/add/add.mjs +251 -0
- package/src/check/config.mjs +112 -0
- package/src/check/exceptions.mjs +103 -0
- package/src/check/federation.mjs +224 -0
- package/src/check/finding.mjs +23 -0
- package/src/check/harness.mjs +146 -0
- package/src/check/i18n.mjs +218 -0
- package/src/check/integration.mjs +566 -0
- package/src/check/security.mjs +165 -0
- package/src/check/steps.mjs +37 -0
- package/src/check/styles.mjs +347 -0
- package/src/check/wiring.mjs +198 -0
- package/src/check.mjs +333 -0
- package/src/cli.mjs +551 -0
- package/src/docs/docs.mjs +154 -0
- package/src/doctor/doctor.mjs +492 -0
- package/src/format.mjs +102 -0
- package/src/info/info.mjs +149 -0
- package/src/init/init.mjs +490 -0
- package/src/init/merge.mjs +191 -0
- package/src/init/template.mjs +292 -0
- package/src/mcp/catalog.mjs +248 -0
- package/src/mcp/glossary.mjs +75 -0
- package/src/mcp/manifest.mjs +53 -0
- package/src/mcp/recipes.mjs +198 -0
- package/src/mcp/server.mjs +249 -0
- package/src/mcp/upgrade-guide.mjs +116 -0
- package/src/mcp/usage.mjs +48 -0
- package/src/project/project.mjs +220 -0
- package/src/types.d.ts +448 -0
- package/src/upgrade/lockstep.mjs +153 -0
- package/src/upgrade/upgrade.mjs +623 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One read of an app's project files, shared by `check` and later `info`, `doctor` and
|
|
3
|
+
* `check --integration`: the MFE role (host or child), federation.config.js (name, exposes,
|
|
4
|
+
* remotes, shared and skip lists), angular.json targets, package.json and the installed packages.
|
|
5
|
+
* Nothing here runs the project's code: federation.config.js is read as text.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
8
|
+
import { join, relative, sep } from 'node:path';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import('../types.js').ProjectInfo} ProjectInfo
|
|
12
|
+
* @typedef {import('../types.js').FederationConfig} FederationConfig
|
|
13
|
+
* @typedef {import('../types.js').AngularWorkspace} AngularWorkspace
|
|
14
|
+
* @typedef {import('../types.js').PackageJson} PackageJson
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} root
|
|
19
|
+
* @param {string} file
|
|
20
|
+
* @returns {string | null}
|
|
21
|
+
*/
|
|
22
|
+
export function readText(root, file) {
|
|
23
|
+
try {
|
|
24
|
+
return readFileSync(join(root, file), 'utf8');
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {string} root
|
|
32
|
+
* @param {string} file
|
|
33
|
+
* @returns {any}
|
|
34
|
+
*/
|
|
35
|
+
export function readJson(root, file) {
|
|
36
|
+
const text = readText(root, file);
|
|
37
|
+
if (text === null) return null;
|
|
38
|
+
try {
|
|
39
|
+
return JSON.parse(text);
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const SKIPPED_DIRS = new Set(['node_modules', 'dist', 'coverage', '.angular', '.git']);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Files under `dir` (relative to `root`, with `/` separators), skipping build output and dot folders.
|
|
49
|
+
* @param {string} root
|
|
50
|
+
* @param {string} dir
|
|
51
|
+
* @param {(file: string) => boolean} [filter]
|
|
52
|
+
* @returns {string[]}
|
|
53
|
+
*/
|
|
54
|
+
export function walk(root, dir, filter = () => true) {
|
|
55
|
+
/** @type {string[]} */
|
|
56
|
+
const files = [];
|
|
57
|
+
/** @param {string} absolute */
|
|
58
|
+
const visit = (absolute) => {
|
|
59
|
+
let entries;
|
|
60
|
+
try {
|
|
61
|
+
entries = readdirSync(absolute);
|
|
62
|
+
} catch {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
for (const name of entries.sort()) {
|
|
66
|
+
if (SKIPPED_DIRS.has(name) || name.startsWith('.')) continue;
|
|
67
|
+
const path = join(absolute, name);
|
|
68
|
+
if (statSync(path).isDirectory()) visit(path);
|
|
69
|
+
else {
|
|
70
|
+
const file = relative(root, path).split(sep).join('/');
|
|
71
|
+
if (filter(file)) files.push(file);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
visit(join(root, dir));
|
|
76
|
+
return files;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The text of the bracket-matched block that opens at `open` (`{` or `[`), or ''.
|
|
81
|
+
* @param {string} text
|
|
82
|
+
* @param {number} open
|
|
83
|
+
*/
|
|
84
|
+
function matchedBlock(text, open) {
|
|
85
|
+
const close = text[open] === '{' ? '}' : ']';
|
|
86
|
+
let depth = 0;
|
|
87
|
+
for (let index = open; index < text.length; index += 1) {
|
|
88
|
+
if (text[index] === text[open]) depth += 1;
|
|
89
|
+
else if (text[index] === close && --depth === 0) return text.slice(open, index + 1);
|
|
90
|
+
}
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The block after `key:` (an object or array literal), or ''.
|
|
96
|
+
* @param {string} text
|
|
97
|
+
* @param {string} key
|
|
98
|
+
*/
|
|
99
|
+
function propertyBlock(text, key) {
|
|
100
|
+
const match = new RegExp(`\\b${key}\\s*:\\s*([[{])`).exec(text);
|
|
101
|
+
return match ? matchedBlock(text, match.index + match[0].length - 1) : '';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** @param {string} source */
|
|
105
|
+
function stripComments(source) {
|
|
106
|
+
return source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:'"`\\])\/\/.*$/gm, '$1');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* federation.config.js read as text (the file is CommonJS that requires the federation builder).
|
|
111
|
+
* @param {string} source
|
|
112
|
+
* @returns {Omit<FederationConfig, 'file'>}
|
|
113
|
+
*/
|
|
114
|
+
export function parseFederationConfig(source) {
|
|
115
|
+
const code = stripComments(source);
|
|
116
|
+
/** @param {string} block */
|
|
117
|
+
const pairs = (block) =>
|
|
118
|
+
Object.fromEntries([...block.matchAll(/(?:['"]([^'"]+)['"]|([\w$]+))\s*:\s*['"]([^'"]+)['"]/g)].map((match) => [match[1] ?? match[2], match[3]]));
|
|
119
|
+
const shared = propertyBlock(code, 'shared');
|
|
120
|
+
const skip = propertyBlock(code, 'skip');
|
|
121
|
+
return {
|
|
122
|
+
source,
|
|
123
|
+
name: /\bname\s*:\s*['"]([^'"]+)['"]/.exec(code)?.[1] ?? null,
|
|
124
|
+
exposes: pairs(propertyBlock(code, 'exposes')),
|
|
125
|
+
remotes: pairs(propertyBlock(code, 'remotes')),
|
|
126
|
+
shared: {
|
|
127
|
+
shareAll: /\bshareAll\s*\(/.test(shared),
|
|
128
|
+
packages: [...new Set([...shared.matchAll(/(?:^|[{,]\s*)['"]?([@\w][\w@/.-]*)['"]?\s*:\s*\{/gm)].map((match) => match[1]))].filter(
|
|
129
|
+
(name) => name !== 'packageInfo',
|
|
130
|
+
),
|
|
131
|
+
},
|
|
132
|
+
skip: [...skip.matchAll(/['"]([^'"]+)['"]/g)].map((match) => match[1]),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The project's angular.json, reduced to what the checks read.
|
|
138
|
+
* @param {string} root
|
|
139
|
+
* @returns {AngularWorkspace | null}
|
|
140
|
+
*/
|
|
141
|
+
function readAngular(root) {
|
|
142
|
+
const angular = readJson(root, 'angular.json');
|
|
143
|
+
if (!angular || typeof angular !== 'object') return null;
|
|
144
|
+
/** @type {AngularWorkspace['projects']} */
|
|
145
|
+
const projects = {};
|
|
146
|
+
for (const [name, project] of Object.entries(angular.projects ?? {})) {
|
|
147
|
+
const value = /** @type {any} */ (project);
|
|
148
|
+
projects[name] = { root: value?.root ?? '', sourceRoot: value?.sourceRoot ?? 'src', targets: value?.architect ?? value?.targets ?? {} };
|
|
149
|
+
}
|
|
150
|
+
const names = Object.keys(projects);
|
|
151
|
+
const defaultProject = angular.defaultProject && projects[angular.defaultProject] ? angular.defaultProject : (names[0] ?? null);
|
|
152
|
+
return { defaultProject, projects };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Versions installed in the project: package-lock.json `packages` (every nested copy), else the
|
|
157
|
+
* top-level node_modules package.json files that are asked for.
|
|
158
|
+
* @param {string} root
|
|
159
|
+
* @returns {(name: string) => { path: string, version: string }[]}
|
|
160
|
+
*/
|
|
161
|
+
function installedReader(root) {
|
|
162
|
+
const lock = readJson(root, 'package-lock.json');
|
|
163
|
+
/** @type {Map<string, { path: string, version: string }[]>} */
|
|
164
|
+
const byName = new Map();
|
|
165
|
+
for (const [path, entry] of Object.entries(lock?.packages ?? {})) {
|
|
166
|
+
const at = path.lastIndexOf('node_modules/');
|
|
167
|
+
const version = /** @type {{ version?: string }} */ (entry)?.version;
|
|
168
|
+
if (at === -1 || typeof version !== 'string') continue;
|
|
169
|
+
const name = path.slice(at + 'node_modules/'.length);
|
|
170
|
+
byName.set(name, [...(byName.get(name) ?? []), { path, version }]);
|
|
171
|
+
}
|
|
172
|
+
return (name) => {
|
|
173
|
+
const fromLock = byName.get(name);
|
|
174
|
+
if (fromLock) return fromLock;
|
|
175
|
+
const version = readJson(root, `node_modules/${name}/package.json`)?.version;
|
|
176
|
+
return typeof version === 'string' ? [{ path: `node_modules/${name}`, version }] : [];
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Host or child, and why. The product config (`mfe-foundation.config.json` role) wins; else a
|
|
182
|
+
* federation config with exposes is a child; else a federation manifest or loadRemoteModule call
|
|
183
|
+
* makes a host. Anything else (a library, a plain Angular app) has no role.
|
|
184
|
+
* @param {string} root
|
|
185
|
+
* @param {FederationConfig | null} federation
|
|
186
|
+
* @returns {{ role: ProjectInfo['role'], roleSource: string }}
|
|
187
|
+
*/
|
|
188
|
+
function detectRole(root, federation) {
|
|
189
|
+
const configured = readJson(root, 'mfe-foundation.config.json')?.role;
|
|
190
|
+
if (configured === 'host' || configured === 'child') return { role: configured, roleSource: 'mfe-foundation.config.json role' };
|
|
191
|
+
if (federation && Object.keys(federation.exposes).length) return { role: 'child', roleSource: 'federation.config.js exposes' };
|
|
192
|
+
if (existsSync(join(root, 'src/assets/federation/federation.manifest.json')))
|
|
193
|
+
return { role: 'host', roleSource: 'src/assets/federation/federation.manifest.json' };
|
|
194
|
+
if (federation && readText(root, 'src/app/app.routes.ts')?.includes('loadRemoteModule'))
|
|
195
|
+
return { role: 'host', roleSource: 'loadRemoteModule in app.routes.ts' };
|
|
196
|
+
return { role: null, roleSource: federation ? 'federation.config.js without exposes or remotes' : 'no federation.config.js' };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Reads the project at `root` once.
|
|
201
|
+
* @param {string} root
|
|
202
|
+
* @returns {ProjectInfo}
|
|
203
|
+
*/
|
|
204
|
+
export function readProject(root) {
|
|
205
|
+
const federationSource = readText(root, 'federation.config.js');
|
|
206
|
+
/** @type {FederationConfig | null} */
|
|
207
|
+
const federation = federationSource === null ? null : { file: 'federation.config.js', ...parseFederationConfig(federationSource) };
|
|
208
|
+
const manifest = readJson(root, 'src/assets/federation/federation.manifest.json');
|
|
209
|
+
/** @type {PackageJson | null} */
|
|
210
|
+
const packageJson = readJson(root, 'package.json');
|
|
211
|
+
return {
|
|
212
|
+
root,
|
|
213
|
+
...detectRole(root, federation),
|
|
214
|
+
packageJson,
|
|
215
|
+
angular: readAngular(root),
|
|
216
|
+
federation,
|
|
217
|
+
remotes: manifest && typeof manifest === 'object' ? Object.keys(manifest) : Object.keys(federation?.remotes ?? {}),
|
|
218
|
+
installed: installedReader(root),
|
|
219
|
+
};
|
|
220
|
+
}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/** Types for the JavaScript sources of sdk-tools (checked with `checkJs`, see tsconfig.tools.json). */
|
|
2
|
+
|
|
3
|
+
export type Severity = 'error' | 'warn';
|
|
4
|
+
|
|
5
|
+
/** One problem `check` reports, from the lint or the type check. */
|
|
6
|
+
export interface Finding {
|
|
7
|
+
rule: string;
|
|
8
|
+
/**
|
|
9
|
+
* The mfe-tools id (MFE_CHILD_003, UI_BUTTON_BASE_001): a project-step or integration finding's
|
|
10
|
+
* rule, a plugin finding's ESLint messageId. `check` sets it on every finding, null when there is none.
|
|
11
|
+
*/
|
|
12
|
+
id?: string | null;
|
|
13
|
+
/** `check --integration`: the repo the finding is in, relative to --root ('.' for the root itself). */
|
|
14
|
+
repo?: string;
|
|
15
|
+
severity: Severity;
|
|
16
|
+
/** Relative to the checked project; empty for project-level findings. */
|
|
17
|
+
file: string;
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
message: string;
|
|
21
|
+
fixable?: true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Counts {
|
|
25
|
+
errors: number;
|
|
26
|
+
warnings: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CheckResult {
|
|
30
|
+
findings: Finding[];
|
|
31
|
+
counts: Counts;
|
|
32
|
+
/** Findings an `sdk-tools.exceptions.json` entry covers: listed, never counted. */
|
|
33
|
+
excepted?: ExceptedFinding[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** One entry of the app-root `sdk-tools.exceptions.json` (approved through PR review). */
|
|
37
|
+
export interface ExceptionEntry {
|
|
38
|
+
/** The finding's rule or id: an mfe-tools id (DS_COLOR_LITERAL, UI_BUTTON_BASE_001) or a lint rule name (sdk/button-role). */
|
|
39
|
+
rule: string;
|
|
40
|
+
/** Glob over the finding's file, relative to the app root (`*`, `**`, `?`). */
|
|
41
|
+
path: string;
|
|
42
|
+
reason: string;
|
|
43
|
+
owner?: string;
|
|
44
|
+
/** ISO date (YYYY-MM-DD) after which the entry no longer applies and is itself a finding. */
|
|
45
|
+
until?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ExceptedFinding extends Finding {
|
|
49
|
+
exception: ExceptionEntry;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PackageJson {
|
|
53
|
+
name?: string;
|
|
54
|
+
version?: string;
|
|
55
|
+
scripts?: Record<string, string>;
|
|
56
|
+
dependencies?: Record<string, string>;
|
|
57
|
+
devDependencies?: Record<string, string>;
|
|
58
|
+
optionalDependencies?: Record<string, string>;
|
|
59
|
+
peerDependencies?: Record<string, string>;
|
|
60
|
+
overrides?: Record<string, unknown>;
|
|
61
|
+
engines?: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface FederationConfig {
|
|
65
|
+
file: string;
|
|
66
|
+
source: string;
|
|
67
|
+
name: string | null;
|
|
68
|
+
/** Expose key to the source file it points at. */
|
|
69
|
+
exposes: Record<string, string>;
|
|
70
|
+
remotes: Record<string, string>;
|
|
71
|
+
shared: { shareAll: boolean; packages: string[] };
|
|
72
|
+
skip: string[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface AngularTarget {
|
|
76
|
+
builder?: string;
|
|
77
|
+
options?: Record<string, any>;
|
|
78
|
+
configurations?: Record<string, Record<string, any>>;
|
|
79
|
+
defaultConfiguration?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface AngularWorkspace {
|
|
83
|
+
defaultProject: string | null;
|
|
84
|
+
projects: Record<string, { root: string; sourceRoot: string; targets: Record<string, AngularTarget> }>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** What the project steps of `check` (and later `info` and `doctor`) know about an app. */
|
|
88
|
+
export interface ProjectInfo {
|
|
89
|
+
root: string;
|
|
90
|
+
/** null: not a federated MFE (a library or a plain Angular app); role-specific steps are skipped. */
|
|
91
|
+
role: 'host' | 'child' | null;
|
|
92
|
+
roleSource: string;
|
|
93
|
+
packageJson: PackageJson | null;
|
|
94
|
+
angular: AngularWorkspace | null;
|
|
95
|
+
federation: FederationConfig | null;
|
|
96
|
+
/** Remote names: the host's federation manifest keys, else federation.config.js remotes. */
|
|
97
|
+
remotes: string[];
|
|
98
|
+
/** Every installed copy of a package (package-lock.json, else node_modules). */
|
|
99
|
+
installed: (name: string) => { path: string; version: string }[];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** One project-level step of `check`: reads the project, returns findings. */
|
|
103
|
+
export type ProjectStep = (project: ProjectInfo) => Finding[];
|
|
104
|
+
|
|
105
|
+
export interface CheckOptions {
|
|
106
|
+
cwd?: string;
|
|
107
|
+
paths?: string[];
|
|
108
|
+
fix?: boolean;
|
|
109
|
+
typecheck?: boolean;
|
|
110
|
+
project?: string;
|
|
111
|
+
manifestPath?: string;
|
|
112
|
+
/** Run the project steps (federation, harness, wiring, config, i18n, styles, security). Default: when the paths cover the whole app (src or .). */
|
|
113
|
+
projectSteps?: boolean;
|
|
114
|
+
/** Override the date expired exceptions are judged against (tests). */
|
|
115
|
+
today?: string;
|
|
116
|
+
onProgress?: (message: string) => void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The JSON envelope every `--json` run prints: one line on stdout. */
|
|
120
|
+
export interface Envelope<T = unknown> {
|
|
121
|
+
ok: boolean;
|
|
122
|
+
/** 0 ok, 1 findings or failure, 2 usage error, 3 blocked by a pre-check. */
|
|
123
|
+
code: 0 | 1 | 2 | 3;
|
|
124
|
+
data: T | null;
|
|
125
|
+
error?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The manifest the MCP answers from, and where it was read. */
|
|
129
|
+
export interface LoadedManifest {
|
|
130
|
+
path: string;
|
|
131
|
+
manifest: import('../../eslint-plugin-sdk/src/types.js').Manifest;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** One line of list_components and search_components. */
|
|
135
|
+
export interface ComponentSummary {
|
|
136
|
+
selector: string;
|
|
137
|
+
name: string;
|
|
138
|
+
kind: 'component' | 'directive' | 'pipe';
|
|
139
|
+
entryPoint: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
deprecated?: string | true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** get_component: one declaration's API from the installed manifest. */
|
|
145
|
+
export interface ComponentDetail extends ComponentSummary {
|
|
146
|
+
sdkVersion: string;
|
|
147
|
+
import: string;
|
|
148
|
+
inputs: {
|
|
149
|
+
name: string;
|
|
150
|
+
type: string;
|
|
151
|
+
values?: string[];
|
|
152
|
+
default?: string;
|
|
153
|
+
required?: true;
|
|
154
|
+
twoWay?: true;
|
|
155
|
+
bareAttribute?: true;
|
|
156
|
+
deprecated?: string | true;
|
|
157
|
+
description?: string;
|
|
158
|
+
}[];
|
|
159
|
+
outputs: { name: string; type: string; deprecated?: string | true; description?: string }[];
|
|
160
|
+
slots: string[];
|
|
161
|
+
related: string[];
|
|
162
|
+
example: string;
|
|
163
|
+
stories: { id: string; url: string }[];
|
|
164
|
+
do: string[];
|
|
165
|
+
dont: string[];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** A recipe of the registry (`projects/sdk-tools/recipes/<id>.md`). */
|
|
169
|
+
export interface Recipe {
|
|
170
|
+
id: string;
|
|
171
|
+
title: string;
|
|
172
|
+
summary: string;
|
|
173
|
+
/** The recipe builds local code the kit could adopt later. */
|
|
174
|
+
kitCandidate: boolean;
|
|
175
|
+
tags: string[];
|
|
176
|
+
body: string;
|
|
177
|
+
/** The template parts (`recipes/parts/<part>/`) whose files `sdk-tools add` writes, in order. */
|
|
178
|
+
parts: string[];
|
|
179
|
+
/** The files `sdk-tools add` writes, with `<name>` for the feature name. */
|
|
180
|
+
files: RecipeFile[];
|
|
181
|
+
/** The i18n keys `sdk-tools add` merges, under `<app>.<name>`. */
|
|
182
|
+
i18nKeys: string[];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface RecipeFile {
|
|
186
|
+
/** Target path in the app, with `<name>` for the feature name. */
|
|
187
|
+
path: string;
|
|
188
|
+
/** From a part the recipe includes (not its own): an existing copy is kept, never a conflict. */
|
|
189
|
+
shared: boolean;
|
|
190
|
+
/** The template part it comes from. */
|
|
191
|
+
part: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
|
|
195
|
+
|
|
196
|
+
/** The MFE kind `init` creates or upgrades; each has its template repo. */
|
|
197
|
+
export type InitRole = 'host' | 'child';
|
|
198
|
+
|
|
199
|
+
/** Where `init` read the template from. */
|
|
200
|
+
export interface TemplateSource {
|
|
201
|
+
/** GitHub name, `org/repo`. */
|
|
202
|
+
repo: string;
|
|
203
|
+
/** `path`: --template; `local`: a checkout found by its origin remote; `cache`: a clone in the cache. */
|
|
204
|
+
source: 'path' | 'local' | 'cache';
|
|
205
|
+
path: string;
|
|
206
|
+
/** HEAD of the template checkout; null for a plain folder. */
|
|
207
|
+
commit: string | null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface InitOptions {
|
|
211
|
+
cwd?: string;
|
|
212
|
+
/** The app folder, relative to cwd (default cwd). */
|
|
213
|
+
dir?: string;
|
|
214
|
+
role?: InitRole;
|
|
215
|
+
dryRun?: boolean;
|
|
216
|
+
templateDir?: string;
|
|
217
|
+
/** Folders to search for a local template checkout. */
|
|
218
|
+
roots?: string[];
|
|
219
|
+
offline?: boolean;
|
|
220
|
+
/** Project name of a new app (default: the folder name). */
|
|
221
|
+
name?: string;
|
|
222
|
+
/** Display name of a new app (default: the project name in title case). */
|
|
223
|
+
displayName?: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface InitOperation {
|
|
227
|
+
path: string;
|
|
228
|
+
action: 'add' | 'update' | 'merge';
|
|
229
|
+
reason: string;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface InitNote {
|
|
233
|
+
path: string;
|
|
234
|
+
reason: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** What `init` did, or would do with --dry-run. */
|
|
238
|
+
export interface InitPlan {
|
|
239
|
+
mode: 'new' | 'upgrade';
|
|
240
|
+
role: InitRole;
|
|
241
|
+
root: string;
|
|
242
|
+
dryRun: boolean;
|
|
243
|
+
/** True when files were written. */
|
|
244
|
+
applied: boolean;
|
|
245
|
+
template: TemplateSource;
|
|
246
|
+
identity: { projectName: string; displayName: string | null };
|
|
247
|
+
operations: InitOperation[];
|
|
248
|
+
/** Files init does not touch and a person must merge (fail closed). */
|
|
249
|
+
manual: InitNote[];
|
|
250
|
+
/** Files the product changed whose product copy stays. */
|
|
251
|
+
kept: InitNote[];
|
|
252
|
+
counts: { add: number; update: number; merge: number; manual: number; kept: number; unchanged: number; skipped: number };
|
|
253
|
+
/** Commands to run after an apply. */
|
|
254
|
+
next: string[];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** One item an `ng update` migration of the SDK logged (its `sdkUpgrade` log metadata). */
|
|
258
|
+
export interface UpgradeItem {
|
|
259
|
+
kind: 'applied' | 'manual';
|
|
260
|
+
migration: string;
|
|
261
|
+
rule: string;
|
|
262
|
+
file: string;
|
|
263
|
+
line?: number;
|
|
264
|
+
message: string;
|
|
265
|
+
/** The version of a step no migration applies (manual-steps.json); dropped when the app is past it. */
|
|
266
|
+
since?: string;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** An app found below the fleet search roots by `upgrade`'s lockstep check. */
|
|
270
|
+
export interface FleetApp {
|
|
271
|
+
dir: string;
|
|
272
|
+
/** `org/name` of its origin remote, lowercased. */
|
|
273
|
+
origin: string | null;
|
|
274
|
+
role: 'host' | 'child' | null;
|
|
275
|
+
/** Federation name (mfe-foundation.config.json identity.projectName, else federation.config.js name). */
|
|
276
|
+
name: string | null;
|
|
277
|
+
remotes: { name: string; repo?: string }[] | null;
|
|
278
|
+
source: string | null;
|
|
279
|
+
/** Installed @sixbell-telco/sdk version. */
|
|
280
|
+
sdk: string | null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** The federation lockstep check of `upgrade`. */
|
|
284
|
+
export interface Lockstep {
|
|
285
|
+
role: 'host' | 'child' | null;
|
|
286
|
+
searched: string[];
|
|
287
|
+
mismatched: { name: string; dir: string; sdk: string | null }[];
|
|
288
|
+
matched: { name: string; dir: string; sdk: string | null }[];
|
|
289
|
+
/** Remotes with no local checkout: a warning, never a block. */
|
|
290
|
+
unknown: { name: string; repo?: string }[];
|
|
291
|
+
/** In a child: hosts found locally that load it. */
|
|
292
|
+
hosts: { name: string; dir: string; sdk: string | null }[];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** A pre-check of `upgrade`; `unblock` says what to do when it fails. */
|
|
296
|
+
export interface Precheck {
|
|
297
|
+
id: string;
|
|
298
|
+
ok: boolean;
|
|
299
|
+
message: string;
|
|
300
|
+
unblock?: string;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** A problem left after the upgrade: a migration error, a failed install or a `check` error. */
|
|
304
|
+
export interface UpgradeFailure {
|
|
305
|
+
rule: string;
|
|
306
|
+
file: string;
|
|
307
|
+
line?: number;
|
|
308
|
+
message: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface UpgradeOptions {
|
|
312
|
+
cwd?: string;
|
|
313
|
+
/** A version, a dist-tag or a path to a packed .tgz; the latest release when omitted. */
|
|
314
|
+
to?: string;
|
|
315
|
+
dryRun?: boolean;
|
|
316
|
+
/** Run `check` after the migrations (default true). */
|
|
317
|
+
check?: boolean;
|
|
318
|
+
/** Where to look for the federation's other checkouts (default SDK_TOOLS_FLEET_ROOT, else the folders above the app). */
|
|
319
|
+
roots?: string[];
|
|
320
|
+
/** Installs the target instead of `npm install` (tests). */
|
|
321
|
+
install?: (spec: string, cwd: string) => Promise<void> | void;
|
|
322
|
+
onProgress?: (message: string) => void;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface UpgradeReport {
|
|
326
|
+
dryRun: boolean;
|
|
327
|
+
from: string | null;
|
|
328
|
+
to: string | null;
|
|
329
|
+
source: 'registry' | 'tarball' | null;
|
|
330
|
+
prechecks: Precheck[];
|
|
331
|
+
migrations: { name: string; version: string; description: string }[];
|
|
332
|
+
/** The dry run before anything changes: the inventory of what the migrations will do. */
|
|
333
|
+
planned: { applied: UpgradeItem[]; manual: UpgradeItem[]; files: { path: string; action: string }[] };
|
|
334
|
+
applied: UpgradeItem[];
|
|
335
|
+
manual: UpgradeItem[];
|
|
336
|
+
/** Steps no migration applies (manual-steps.json) for the versions crossed; reminders, not findings. */
|
|
337
|
+
steps: UpgradeItem[];
|
|
338
|
+
failing: UpgradeFailure[];
|
|
339
|
+
files: { path: string; action: string }[];
|
|
340
|
+
warnings: string[];
|
|
341
|
+
/** The app's Prettier over the files the upgrade changed; null on a dry run or when the upgrade stopped before it. */
|
|
342
|
+
format: UpgradeFormat | null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** The format step of `sdk-tools upgrade`. */
|
|
346
|
+
export interface UpgradeFormat {
|
|
347
|
+
tool: 'prettier';
|
|
348
|
+
/** formatted; skipped (no Prettier in the app, or no changed files); failed (also a `format` failure). */
|
|
349
|
+
status: 'formatted' | 'skipped' | 'failed';
|
|
350
|
+
/** The app-relative files passed to `prettier --write`. */
|
|
351
|
+
files: string[];
|
|
352
|
+
reason?: string;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** One file `sdk-tools add` plans. */
|
|
356
|
+
export interface AddFile {
|
|
357
|
+
path: string;
|
|
358
|
+
/** create; overwrite (--force); unchanged (same content); kept (an existing shared file); conflict (refused). */
|
|
359
|
+
action: 'create' | 'overwrite' | 'unchanged' | 'kept' | 'conflict';
|
|
360
|
+
shared: boolean;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** The i18n merge into one `src/assets/i18n/<lang>.json`. */
|
|
364
|
+
export interface AddI18n {
|
|
365
|
+
path: string;
|
|
366
|
+
added: number;
|
|
367
|
+
/** Keys that already existed; their values are never changed. */
|
|
368
|
+
kept: number;
|
|
369
|
+
/** Keys whose shape differs (text vs group): they block the add. */
|
|
370
|
+
conflicts: string[];
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** What `sdk-tools add` did, or would do with --dry-run. */
|
|
374
|
+
export interface AddPlan {
|
|
375
|
+
recipe: string;
|
|
376
|
+
name: string;
|
|
377
|
+
i18nPrefix: string;
|
|
378
|
+
dryRun: boolean;
|
|
379
|
+
force: boolean;
|
|
380
|
+
written: boolean;
|
|
381
|
+
/** A conflict stopped every write. */
|
|
382
|
+
blocked: boolean;
|
|
383
|
+
files: AddFile[];
|
|
384
|
+
i18n: AddI18n[];
|
|
385
|
+
warnings: string[];
|
|
386
|
+
next: string[];
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** `get_upgrade_guide`: what moving between two SDK versions involves, from the installed SDK. */
|
|
390
|
+
export interface UpgradeGuide {
|
|
391
|
+
installed: string;
|
|
392
|
+
from: string;
|
|
393
|
+
to: string;
|
|
394
|
+
migrations: { name: string; version: string; description: string }[];
|
|
395
|
+
manualSteps: { id: string; version: string; step: string }[];
|
|
396
|
+
consumerUpgrade: { version: string; steps: string[] }[];
|
|
397
|
+
command: string;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** `sdk-tools info --json` data (schemaVersion 1). Fields are only ever added. */
|
|
401
|
+
export interface ContextInfo {
|
|
402
|
+
schemaVersion: 1;
|
|
403
|
+
root: string;
|
|
404
|
+
/** package.json name. */
|
|
405
|
+
name: string | null;
|
|
406
|
+
role: 'host' | 'child' | 'none';
|
|
407
|
+
roleSource: string;
|
|
408
|
+
kit: {
|
|
409
|
+
/** The @sixbell-telco/sdk range package.json declares. */
|
|
410
|
+
declared: string | null;
|
|
411
|
+
/** node_modules, else the package-lock.json top-level entry. */
|
|
412
|
+
installed: string | null;
|
|
413
|
+
/** `@sixbell-telco/sdk/...` specifiers imported under src, sorted. */
|
|
414
|
+
entryPoints: string[];
|
|
415
|
+
};
|
|
416
|
+
angular: { declared: string | null; installed: string | null };
|
|
417
|
+
theme: { default: string | null; themes: string[]; source: string | null };
|
|
418
|
+
/** The `layout` block of mfe-foundation.config.json. */
|
|
419
|
+
layout: Record<string, unknown> | null;
|
|
420
|
+
federation: { name: string | null; exposes: Record<string, string>; remotes: string[] } | null;
|
|
421
|
+
files: { designMd: boolean; agentsMd: boolean; foundationConfig: boolean };
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/** A doctor finding: a project finding with the command or edit that fixes it. */
|
|
425
|
+
export interface DoctorFinding extends Finding {
|
|
426
|
+
fix: string;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export interface DoctorReport {
|
|
430
|
+
root: string;
|
|
431
|
+
role: 'host' | 'child' | 'none';
|
|
432
|
+
environment: {
|
|
433
|
+
node: { version: string; required: string | null; ok: boolean };
|
|
434
|
+
npm: { version: string | null; required: string | null; ok: boolean };
|
|
435
|
+
nvmrc: string | null;
|
|
436
|
+
};
|
|
437
|
+
/** The local template checkout drift was judged against; null when none was found or the app is no MFE. */
|
|
438
|
+
template: { repo: string; path: string; source: TemplateSource['source']; commit: string | null } | null;
|
|
439
|
+
findings: DoctorFinding[];
|
|
440
|
+
counts: Counts;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** `sdk-tools docs` data: one component, one recipe, the lists, or near matches. */
|
|
444
|
+
export type DocsResult =
|
|
445
|
+
| { kind: 'component'; component: ComponentDetail }
|
|
446
|
+
| { kind: 'recipe'; recipe: Recipe }
|
|
447
|
+
| { kind: 'list'; sdkVersion: string; components: ComponentSummary[]; recipes: { id: string; title: string; summary: string }[] }
|
|
448
|
+
| { kind: 'not-found'; query: string; sdkVersion: string; suggestions: string[] };
|