@simplysm/sd-cli 13.0.76 → 13.0.77
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/README.md +341 -16
- package/dist/builders/DtsBuilder.js +2 -2
- package/dist/builders/DtsBuilder.js.map +1 -1
- package/dist/builders/LibraryBuilder.d.ts +3 -3
- package/dist/builders/LibraryBuilder.d.ts.map +1 -1
- package/dist/builders/LibraryBuilder.js +2 -2
- package/dist/builders/LibraryBuilder.js.map +1 -1
- package/dist/builders/types.d.ts +7 -1
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/capacitor/capacitor.d.ts +5 -0
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +59 -59
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/check.js +4 -4
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/device.js +3 -3
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/lint.js +4 -4
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/publish.js +20 -20
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/replace-deps.js +1 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/commands/typecheck.js +9 -9
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/electron/electron.js +16 -16
- package/dist/electron/electron.js.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +6 -6
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.d.ts +7 -6
- package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +157 -203
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.js +3 -4
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
- package/dist/sd-cli.js +1 -1
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +9 -3
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/utils/copy-public.d.ts.map +1 -1
- package/dist/utils/copy-public.js +23 -27
- package/dist/utils/copy-public.js.map +1 -1
- package/dist/utils/copy-src.d.ts.map +1 -1
- package/dist/utils/copy-src.js +7 -7
- package/dist/utils/copy-src.js.map +1 -1
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/esbuild-config.js +36 -42
- package/dist/utils/esbuild-config.js.map +1 -1
- package/dist/utils/replace-deps.js +7 -7
- package/dist/utils/replace-deps.js.map +1 -1
- package/dist/utils/sd-config.js +2 -2
- package/dist/utils/sd-config.js.map +1 -1
- package/dist/utils/template.js +7 -7
- package/dist/utils/template.js.map +1 -1
- package/dist/utils/tsconfig.d.ts +1 -2
- package/dist/utils/tsconfig.d.ts.map +1 -1
- package/dist/utils/tsconfig.js +5 -8
- package/dist/utils/tsconfig.js.map +1 -1
- package/dist/utils/typecheck-serialization.js +2 -2
- package/dist/utils/typecheck-serialization.js.map +1 -1
- package/dist/utils/vite-config.d.ts +2 -0
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +36 -3
- package/dist/utils/vite-config.js.map +1 -1
- package/dist/utils/worker-events.d.ts +11 -1
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-events.js +3 -5
- package/dist/utils/worker-events.js.map +1 -1
- package/dist/utils/worker-utils.d.ts +2 -2
- package/dist/utils/worker-utils.d.ts.map +1 -1
- package/dist/utils/worker-utils.js +1 -1
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts +1 -1
- package/dist/workers/client.worker.js +3 -3
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/dts.worker.d.ts +1 -1
- package/dist/workers/dts.worker.d.ts.map +1 -1
- package/dist/workers/dts.worker.js +13 -28
- package/dist/workers/dts.worker.js.map +1 -1
- package/dist/workers/library.worker.d.ts +1 -1
- package/dist/workers/library.worker.js +4 -4
- package/dist/workers/library.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +1 -1
- package/dist/workers/server-runtime.worker.d.ts +1 -1
- package/dist/workers/server-runtime.worker.js +4 -4
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/dist/workers/server.worker.d.ts +1 -1
- package/dist/workers/server.worker.js +6 -6
- package/dist/workers/server.worker.js.map +1 -1
- package/package.json +4 -4
- package/src/builders/DtsBuilder.ts +2 -2
- package/src/builders/LibraryBuilder.ts +7 -10
- package/src/builders/types.ts +6 -1
- package/src/capacitor/capacitor.ts +61 -60
- package/src/commands/check.ts +4 -4
- package/src/commands/device.ts +3 -3
- package/src/commands/lint.ts +4 -4
- package/src/commands/publish.ts +20 -20
- package/src/commands/replace-deps.ts +1 -1
- package/src/commands/typecheck.ts +9 -9
- package/src/electron/electron.ts +16 -16
- package/src/orchestrators/BuildOrchestrator.ts +6 -6
- package/src/orchestrators/DevOrchestrator.ts +210 -256
- package/src/orchestrators/WatchOrchestrator.ts +8 -10
- package/src/sd-cli.ts +1 -1
- package/src/sd-config.types.ts +10 -3
- package/src/utils/copy-public.ts +22 -26
- package/src/utils/copy-src.ts +7 -7
- package/src/utils/esbuild-config.ts +51 -63
- package/src/utils/replace-deps.ts +7 -7
- package/src/utils/sd-config.ts +2 -2
- package/src/utils/template.ts +7 -7
- package/src/utils/tsconfig.ts +6 -10
- package/src/utils/typecheck-serialization.ts +2 -2
- package/src/utils/vite-config.ts +376 -341
- package/src/utils/worker-events.ts +13 -10
- package/src/utils/worker-utils.ts +45 -45
- package/src/workers/client.worker.ts +3 -3
- package/src/workers/dts.worker.ts +451 -467
- package/src/workers/library.worker.ts +4 -4
- package/src/workers/server-runtime.worker.ts +4 -4
- package/src/workers/server.worker.ts +572 -572
- package/templates/init/package.json.hbs +2 -2
- package/templates/init/packages/client-admin/package.json.hbs +5 -5
- package/templates/init/packages/client-admin/src/views/auth/LoginView.tsx +2 -2
- package/templates/init/packages/client-admin/src/views/home/base/employee/EmployeeSheet.tsx.hbs +1 -1
- package/templates/init/packages/client-admin/src/views/home/base/role-permission/RoleSheet.tsx.hbs +1 -1
- package/templates/init/packages/db-main/package.json.hbs +2 -2
- package/templates/init/packages/server/package.json.hbs +4 -4
- package/templates/init/tests/e2e/package.json.hbs +1 -1
- package/tests/get-compiler-options-for-package.spec.ts +13 -27
- package/tests/get-types-from-package-json.spec.ts +15 -11
- package/tests/load-ignore-patterns.spec.ts +15 -11
- package/tests/load-sd-config.spec.ts +16 -14
- package/tests/publish-config-narrowing.spec.ts +20 -0
- package/tests/run-lint.spec.ts +38 -34
- package/tests/run-typecheck.spec.ts +194 -135
- package/tests/sd-public-dev-plugin-mime.spec.ts +19 -0
- package/dist/builders/index.d.ts +0 -5
- package/dist/builders/index.d.ts.map +0 -1
- package/dist/builders/index.js +0 -5
- package/dist/builders/index.js.map +0 -6
- package/dist/infra/index.d.ts +0 -4
- package/dist/infra/index.d.ts.map +0 -1
- package/dist/infra/index.js +0 -4
- package/dist/infra/index.js.map +0 -6
- package/dist/orchestrators/index.d.ts +0 -4
- package/dist/orchestrators/index.d.ts.map +0 -1
- package/dist/orchestrators/index.js +0 -4
- package/dist/orchestrators/index.js.map +0 -6
- package/src/builders/index.ts +0 -4
- package/src/infra/index.ts +0 -3
- package/src/orchestrators/index.ts +0 -3
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"vitest": "vitest"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@simplysm/lint": "~13.0.
|
|
21
|
-
"@simplysm/sd-cli": "~13.0.
|
|
20
|
+
"@simplysm/lint": "~13.0.77",
|
|
21
|
+
"@simplysm/sd-cli": "~13.0.77",
|
|
22
22
|
"@types/node": "^20.19.35",
|
|
23
23
|
"eslint": "^9.39.3",
|
|
24
24
|
"prettier": "^3.8.1",
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"private": true,
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@{{projectName}}/db-main": "workspace:*",
|
|
9
|
-
"@simplysm/core-browser": "~13.0.
|
|
10
|
-
"@simplysm/core-common": "~13.0.
|
|
9
|
+
"@simplysm/core-browser": "~13.0.77",
|
|
10
|
+
"@simplysm/core-common": "~13.0.77",
|
|
11
11
|
"@simplysm/excel": "^13.0.71",
|
|
12
|
-
"@simplysm/orm-common": "~13.0.
|
|
13
|
-
"@simplysm/service-client": "~13.0.
|
|
14
|
-
"@simplysm/solid": "~13.0.
|
|
12
|
+
"@simplysm/orm-common": "~13.0.77",
|
|
13
|
+
"@simplysm/service-client": "~13.0.77",
|
|
14
|
+
"@simplysm/solid": "~13.0.77",
|
|
15
15
|
"@solid-primitives/event-listener": "^2.4.5",
|
|
16
16
|
"@solidjs/router": "^0.15.4",
|
|
17
17
|
"@tabler/icons-solidjs": "^3.37.1",
|
|
@@ -81,7 +81,7 @@ export function LoginView() {
|
|
|
81
81
|
type="email"
|
|
82
82
|
placeholder="이메일을 입력하세요"
|
|
83
83
|
required
|
|
84
|
-
|
|
84
|
+
lazyValidation
|
|
85
85
|
size="lg"
|
|
86
86
|
autocomplete="employeename"
|
|
87
87
|
value={data.email}
|
|
@@ -95,7 +95,7 @@ export function LoginView() {
|
|
|
95
95
|
<FormGroup.Item>
|
|
96
96
|
<TextInput
|
|
97
97
|
required
|
|
98
|
-
|
|
98
|
+
lazyValidation
|
|
99
99
|
class="w-full"
|
|
100
100
|
type="password"
|
|
101
101
|
placeholder="비밀번호를 입력하세요"
|
package/templates/init/packages/client-admin/src/views/home/base/employee/EmployeeSheet.tsx.hbs
CHANGED
|
@@ -164,7 +164,7 @@ export function EmployeeSheet() {
|
|
|
164
164
|
<CrudSheet<SheetItem, Filter>
|
|
165
165
|
search={search}
|
|
166
166
|
getItemKey={(item) => item.id}
|
|
167
|
-
|
|
167
|
+
isItemDeleted={(item) => item.isDeleted}
|
|
168
168
|
isItemSelectable={(item) => item.id != null}
|
|
169
169
|
persistKey="employee-page"
|
|
170
170
|
editable={employeePerms.edit}
|
package/templates/init/packages/client-admin/src/views/home/base/role-permission/RoleSheet.tsx.hbs
CHANGED
|
@@ -85,7 +85,7 @@ export function RoleSheet() {
|
|
|
85
85
|
<CrudSheet<SheetItem, Filter>
|
|
86
86
|
search={search}
|
|
87
87
|
getItemKey={(item) => item.id}
|
|
88
|
-
|
|
88
|
+
isItemDeleted={(item) => item.isDeleted}
|
|
89
89
|
isItemSelectable={(item) => item.id != null}
|
|
90
90
|
persistKey="role-sheet-page"
|
|
91
91
|
editable={rolePerms.edit}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"private": true,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@{{projectName}}/db-main": "workspace:*",
|
|
8
|
-
"@simplysm/core-common": "~13.0.
|
|
8
|
+
"@simplysm/core-common": "~13.0.77",
|
|
9
9
|
"@simplysm/excel": "^13.0.71",
|
|
10
|
-
"@simplysm/orm-common": "~13.0.
|
|
11
|
-
"@simplysm/orm-node": "~13.0.
|
|
12
|
-
"@simplysm/service-server": "~13.0.
|
|
10
|
+
"@simplysm/orm-common": "~13.0.77",
|
|
11
|
+
"@simplysm/orm-node": "~13.0.77",
|
|
12
|
+
"@simplysm/service-server": "~13.0.77",
|
|
13
13
|
"bcrypt": "^6.0.0",
|
|
14
14
|
"pg": "^8.19.0",
|
|
15
15
|
"pg-copy-streams": "^7.0.0"
|
|
@@ -3,12 +3,16 @@ import type ts from "typescript";
|
|
|
3
3
|
|
|
4
4
|
// Mock core-node functions
|
|
5
5
|
vi.mock("@simplysm/core-node", () => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
fsx: {
|
|
7
|
+
exists: vi.fn(),
|
|
8
|
+
readJson: vi.fn(),
|
|
9
|
+
},
|
|
10
|
+
pathx: {
|
|
11
|
+
posix: vi.fn((p: string) => p.replace(/\\/g, "/")),
|
|
12
|
+
},
|
|
9
13
|
}));
|
|
10
14
|
|
|
11
|
-
import {
|
|
15
|
+
import { fsx } from "@simplysm/core-node";
|
|
12
16
|
import { getCompilerOptionsForPackage } from "../src/utils/tsconfig";
|
|
13
17
|
|
|
14
18
|
describe("getCompilerOptionsForPackage", () => {
|
|
@@ -28,8 +32,8 @@ describe("getCompilerOptionsForPackage", () => {
|
|
|
28
32
|
|
|
29
33
|
it("node target: removes DOM lib, includes node in types", async () => {
|
|
30
34
|
const packageDir = "/project/packages/core-node";
|
|
31
|
-
vi.mocked(
|
|
32
|
-
vi.mocked(
|
|
35
|
+
vi.mocked(fsx.exists).mockResolvedValue(true);
|
|
36
|
+
vi.mocked(fsx.readJson).mockResolvedValue({
|
|
33
37
|
devDependencies: {
|
|
34
38
|
"@types/express": "^4.17.0",
|
|
35
39
|
},
|
|
@@ -46,8 +50,8 @@ describe("getCompilerOptionsForPackage", () => {
|
|
|
46
50
|
|
|
47
51
|
it("browser target: keeps lib, removes node from types", async () => {
|
|
48
52
|
const packageDir = "/project/packages/core-browser";
|
|
49
|
-
vi.mocked(
|
|
50
|
-
vi.mocked(
|
|
53
|
+
vi.mocked(fsx.exists).mockResolvedValue(true);
|
|
54
|
+
vi.mocked(fsx.readJson).mockResolvedValue({
|
|
51
55
|
devDependencies: {
|
|
52
56
|
"@types/node": "^20.0.0",
|
|
53
57
|
"@types/react": "^18.0.0",
|
|
@@ -63,27 +67,9 @@ describe("getCompilerOptionsForPackage", () => {
|
|
|
63
67
|
expect(result.types).toContain("react");
|
|
64
68
|
});
|
|
65
69
|
|
|
66
|
-
it("neutral target: keeps lib, includes node in types", async () => {
|
|
67
|
-
const packageDir = "/project/packages/core-common";
|
|
68
|
-
vi.mocked(fsExists).mockResolvedValue(true);
|
|
69
|
-
vi.mocked(fsReadJson).mockResolvedValue({
|
|
70
|
-
devDependencies: {
|
|
71
|
-
"@types/lodash": "^4.0.0",
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const result = await getCompilerOptionsForPackage(baseOptions, "neutral", packageDir);
|
|
76
|
-
|
|
77
|
-
// lib is preserved (includes DOM)
|
|
78
|
-
expect(result.lib).toEqual(["ES2024", "DOM", "DOM.Iterable", "WebWorker"]);
|
|
79
|
-
// types includes node and lodash
|
|
80
|
-
expect(result.types).toContain("node");
|
|
81
|
-
expect(result.types).toContain("lodash");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
70
|
it("handles missing package.json with empty types", async () => {
|
|
85
71
|
const packageDir = "/project/packages/unknown";
|
|
86
|
-
vi.mocked(
|
|
72
|
+
vi.mocked(fsx.exists).mockResolvedValue(false);
|
|
87
73
|
|
|
88
74
|
const result = await getCompilerOptionsForPackage(baseOptions, "node", packageDir);
|
|
89
75
|
|
|
@@ -3,12 +3,16 @@ import path from "path";
|
|
|
3
3
|
|
|
4
4
|
// Mock core-node functions
|
|
5
5
|
vi.mock("@simplysm/core-node", () => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
fsx: {
|
|
7
|
+
exists: vi.fn(),
|
|
8
|
+
readJson: vi.fn(),
|
|
9
|
+
},
|
|
10
|
+
pathx: {
|
|
11
|
+
posix: vi.fn((p: string) => p.replace(/\\/g, "/")),
|
|
12
|
+
},
|
|
9
13
|
}));
|
|
10
14
|
|
|
11
|
-
import {
|
|
15
|
+
import { fsx } from "@simplysm/core-node";
|
|
12
16
|
import { getTypesFromPackageJson } from "../src/utils/tsconfig";
|
|
13
17
|
|
|
14
18
|
describe("getTypesFromPackageJson", () => {
|
|
@@ -22,8 +26,8 @@ describe("getTypesFromPackageJson", () => {
|
|
|
22
26
|
|
|
23
27
|
it("converts @types/* devDependencies to types list", async () => {
|
|
24
28
|
const packageDir = "/project/packages/core-common";
|
|
25
|
-
const mockFsExists = vi.mocked(
|
|
26
|
-
const mockFsReadJson = vi.mocked(
|
|
29
|
+
const mockFsExists = vi.mocked(fsx.exists);
|
|
30
|
+
const mockFsReadJson = vi.mocked(fsx.readJson);
|
|
27
31
|
|
|
28
32
|
mockFsExists.mockResolvedValue(true);
|
|
29
33
|
mockFsReadJson.mockResolvedValue({
|
|
@@ -43,7 +47,7 @@ describe("getTypesFromPackageJson", () => {
|
|
|
43
47
|
|
|
44
48
|
it("returns empty array if package.json does not exist", async () => {
|
|
45
49
|
const packageDir = "/project/packages/unknown";
|
|
46
|
-
const mockFsExists = vi.mocked(
|
|
50
|
+
const mockFsExists = vi.mocked(fsx.exists);
|
|
47
51
|
|
|
48
52
|
mockFsExists.mockResolvedValue(false);
|
|
49
53
|
|
|
@@ -54,8 +58,8 @@ describe("getTypesFromPackageJson", () => {
|
|
|
54
58
|
|
|
55
59
|
it("returns empty array if devDependencies does not exist", async () => {
|
|
56
60
|
const packageDir = "/project/packages/core-common";
|
|
57
|
-
const mockFsExists = vi.mocked(
|
|
58
|
-
const mockFsReadJson = vi.mocked(
|
|
61
|
+
const mockFsExists = vi.mocked(fsx.exists);
|
|
62
|
+
const mockFsReadJson = vi.mocked(fsx.readJson);
|
|
59
63
|
|
|
60
64
|
mockFsExists.mockResolvedValue(true);
|
|
61
65
|
mockFsReadJson.mockResolvedValue({
|
|
@@ -70,8 +74,8 @@ describe("getTypesFromPackageJson", () => {
|
|
|
70
74
|
|
|
71
75
|
it("handles scoped @types packages correctly", async () => {
|
|
72
76
|
const packageDir = "/project/packages/core-common";
|
|
73
|
-
const mockFsExists = vi.mocked(
|
|
74
|
-
const mockFsReadJson = vi.mocked(
|
|
77
|
+
const mockFsExists = vi.mocked(fsx.exists);
|
|
78
|
+
const mockFsReadJson = vi.mocked(fsx.readJson);
|
|
75
79
|
|
|
76
80
|
mockFsExists.mockResolvedValue(true);
|
|
77
81
|
mockFsReadJson.mockResolvedValue({
|
|
@@ -4,8 +4,12 @@ import path from "path";
|
|
|
4
4
|
|
|
5
5
|
// Mock core-node functions and jiti
|
|
6
6
|
vi.mock("@simplysm/core-node", () => ({
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
fsx: {
|
|
8
|
+
exists: vi.fn(),
|
|
9
|
+
},
|
|
10
|
+
pathx: {
|
|
11
|
+
posix: vi.fn(),
|
|
12
|
+
},
|
|
9
13
|
}));
|
|
10
14
|
|
|
11
15
|
const mockJitiImportFn = vi.fn();
|
|
@@ -15,7 +19,7 @@ vi.mock("jiti", () => ({
|
|
|
15
19
|
})),
|
|
16
20
|
}));
|
|
17
21
|
|
|
18
|
-
import {
|
|
22
|
+
import { fsx } from "@simplysm/core-node";
|
|
19
23
|
|
|
20
24
|
describe("loadIgnorePatterns", () => {
|
|
21
25
|
beforeEach(() => {
|
|
@@ -28,7 +32,7 @@ describe("loadIgnorePatterns", () => {
|
|
|
28
32
|
|
|
29
33
|
it("extracts globalIgnores pattern from eslint.config.ts", async () => {
|
|
30
34
|
const cwd = "/project";
|
|
31
|
-
const mockExists = vi.mocked(
|
|
35
|
+
const mockExists = vi.mocked(fsx.exists);
|
|
32
36
|
|
|
33
37
|
mockExists.mockImplementation((filePath: string) => {
|
|
34
38
|
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
@@ -45,7 +49,7 @@ describe("loadIgnorePatterns", () => {
|
|
|
45
49
|
|
|
46
50
|
it("does not extract as globalIgnores if files is present", async () => {
|
|
47
51
|
const cwd = "/project";
|
|
48
|
-
const mockExists = vi.mocked(
|
|
52
|
+
const mockExists = vi.mocked(fsx.exists);
|
|
49
53
|
|
|
50
54
|
mockExists.mockImplementation((filePath: string) => {
|
|
51
55
|
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
@@ -66,7 +70,7 @@ describe("loadIgnorePatterns", () => {
|
|
|
66
70
|
|
|
67
71
|
it("throws error if config file not found", async () => {
|
|
68
72
|
const cwd = "/project";
|
|
69
|
-
const mockExists = vi.mocked(
|
|
73
|
+
const mockExists = vi.mocked(fsx.exists);
|
|
70
74
|
|
|
71
75
|
mockExists.mockResolvedValue(false);
|
|
72
76
|
|
|
@@ -75,7 +79,7 @@ describe("loadIgnorePatterns", () => {
|
|
|
75
79
|
|
|
76
80
|
it("throws error if config is not array", async () => {
|
|
77
81
|
const cwd = "/project";
|
|
78
|
-
const mockExists = vi.mocked(
|
|
82
|
+
const mockExists = vi.mocked(fsx.exists);
|
|
79
83
|
|
|
80
84
|
mockExists.mockImplementation((filePath: string) => {
|
|
81
85
|
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
@@ -90,7 +94,7 @@ describe("loadIgnorePatterns", () => {
|
|
|
90
94
|
|
|
91
95
|
it("merges multiple globalIgnores settings", async () => {
|
|
92
96
|
const cwd = "/project";
|
|
93
|
-
const mockExists = vi.mocked(
|
|
97
|
+
const mockExists = vi.mocked(fsx.exists);
|
|
94
98
|
|
|
95
99
|
mockExists.mockImplementation((filePath: string) => {
|
|
96
100
|
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
@@ -107,7 +111,7 @@ describe("loadIgnorePatterns", () => {
|
|
|
107
111
|
|
|
108
112
|
it("handles config that directly exports array", async () => {
|
|
109
113
|
const cwd = "/project";
|
|
110
|
-
const mockExists = vi.mocked(
|
|
114
|
+
const mockExists = vi.mocked(fsx.exists);
|
|
111
115
|
|
|
112
116
|
mockExists.mockImplementation((filePath: string) => {
|
|
113
117
|
return Promise.resolve(filePath === path.join(cwd, "eslint.config.js"));
|
|
@@ -122,7 +126,7 @@ describe("loadIgnorePatterns", () => {
|
|
|
122
126
|
|
|
123
127
|
it("throws error if config has no default and is not array", async () => {
|
|
124
128
|
const cwd = "/project";
|
|
125
|
-
const mockExists = vi.mocked(
|
|
129
|
+
const mockExists = vi.mocked(fsx.exists);
|
|
126
130
|
|
|
127
131
|
mockExists.mockImplementation((filePath: string) => {
|
|
128
132
|
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
@@ -139,7 +143,7 @@ describe("loadIgnorePatterns", () => {
|
|
|
139
143
|
|
|
140
144
|
it("uses mts file if eslint.config.ts not found", async () => {
|
|
141
145
|
const cwd = "/project";
|
|
142
|
-
const mockExists = vi.mocked(
|
|
146
|
+
const mockExists = vi.mocked(fsx.exists);
|
|
143
147
|
|
|
144
148
|
mockExists.mockImplementation((filePath: string) => {
|
|
145
149
|
// eslint.config.ts does not exist, only eslint.config.mts
|
|
@@ -3,7 +3,9 @@ import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
|
|
|
3
3
|
const mockJitiImport = vi.fn();
|
|
4
4
|
|
|
5
5
|
vi.mock("@simplysm/core-node", () => ({
|
|
6
|
-
|
|
6
|
+
fsx: {
|
|
7
|
+
exists: vi.fn(),
|
|
8
|
+
},
|
|
7
9
|
}));
|
|
8
10
|
|
|
9
11
|
vi.mock("jiti", () => ({
|
|
@@ -12,7 +14,7 @@ vi.mock("jiti", () => ({
|
|
|
12
14
|
})),
|
|
13
15
|
}));
|
|
14
16
|
|
|
15
|
-
import {
|
|
17
|
+
import { fsx } from "@simplysm/core-node";
|
|
16
18
|
import { loadSdConfig } from "../src/utils/sd-config";
|
|
17
19
|
|
|
18
20
|
describe("loadSdConfig", () => {
|
|
@@ -25,48 +27,48 @@ describe("loadSdConfig", () => {
|
|
|
25
27
|
});
|
|
26
28
|
|
|
27
29
|
it("throws error if sd.config.ts file not found", async () => {
|
|
28
|
-
vi.mocked(
|
|
30
|
+
vi.mocked(fsx.exists).mockResolvedValue(false);
|
|
29
31
|
|
|
30
|
-
await expect(loadSdConfig({ cwd: "/project", dev: false,
|
|
32
|
+
await expect(loadSdConfig({ cwd: "/project", dev: false, options: [] })).rejects.toThrow(
|
|
31
33
|
"sd.config.ts file not found",
|
|
32
34
|
);
|
|
33
35
|
});
|
|
34
36
|
|
|
35
37
|
it("throws error if no default export", async () => {
|
|
36
|
-
vi.mocked(
|
|
38
|
+
vi.mocked(fsx.exists).mockResolvedValue(true);
|
|
37
39
|
mockJitiImport.mockResolvedValue({
|
|
38
40
|
someOtherExport: () => ({}),
|
|
39
41
|
});
|
|
40
42
|
|
|
41
|
-
await expect(loadSdConfig({ cwd: "/project", dev: false,
|
|
43
|
+
await expect(loadSdConfig({ cwd: "/project", dev: false, options: [] })).rejects.toThrow(
|
|
42
44
|
"sd.config.ts must export a function as default",
|
|
43
45
|
);
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
it("throws error if default export is not function", async () => {
|
|
47
|
-
vi.mocked(
|
|
49
|
+
vi.mocked(fsx.exists).mockResolvedValue(true);
|
|
48
50
|
mockJitiImport.mockResolvedValue({
|
|
49
51
|
default: { packages: {} }, // object not function
|
|
50
52
|
});
|
|
51
53
|
|
|
52
|
-
await expect(loadSdConfig({ cwd: "/project", dev: false,
|
|
54
|
+
await expect(loadSdConfig({ cwd: "/project", dev: false, options: [] })).rejects.toThrow(
|
|
53
55
|
"sd.config.ts must export a function as default",
|
|
54
56
|
);
|
|
55
57
|
});
|
|
56
58
|
|
|
57
59
|
it("throws error if return value is wrong format (missing packages)", async () => {
|
|
58
|
-
vi.mocked(
|
|
60
|
+
vi.mocked(fsx.exists).mockResolvedValue(true);
|
|
59
61
|
mockJitiImport.mockResolvedValue({
|
|
60
62
|
default: () => ({}), // missing packages property
|
|
61
63
|
});
|
|
62
64
|
|
|
63
|
-
await expect(loadSdConfig({ cwd: "/project", dev: false,
|
|
65
|
+
await expect(loadSdConfig({ cwd: "/project", dev: false, options: [] })).rejects.toThrow(
|
|
64
66
|
/sd\.config\.ts return value is not in .* correct format/,
|
|
65
67
|
);
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
it("returns correct config", async () => {
|
|
69
|
-
vi.mocked(
|
|
71
|
+
vi.mocked(fsx.exists).mockResolvedValue(true);
|
|
70
72
|
mockJitiImport.mockResolvedValue({
|
|
71
73
|
default: () => ({
|
|
72
74
|
packages: {
|
|
@@ -76,7 +78,7 @@ describe("loadSdConfig", () => {
|
|
|
76
78
|
}),
|
|
77
79
|
});
|
|
78
80
|
|
|
79
|
-
const config = await loadSdConfig({ cwd: "/project", dev: false,
|
|
81
|
+
const config = await loadSdConfig({ cwd: "/project", dev: false, options: [] });
|
|
80
82
|
|
|
81
83
|
expect(config.packages).toEqual({
|
|
82
84
|
"core-common": { target: "neutral" },
|
|
@@ -85,12 +87,12 @@ describe("loadSdConfig", () => {
|
|
|
85
87
|
});
|
|
86
88
|
|
|
87
89
|
it("empty packages object is valid", async () => {
|
|
88
|
-
vi.mocked(
|
|
90
|
+
vi.mocked(fsx.exists).mockResolvedValue(true);
|
|
89
91
|
mockJitiImport.mockResolvedValue({
|
|
90
92
|
default: () => ({ packages: {} }),
|
|
91
93
|
});
|
|
92
94
|
|
|
93
|
-
const config = await loadSdConfig({ cwd: "/project", dev: false,
|
|
95
|
+
const config = await loadSdConfig({ cwd: "/project", dev: false, options: [] });
|
|
94
96
|
|
|
95
97
|
expect(config.packages).toEqual({});
|
|
96
98
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { SdPublishConfig, SdNpmPublishConfig } from "../src/sd-config.types";
|
|
3
|
+
|
|
4
|
+
describe("SdPublishConfig", () => {
|
|
5
|
+
it("all variants have .type field for uniform narrowing", () => {
|
|
6
|
+
const configs: SdPublishConfig[] = [
|
|
7
|
+
{ type: "npm" },
|
|
8
|
+
{ type: "local-directory", path: "/deploy" },
|
|
9
|
+
{ type: "ftp", host: "example.com" },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const types = configs.map((c) => c.type);
|
|
13
|
+
expect(types).toEqual(["npm", "local-directory", "ftp"]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("npm config is an object with type field", () => {
|
|
17
|
+
const npmConfig: SdNpmPublishConfig = { type: "npm" };
|
|
18
|
+
expect(npmConfig.type).toBe("npm");
|
|
19
|
+
});
|
|
20
|
+
});
|