@simplysm/sd-cli 13.0.75 → 13.0.76

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 (28) hide show
  1. package/dist/commands/lint.d.ts +2 -2
  2. package/dist/commands/lint.d.ts.map +1 -1
  3. package/dist/commands/lint.js +0 -94
  4. package/dist/commands/lint.js.map +1 -1
  5. package/package.json +4 -5
  6. package/src/commands/lint.ts +2 -113
  7. package/templates/init/package.json.hbs +2 -3
  8. package/templates/init/packages/client-admin/package.json.hbs +5 -5
  9. package/templates/init/packages/client-admin/src/views/home/base/employee/EmployeeDetail.tsx.hbs +86 -105
  10. package/templates/init/packages/client-admin/src/views/home/base/role-permission/RoleDetail.tsx.hbs +4 -12
  11. package/templates/init/packages/client-admin/src/views/home/base/role-permission/RolePermissionDetail.tsx.hbs +0 -2
  12. package/templates/init/packages/client-admin/src/views/home/base/role-permission/RolePermissionView.tsx +1 -1
  13. package/templates/init/packages/client-admin/src/views/home/my-info/MyInfoDetail.tsx.hbs +36 -43
  14. package/templates/init/packages/db-main/package.json.hbs +2 -2
  15. package/templates/init/packages/server/package.json.hbs +4 -4
  16. package/templates/init/tests/e2e/package.json.hbs +1 -1
  17. package/tests/get-compiler-options-for-package.spec.ts +0 -45
  18. package/tests/get-package-source-files.spec.ts +0 -42
  19. package/tests/get-types-from-package-json.spec.ts +0 -19
  20. package/tests/infra/ResultCollector.spec.ts +0 -9
  21. package/tests/infra/WorkerManager.spec.ts +0 -34
  22. package/tests/load-ignore-patterns.spec.ts +0 -29
  23. package/tests/load-sd-config.spec.ts +0 -39
  24. package/tests/run-lint.spec.ts +0 -53
  25. package/tests/run-typecheck.spec.ts +0 -168
  26. package/tests/run-watch.spec.ts +0 -34
  27. package/tests/sd-cli.spec.ts +0 -88
  28. package/templates/init/stylelint.config.ts +0 -1
@@ -270,117 +270,6 @@ describe("runTypecheck", () => {
270
270
  expect(process.exitCode).toBeUndefined();
271
271
  });
272
272
 
273
- it("uses default value when default export is not a function", async () => {
274
- vi.mocked(ts.readConfigFile).mockReturnValue({
275
- config: {},
276
- });
277
-
278
- vi.mocked(ts.parseJsonConfigFileContent).mockReturnValue({
279
- options: { lib: ["ES2024"], types: [] },
280
- fileNames: ["/project/packages/core-common/src/index.ts"],
281
- errors: [],
282
- } as unknown as ts.ParsedCommandLine);
283
-
284
- vi.mocked(fsExists).mockResolvedValue(false);
285
- vi.mocked(fsReadJson).mockResolvedValue({ devDependencies: {} });
286
-
287
- // When sd.config.ts's default export is an object, not a function
288
- mockJitiImport.mockResolvedValue({
289
- default: { packages: {} }, // object, not a function
290
- });
291
-
292
- vi.mocked(ts.sortAndDeduplicateDiagnostics).mockReturnValue(
293
- [] as unknown as ts.SortedReadonlyArray<ts.Diagnostic>,
294
- );
295
-
296
- // Should proceed with default value without error
297
- await runTypecheck({ targets: [], options: [] });
298
-
299
- expect(process.exitCode).toBeUndefined();
300
- });
301
-
302
- it("uses default value when no default export in sd.config.ts", async () => {
303
- vi.mocked(ts.readConfigFile).mockReturnValue({
304
- config: {},
305
- });
306
-
307
- vi.mocked(ts.parseJsonConfigFileContent).mockReturnValue({
308
- options: { lib: ["ES2024"], types: [] },
309
- fileNames: ["/project/packages/core-common/src/index.ts"],
310
- errors: [],
311
- } as unknown as ts.ParsedCommandLine);
312
-
313
- vi.mocked(fsExists).mockResolvedValue(false);
314
- vi.mocked(fsReadJson).mockResolvedValue({ devDependencies: {} });
315
-
316
- // When sd.config.ts has no default export
317
- mockJitiImport.mockResolvedValue({
318
- someOtherExport: () => ({}),
319
- });
320
-
321
- const { Worker } = await import("@simplysm/core-node");
322
- vi.mocked(Worker.create).mockReturnValue({
323
- build: vi.fn(() =>
324
- Promise.resolve({
325
- success: true,
326
- diagnostics: [],
327
- errorCount: 0,
328
- warningCount: 0,
329
- }),
330
- ),
331
- terminate: vi.fn(() => Promise.resolve()),
332
- } as unknown as ReturnType<typeof Worker.create>);
333
-
334
- vi.mocked(ts.sortAndDeduplicateDiagnostics).mockReturnValue(
335
- [] as unknown as ts.SortedReadonlyArray<ts.Diagnostic>,
336
- );
337
-
338
- // Should proceed with default value without error
339
- await runTypecheck({ targets: [], options: [] });
340
-
341
- expect(process.exitCode).toBeUndefined();
342
- });
343
-
344
- it("typecheck multiple packages", async () => {
345
- vi.mocked(ts.readConfigFile).mockReturnValue({
346
- config: {},
347
- });
348
-
349
- vi.mocked(ts.parseJsonConfigFileContent).mockReturnValue({
350
- options: { lib: ["ES2024", "DOM"], types: [] },
351
- fileNames: [
352
- "/project/packages/core-node/src/index.ts",
353
- "/project/packages/core-browser/src/index.ts",
354
- "/project/packages/core-common/src/index.ts",
355
- ],
356
- errors: [],
357
- } as unknown as ts.ParsedCommandLine);
358
-
359
- vi.mocked(fsExists).mockResolvedValue(false);
360
- vi.mocked(fsReadJson).mockResolvedValue({ devDependencies: {} });
361
-
362
- const { Worker } = await import("@simplysm/core-node");
363
- vi.mocked(Worker.create).mockReturnValue({
364
- build: vi.fn(() =>
365
- Promise.resolve({
366
- success: true,
367
- diagnostics: [],
368
- errorCount: 0,
369
- warningCount: 0,
370
- }),
371
- ),
372
- terminate: vi.fn(() => Promise.resolve()),
373
- } as unknown as ReturnType<typeof Worker.create>);
374
-
375
- vi.mocked(ts.sortAndDeduplicateDiagnostics).mockReturnValue(
376
- [] as unknown as ts.SortedReadonlyArray<ts.Diagnostic>,
377
- );
378
-
379
- await runTypecheck({ targets: [], options: [] });
380
-
381
- expect(process.exitCode).toBeUndefined();
382
- });
383
-
384
273
  it("sets exitCode to 1 when typecheck errors occur", async () => {
385
274
  vi.mocked(ts.readConfigFile).mockReturnValue({ config: {} });
386
275
 
@@ -486,44 +375,6 @@ describe("runTypecheck", () => {
486
375
  expect(pkgCall).toBeDefined();
487
376
  });
488
377
 
489
- it("does not create other task when only packages/ files exist", async () => {
490
- vi.mocked(ts.readConfigFile).mockReturnValue({ config: {} });
491
-
492
- vi.mocked(ts.parseJsonConfigFileContent).mockReturnValue({
493
- options: { lib: ["ES2024"], types: [] },
494
- fileNames: ["/project/packages/core-common/src/index.ts"],
495
- errors: [],
496
- } as unknown as ts.ParsedCommandLine);
497
-
498
- vi.mocked(fsExists).mockResolvedValue(false);
499
- vi.mocked(fsReadJson).mockResolvedValue({ devDependencies: {} });
500
-
501
- vi.mocked(ts.sortAndDeduplicateDiagnostics).mockReturnValue(
502
- [] as unknown as ts.SortedReadonlyArray<ts.Diagnostic>,
503
- );
504
-
505
- const { Worker } = await import("@simplysm/core-node");
506
- const mockBuildDts = vi.fn(() =>
507
- Promise.resolve({
508
- success: true,
509
- diagnostics: [],
510
- errorCount: 0,
511
- warningCount: 0,
512
- }),
513
- );
514
- vi.mocked(Worker.create).mockReturnValue({
515
- build: mockBuildDts,
516
- terminate: vi.fn(() => Promise.resolve()),
517
- } as unknown as ReturnType<typeof Worker.create>);
518
-
519
- await runTypecheck({ targets: [], options: [] });
520
-
521
- // Should have no call with name="root"
522
- const nonPkgCall = (mockBuildDts.mock.calls as unknown[][]).find(
523
- (call) => (call[0] as { name: string }).name === "root",
524
- );
525
- expect(nonPkgCall).toBeUndefined();
526
- });
527
378
  });
528
379
 
529
380
  describe("executeTypecheck", () => {
@@ -631,23 +482,4 @@ describe("executeTypecheck", () => {
631
482
  expect(process.exitCode).toBeUndefined();
632
483
  });
633
484
 
634
- it("returns failure result when tsconfig.json fails to load", async () => {
635
- const { executeTypecheck } = await import("../src/commands/typecheck");
636
-
637
- vi.mocked(ts.readConfigFile).mockReturnValue({
638
- error: {
639
- category: ts.DiagnosticCategory.Error,
640
- messageText: "Failed to read tsconfig.json",
641
- } as ts.Diagnostic,
642
- });
643
-
644
- vi.mocked(ts.formatDiagnosticsWithColorAndContext).mockReturnValue("");
645
-
646
- const result = await executeTypecheck({ targets: [], options: [] });
647
-
648
- expect(result.success).toBe(false);
649
- expect(result.errorCount).toBe(1);
650
- // executeTypecheck should not set process.exitCode
651
- expect(process.exitCode).toBeUndefined();
652
- });
653
485
  });
@@ -38,38 +38,4 @@ describe("filterPackagesByTargets", () => {
38
38
  expect(result["core-node"]).toEqual({ target: "node" });
39
39
  });
40
40
 
41
- it("returns empty result when specifying non-existent package", () => {
42
- const result = filterPackagesByTargets(mockPackages, ["non-existent"]);
43
-
44
- expect(Object.keys(result)).toHaveLength(0);
45
- });
46
-
47
- it("ignores undefined package config", () => {
48
- const result = filterPackagesByTargets(mockPackages, ["empty-pkg"]);
49
-
50
- expect(Object.keys(result)).toHaveLength(0);
51
- });
52
-
53
- it("filters client target packages", () => {
54
- const result = filterPackagesByTargets(mockPackages, ["solid-demo"]);
55
-
56
- expect(Object.keys(result)).toHaveLength(1);
57
- expect(result["solid-demo"]).toEqual({ target: "client", server: 3000 });
58
- });
59
-
60
- it("handles empty packages object", () => {
61
- const result = filterPackagesByTargets({}, []);
62
-
63
- expect(Object.keys(result)).toHaveLength(0);
64
- });
65
-
66
- it("handles case where all packages are scripts", () => {
67
- const scriptsOnly: Record<string, SdPackageConfig> = {
68
- pkg1: { target: "scripts" },
69
- pkg2: { target: "scripts" },
70
- };
71
- const result = filterPackagesByTargets(scriptsOnly, []);
72
-
73
- expect(Object.keys(result)).toHaveLength(0);
74
- });
75
41
  });
@@ -74,15 +74,6 @@ describe("sd-cli", () => {
74
74
  });
75
75
  });
76
76
 
77
- it("runs lint command without targets", async () => {
78
- await createCliParser(["lint"]).parse();
79
-
80
- expect(runLint).toHaveBeenCalledWith({
81
- targets: [],
82
- fix: false,
83
- timing: false,
84
- });
85
- });
86
77
  });
87
78
 
88
79
  describe("typecheck command", () => {
@@ -124,15 +115,6 @@ describe("sd-cli", () => {
124
115
  });
125
116
  });
126
117
 
127
- it("runs check command without targets", async () => {
128
- await createCliParser(["check"]).parse();
129
-
130
- expect(runCheck).toHaveBeenCalledWith({
131
- targets: [],
132
- types: ["typecheck", "lint", "test"],
133
- });
134
- });
135
-
136
118
  it("specifies single type using --type option", async () => {
137
119
  await createCliParser(["check", "--type", "test"]).parse();
138
120
 
@@ -153,32 +135,6 @@ describe("sd-cli", () => {
153
135
  });
154
136
  });
155
137
 
156
- it("passes multiple targets to watch command", async () => {
157
- await createCliParser(["watch", "solid", "solid-demo"]).parse();
158
-
159
- expect(runWatch).toHaveBeenCalledWith({
160
- targets: ["solid", "solid-demo"],
161
- options: [],
162
- });
163
- });
164
-
165
- it("runs watch command without targets", async () => {
166
- await createCliParser(["watch"]).parse();
167
-
168
- expect(runWatch).toHaveBeenCalledWith({
169
- targets: [],
170
- options: [],
171
- });
172
- });
173
-
174
- it("passes --options option correctly", async () => {
175
- await createCliParser(["watch", "-o", "dev"]).parse();
176
-
177
- expect(runWatch).toHaveBeenCalledWith({
178
- targets: [],
179
- options: ["dev"],
180
- });
181
- });
182
138
  });
183
139
 
184
140
  describe("build command", () => {
@@ -191,23 +147,6 @@ describe("sd-cli", () => {
191
147
  });
192
148
  });
193
149
 
194
- it("runs build command without targets", async () => {
195
- await createCliParser(["build"]).parse();
196
-
197
- expect(runBuild).toHaveBeenCalledWith({
198
- targets: [],
199
- options: [],
200
- });
201
- });
202
-
203
- it("passes --options option correctly", async () => {
204
- await createCliParser(["build", "-o", "prod"]).parse();
205
-
206
- expect(runBuild).toHaveBeenCalledWith({
207
- targets: [],
208
- options: ["prod"],
209
- });
210
- });
211
150
  });
212
151
 
213
152
  describe("publish command", () => {
@@ -222,17 +161,6 @@ describe("sd-cli", () => {
222
161
  });
223
162
  });
224
163
 
225
- it("runs publish command without targets", async () => {
226
- await createCliParser(["publish"]).parse();
227
-
228
- expect(runPublish).toHaveBeenCalledWith({
229
- targets: [],
230
- noBuild: false,
231
- dryRun: false,
232
- options: [],
233
- });
234
- });
235
-
236
164
  it("passes --no-build option correctly", async () => {
237
165
  await createCliParser(["publish", "--no-build"]).parse();
238
166
 
@@ -277,16 +205,6 @@ describe("sd-cli", () => {
277
205
  });
278
206
  });
279
207
 
280
- it("uses --dry-run with other options together", async () => {
281
- await createCliParser(["publish", "solid", "--dry-run", "-o", "prod"]).parse();
282
-
283
- expect(runPublish).toHaveBeenCalledWith({
284
- targets: ["solid"],
285
- noBuild: false,
286
- dryRun: true,
287
- options: ["prod"],
288
- });
289
- });
290
208
  });
291
209
 
292
210
  describe("global --debug option", () => {
@@ -296,12 +214,6 @@ describe("sd-cli", () => {
296
214
  expect(consola.level).toBe(LogLevels.debug);
297
215
  });
298
216
 
299
- it("does not change consola.level without --debug", async () => {
300
- const levelBefore = consola.level;
301
- await createCliParser(["lint"]).parse();
302
-
303
- expect(consola.level).toBe(levelBefore);
304
- });
305
217
  });
306
218
 
307
219
  describe("error handling", () => {
@@ -1 +0,0 @@
1
- export { default } from "@simplysm/lint/stylelint-recommended";