@mgamadeus/ddd-web 0.19.1 → 0.19.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.3
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- `ddd-web link-skills` (and the Composer twin `ddd-link-skills` of `mgamadeus/ddd`) linked a skill from a nested,
|
|
7
|
+
older copy of a package (a second npm or Composer root below the repository) because the copies were ordered by
|
|
8
|
+
path. The copy whose install folder lies closest to the repository root (the app's own install) now wins, at the
|
|
9
|
+
same depth the higher version; the skipped copy is printed as a `copy` note (not a problem, `--check` passes).
|
|
10
|
+
|
|
11
|
+
## 0.19.2
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- `mswHandlers`: a path parameter in the URL pattern is an MSW `:param` (one segment) instead of `*` (any segments).
|
|
15
|
+
`*/books/*` also answered `/books/7/archive` and every other deeper path, so a handler could swallow the request of
|
|
16
|
+
another operation and hide a wrong URL. Parameter names are reduced to word characters and kept unique
|
|
17
|
+
(`{file-name}` → `:file_name`). The params a `response` function receives are unchanged. Regenerate the handlers;
|
|
18
|
+
a hand-written `url` override keeps working as it is.
|
|
19
|
+
|
|
20
|
+
### Tests
|
|
21
|
+
- `mswPathPattern` (names, several parameters, duplicates) and a runtime check that `/books/:bookId` leaves
|
|
22
|
+
`/books/7/preview` unanswered.
|
|
23
|
+
|
|
3
24
|
## 0.19.1
|
|
4
25
|
|
|
5
26
|
### Fixed
|
package/README.md
CHANGED
|
@@ -87,7 +87,7 @@ export default defineConfig({
|
|
|
87
87
|
import { adminApiMocks } from './api/adminApiMocks';
|
|
88
88
|
|
|
89
89
|
export const handlers = [
|
|
90
|
-
adminApiMocks.getApiAdminLibraryBooksByBookId(), // GET */api/admin/library/books
|
|
90
|
+
adminApiMocks.getApiAdminLibraryBooksByBookId(), // GET */api/admin/library/books/:bookId → getBookGetResponseDtoMock()
|
|
91
91
|
adminApiMocks.deleteApiAdminLibraryBooksByBookId({ status: 500, delay: 300 }),
|
|
92
92
|
adminApiMocks.getApiAdminLibraryBooksList({ response: (params, defaultMock) => ({ ...defaultMock!, books: { elements: [] } }) }),
|
|
93
93
|
];
|
|
@@ -258,9 +258,14 @@ ddd-web link-skills [--check] [--dry-run] [--quiet] [--root <dir>]
|
|
|
258
258
|
```
|
|
259
259
|
|
|
260
260
|
```json
|
|
261
|
-
{ "scripts": { "postinstall": "ddd-web link-skills" } }
|
|
261
|
+
{ "scripts": { "postinstall": "ddd-web link-skills", "link-skills": "ddd-web link-skills" } }
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
+
With `ignore-scripts=true` (in `.npmrc` or `~/.npmrc`) npm and pnpm run no `postinstall`: an install links nothing.
|
|
265
|
+
Run `npm run link-skills` (or `pnpm link-skills`) after the install — `npm run` runs a named script even then — or
|
|
266
|
+
rely on the Composer hook `ddd-link-skills`, which walks `node_modules/@mgamadeus/*` too and links the npm packages'
|
|
267
|
+
skills on the next Composer run.
|
|
268
|
+
|
|
264
269
|
Programmatic: `runSkillLinks({ cwd, root, check, dryRun, quiet, logger })` from `/codegen` returns a report with
|
|
265
270
|
`exitCode`, `skills`, `lines` and `problems`; `linkSkills()` (one result per skill) stays for existing callers.
|
|
266
271
|
|
|
@@ -278,7 +283,9 @@ postinstall never fight; either one alone links everything.
|
|
|
278
283
|
lies at most three levels below the root (`vendor/`, `app/vendor/`, `apps/admin/node_modules/`); other `vendor/`,
|
|
279
284
|
`node_modules/` and dot folders are not searched, symlinked folders are not followed. A skill is a folder with a
|
|
280
285
|
`SKILL.md`. Order: skill path, byte order. The same name from two packages is a clash: the first is kept and the
|
|
281
|
-
clash reported. The same package installed twice (two Composer roots) is not a clash
|
|
286
|
+
clash reported. The same package installed twice (two Composer or npm roots) is not a clash: the copy whose install folder lies closest
|
|
287
|
+
to the root (the app's own install) is linked, at the same depth the higher version; the skipped copy is reported as a
|
|
288
|
+
note (`copy`), not a problem.
|
|
282
289
|
3. **Primary folder** `<root>/.claude/skills`, created when missing. When `.claude` or `.claude/skills` is a symlink
|
|
283
290
|
(for example to `.codex`), the links go into its real location, once.
|
|
284
291
|
4. **Mirrors** `<root>/.agents/skills` and `<root>/.codex/skills` (Codex): the layout is detected, never changed. A
|
|
@@ -2085,7 +2085,7 @@ function renderMswHandlers(input) {
|
|
|
2085
2085
|
if (shape && local) defaultMock = shape.array ? `[${local}()]` : `${local}()`;
|
|
2086
2086
|
}
|
|
2087
2087
|
if (kind === "text" && responseType === "unknown") responseType = "string";
|
|
2088
|
-
const pattern =
|
|
2088
|
+
const pattern = mswPathPattern(endpoint.path);
|
|
2089
2089
|
const key = IDENTIFIER2.test(endpoint.key) ? endpoint.key : JSON.stringify(endpoint.key);
|
|
2090
2090
|
entries.push(
|
|
2091
2091
|
` ${key}: (custom?: Partial<StoryMock<${responseType}, ${argType}>>) =>
|
|
@@ -2132,7 +2132,7 @@ export type StoryMockParams<Arg> = { [Name in Arg extends object ? Extract<keyof
|
|
|
2132
2132
|
|
|
2133
2133
|
/** How a generated handler answers; the factories take \`Partial<StoryMock<\u2026>>\`. */
|
|
2134
2134
|
export interface StoryMock<Response, Arg = void> {
|
|
2135
|
-
/** URL pattern matched instead of the generated one (any origin + the operation path,
|
|
2135
|
+
/** URL pattern matched instead of the generated one (any origin + the operation path, \`:name\` per path parameter). */
|
|
2136
2136
|
url: string;
|
|
2137
2137
|
/** Default: the operation's first declared 2xx status (200 for a file download). */
|
|
2138
2138
|
status: number;
|
|
@@ -2194,6 +2194,18 @@ const mockOperation = <Response, Arg>(
|
|
|
2194
2194
|
return new HttpResponse(body as unknown as BodyInit, init);
|
|
2195
2195
|
});
|
|
2196
2196
|
`;
|
|
2197
|
+
function mswPathPattern(operationPath) {
|
|
2198
|
+
const used = /* @__PURE__ */ new Set();
|
|
2199
|
+
const path13 = operationPath.replace(/\{([^}]+)\}/g, (_, raw) => {
|
|
2200
|
+
let name = raw.replace(/\W/g, "_") || "param";
|
|
2201
|
+
if (/^\d/.test(name)) name = `p${name}`;
|
|
2202
|
+
let unique = name;
|
|
2203
|
+
for (let index = 2; used.has(unique); index++) unique = `${name}${index}`;
|
|
2204
|
+
used.add(unique);
|
|
2205
|
+
return `:${unique}`;
|
|
2206
|
+
});
|
|
2207
|
+
return `*${path13}`;
|
|
2208
|
+
}
|
|
2197
2209
|
function successStatus(responses) {
|
|
2198
2210
|
const codes = Object.keys(responses ?? {}).filter((code) => /^2\d\d$/.test(code)).map(Number).sort((a, b) => a - b);
|
|
2199
2211
|
return codes[0] ?? 200;
|
|
@@ -2929,6 +2941,7 @@ var SkillLinker = class {
|
|
|
2929
2941
|
}
|
|
2930
2942
|
}
|
|
2931
2943
|
for (const warning of plan.warnings) this.warn(warning);
|
|
2944
|
+
for (const note of plan.notes) this.info(note);
|
|
2932
2945
|
const skillCount = plan.managedSkillNames.length;
|
|
2933
2946
|
const packageCount = plan.packageNames.length;
|
|
2934
2947
|
const changeCount = plan.operations.length;
|
|
@@ -2959,7 +2972,7 @@ var SkillLinker = class {
|
|
|
2959
2972
|
const primary = this.resolvePrimaryDirectory();
|
|
2960
2973
|
const primaryExists = isDirectory(primaryLogical);
|
|
2961
2974
|
if (!primaryExists && winners.size === 0) {
|
|
2962
|
-
return { nothingToDo: true, operations: [], warnings: [], managedSkillNames: [], packageNames: [] };
|
|
2975
|
+
return { nothingToDo: true, operations: [], warnings: [], notes: [], managedSkillNames: [], packageNames: [] };
|
|
2963
2976
|
}
|
|
2964
2977
|
const previousManifestPath = `${primary}/${SKILLS_MANIFEST_FILE_NAME}`;
|
|
2965
2978
|
let previousEntries = readManifestEntries(previousManifestPath);
|
|
@@ -3123,11 +3136,12 @@ var SkillLinker = class {
|
|
|
3123
3136
|
}
|
|
3124
3137
|
const packageNames = /* @__PURE__ */ new Set();
|
|
3125
3138
|
for (const entry of managed.values()) if (typeof entry.package === "string") packageNames.add(entry.package);
|
|
3126
|
-
return { nothingToDo: false, operations, warnings, managedSkillNames: managedNames, packageNames: [...packageNames] };
|
|
3139
|
+
return { nothingToDo: false, operations, warnings, notes: discovery.notes, managedSkillNames: managedNames, packageNames: [...packageNames] };
|
|
3127
3140
|
}
|
|
3128
3141
|
/**
|
|
3129
3142
|
* Skills of all DDD packages below the root in deterministic order (skill path, byte order). The first package
|
|
3130
|
-
* shipping a name wins; another package with the same name is a clash; the same package installed twice is not
|
|
3143
|
+
* shipping a name wins; another package with the same name is a clash; the same package installed twice is not: the
|
|
3144
|
+
* copy closest to the root wins, then the higher version ({@link isPreferredCopyOverOther}); the skipped copy is a note.
|
|
3131
3145
|
*/
|
|
3132
3146
|
discoverSkills() {
|
|
3133
3147
|
const candidates = [];
|
|
@@ -3143,18 +3157,39 @@ var SkillLinker = class {
|
|
|
3143
3157
|
candidates.sort((first, second) => compareBytes(first.directory, second.directory));
|
|
3144
3158
|
const winners = /* @__PURE__ */ new Map();
|
|
3145
3159
|
const warnings = [];
|
|
3160
|
+
const notes = [];
|
|
3146
3161
|
for (const candidate of candidates) {
|
|
3147
3162
|
const winner = winners.get(candidate.name);
|
|
3148
3163
|
if (!winner) {
|
|
3149
3164
|
winners.set(candidate.name, candidate);
|
|
3150
|
-
} else if (winner.package
|
|
3165
|
+
} else if (winner.package === candidate.package) {
|
|
3166
|
+
const preferred = this.isPreferredCopyOverOther(candidate, winner) ? candidate : winner;
|
|
3167
|
+
const skipped = preferred === candidate ? winner : candidate;
|
|
3168
|
+
winners.set(candidate.name, preferred);
|
|
3169
|
+
notes.push(
|
|
3170
|
+
`${label("copy")}${candidate.name}: ${candidate.package} ${preferred.version ?? "?"} (${relativePath(this.root, preferred.directory)}) linked; the copy ${skipped.version ?? "?"} (${relativePath(this.root, skipped.directory)}) skipped`
|
|
3171
|
+
);
|
|
3172
|
+
} else {
|
|
3151
3173
|
warnings.push(
|
|
3152
3174
|
`${label("clash")}${candidate.name}: shipped by ${winner.package} (${relativePath(this.root, winner.directory)}) and ${candidate.package} (${relativePath(this.root, candidate.directory)}); ${winner.package} kept`
|
|
3153
3175
|
);
|
|
3154
3176
|
this.results.push({ skill: candidate.name, action: "skipped", target: relativePath(this.root, candidate.directory), package: candidate.package });
|
|
3155
3177
|
}
|
|
3156
3178
|
}
|
|
3157
|
-
return { winners, warnings };
|
|
3179
|
+
return { winners, warnings, notes };
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Of two copies of the same package that ship one skill name (two Composer or npm roots below the repository), the
|
|
3183
|
+
* app's own install wins: the copy whose install folder lies closest to the root; at the same depth the higher
|
|
3184
|
+
* version; then the first in path order.
|
|
3185
|
+
*/
|
|
3186
|
+
isPreferredCopyOverOther(copy, otherCopy) {
|
|
3187
|
+
const copyDepth = relativePath(this.root, copy.directory).split("/").length;
|
|
3188
|
+
const otherCopyDepth = relativePath(this.root, otherCopy.directory).split("/").length;
|
|
3189
|
+
if (copyDepth !== otherCopyDepth) return copyDepth < otherCopyDepth;
|
|
3190
|
+
const versionComparison = compareVersions(copy.version, otherCopy.version);
|
|
3191
|
+
if (versionComparison !== 0) return versionComparison > 0;
|
|
3192
|
+
return compareBytes(copy.directory, otherCopy.directory) < 0;
|
|
3158
3193
|
}
|
|
3159
3194
|
legacySourcePackage(sourceDir) {
|
|
3160
3195
|
const skillsDirectory = path12.resolve(path12.resolve(this.options.cwd ?? process.cwd()), sourceDir);
|
|
@@ -3350,6 +3385,16 @@ function listDirectoryNames(directory) {
|
|
|
3350
3385
|
return [];
|
|
3351
3386
|
}
|
|
3352
3387
|
}
|
|
3388
|
+
function compareVersions(first, second) {
|
|
3389
|
+
const partsOf = (version) => (version ?? "0").replace(/^v/, "").split(/[.+-]/).map((part) => /^\d+$/.test(part) ? Number(part) : 0);
|
|
3390
|
+
const firstParts = partsOf(first);
|
|
3391
|
+
const secondParts = partsOf(second);
|
|
3392
|
+
for (let index = 0; index < Math.max(firstParts.length, secondParts.length); index++) {
|
|
3393
|
+
const difference = (firstParts[index] ?? 0) - (secondParts[index] ?? 0);
|
|
3394
|
+
if (difference !== 0) return difference > 0 ? 1 : -1;
|
|
3395
|
+
}
|
|
3396
|
+
return 0;
|
|
3397
|
+
}
|
|
3353
3398
|
function compareBytes(first, second) {
|
|
3354
3399
|
return Buffer.compare(Buffer.from(first), Buffer.from(second));
|
|
3355
3400
|
}
|
|
@@ -3384,4 +3429,4 @@ export {
|
|
|
3384
3429
|
runSkillLinks,
|
|
3385
3430
|
linkSkills
|
|
3386
3431
|
};
|
|
3387
|
-
//# sourceMappingURL=chunk-
|
|
3432
|
+
//# sourceMappingURL=chunk-IPOFLOAJ.js.map
|