ebely 0.0.4 → 0.0.6

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/bin/ebely.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { cp, mkdir, readdir, readFile, writeFile } from 'node:fs/promises'
3
3
  import { existsSync } from 'node:fs'
4
- import { basename, dirname, join, resolve, sep } from 'node:path'
4
+ import { basename, dirname, join, relative, resolve, sep } from 'node:path'
5
5
  import { fileURLToPath } from 'node:url'
6
6
 
7
7
  const __dirname = dirname(fileURLToPath(import.meta.url))
@@ -97,9 +97,13 @@ async function createProject({ dir }) {
97
97
  }
98
98
 
99
99
  // Копируем шаблон целиком, кроме node_modules.
100
+ // Важно: фильтруем по пути ОТНОСИТЕЛЬНО шаблона, а не по абсолютному —
101
+ // иначе при установке через npx/npm весь путь пакета лежит внутри
102
+ // node_modules, фильтр отбрасывает корень шаблона и не копируется ничего.
100
103
  await cp(templateSrc, target, {
101
104
  recursive: true,
102
- filter: (src) => !src.split(sep).includes('node_modules'),
105
+ filter: (src) =>
106
+ !relative(templateSrc, src).split(sep).includes('node_modules'),
103
107
  })
104
108
 
105
109
  // package.json: имя по папке + реальная версия ebely вместо workspace:*.
package/dist/index.js CHANGED
@@ -314,8 +314,38 @@ function collectOperations(args) {
314
314
  });
315
315
  }
316
316
  }
317
+ dedupeNames({ operations });
317
318
  return operations;
318
319
  }
320
+ function prefixMethod(args) {
321
+ const { method, name } = args;
322
+ return method + name.charAt(0).toUpperCase() + name.slice(1);
323
+ }
324
+ function dedupeNames(args) {
325
+ const { operations } = args;
326
+ const counts = /* @__PURE__ */ new Map();
327
+ for (const op of operations) {
328
+ const byName = counts.get(op.group) ?? /* @__PURE__ */ new Map();
329
+ byName.set(op.name, (byName.get(op.name) ?? 0) + 1);
330
+ counts.set(op.group, byName);
331
+ }
332
+ const taken = /* @__PURE__ */ new Map();
333
+ const claim = (group, name) => {
334
+ const used = taken.get(group) ?? /* @__PURE__ */ new Set();
335
+ let candidate = name;
336
+ let i = 2;
337
+ while (used.has(candidate))
338
+ candidate = `${name}${i++}`;
339
+ used.add(candidate);
340
+ taken.set(group, used);
341
+ return candidate;
342
+ };
343
+ for (const op of operations) {
344
+ const collides = (counts.get(op.group)?.get(op.name) ?? 0) > 1;
345
+ const base = collides ? prefixMethod({ method: op.method, name: op.name }) : op.name;
346
+ op.name = claim(op.group, base);
347
+ }
348
+ }
319
349
 
320
350
  // src/generator/render.ts
321
351
  function buildInputType(op) {
package/dist/index.mjs CHANGED
@@ -284,8 +284,38 @@ function collectOperations(args) {
284
284
  });
285
285
  }
286
286
  }
287
+ dedupeNames({ operations });
287
288
  return operations;
288
289
  }
290
+ function prefixMethod(args) {
291
+ const { method, name } = args;
292
+ return method + name.charAt(0).toUpperCase() + name.slice(1);
293
+ }
294
+ function dedupeNames(args) {
295
+ const { operations } = args;
296
+ const counts = /* @__PURE__ */ new Map();
297
+ for (const op of operations) {
298
+ const byName = counts.get(op.group) ?? /* @__PURE__ */ new Map();
299
+ byName.set(op.name, (byName.get(op.name) ?? 0) + 1);
300
+ counts.set(op.group, byName);
301
+ }
302
+ const taken = /* @__PURE__ */ new Map();
303
+ const claim = (group, name) => {
304
+ const used = taken.get(group) ?? /* @__PURE__ */ new Set();
305
+ let candidate = name;
306
+ let i = 2;
307
+ while (used.has(candidate))
308
+ candidate = `${name}${i++}`;
309
+ used.add(candidate);
310
+ taken.set(group, used);
311
+ return candidate;
312
+ };
313
+ for (const op of operations) {
314
+ const collides = (counts.get(op.group)?.get(op.name) ?? 0) > 1;
315
+ const base = collides ? prefixMethod({ method: op.method, name: op.name }) : op.name;
316
+ op.name = claim(op.group, base);
317
+ }
318
+ }
289
319
 
290
320
  // src/generator/render.ts
291
321
  function buildInputType(op) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ebely",
3
3
  "license": "MIT",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -35,6 +35,6 @@
35
35
  "build": "tsup index.ts --format cjs,esm --dts",
36
36
  "release": "pnpm run build && changeset publish",
37
37
  "lint": "tsc",
38
- "test": "tsx --test src/response.test.ts src/hooks.test.ts src/generator/render.test.ts"
38
+ "test": "tsx --test src/response.test.ts src/hooks.test.ts src/generator/render.test.ts src/generator/operations.test.ts"
39
39
  }
40
40
  }