@casekit/orm2-cli 1.0.2 → 1.0.4

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.
@@ -17,7 +17,7 @@ describe("orm generate model", () => {
17
17
  };
18
18
  `,
19
19
  "app/db.server/models/user.ts": unindent `
20
- import { ModelDefinition, sql } from "@casekit/orm2";
20
+ import { type ModelDefinition, sql } from "@casekit/orm2";
21
21
 
22
22
  export const user = {
23
23
  fields: {
@@ -38,7 +38,7 @@ describe("orm generate model", () => {
38
38
  .parseAsync("model --name post --fields title:text content:text");
39
39
  const modelFile = vol.readFileSync("./app/db.server/models/post.ts", "utf8");
40
40
  expect(modelFile.trim()).toEqual(unindent `
41
- import { ModelDefinition, sql } from "@casekit/orm2";
41
+ import { type ModelDefinition, sql } from "@casekit/orm2";
42
42
 
43
43
  export const post = {
44
44
  fields: {
@@ -84,14 +84,21 @@ export const generateModelFile = async (opts, { directory }) => {
84
84
  const hasSqlLiteral = j(modelDefinition).find(j.TaggedTemplateExpression, {
85
85
  tag: { type: "Identifier", name: "sql" },
86
86
  }).length > 0;
87
- // Build the import statement
88
- const importSpecifiers = [
89
- j.importSpecifier(j.identifier("ModelDefinition")),
90
- ];
87
+ // Build the import statement by parsing the import code string
88
+ // to ensure proper TypeScript type-only import syntax
89
+ let importCode;
91
90
  if (hasSqlLiteral) {
92
- importSpecifiers.push(j.importSpecifier(j.identifier("sql")));
91
+ // import { type ModelDefinition, sql }
92
+ importCode =
93
+ 'import { type ModelDefinition, sql } from "@casekit/orm2";';
93
94
  }
94
- const importDeclaration = j.importDeclaration(importSpecifiers, j.literal("@casekit/orm2"));
95
+ else {
96
+ // import type { ModelDefinition }
97
+ importCode = 'import type { ModelDefinition } from "@casekit/orm2";';
98
+ }
99
+ const importDeclaration = j(importCode)
100
+ .find(j.ImportDeclaration)
101
+ .get().node;
95
102
  // Build the export statement with type assertion
96
103
  const exportDeclaration = j.exportNamedDeclaration(j.variableDeclaration("const", [
97
104
  j.variableDeclarator(j.identifier(opts.name), j.tsSatisfiesExpression(j.tsAsExpression(modelDefinition, j.tsTypeReference(j.identifier("const"))), j.tsTypeReference(j.identifier("ModelDefinition")))),
@@ -38,7 +38,7 @@ describe("generateModelFile", () => {
38
38
  fields: ["id:serial", "name:text"],
39
39
  }, { directory: "./app/db.server" });
40
40
  expect(result.trim()).toBe(unindent `
41
- import { ModelDefinition, sql } from "@casekit/orm2";
41
+ import { type ModelDefinition, sql } from "@casekit/orm2";
42
42
 
43
43
  export const bar = {
44
44
  fields: {
@@ -59,7 +59,7 @@ describe("generateModelFile", () => {
59
59
  directory: "./app/db.server",
60
60
  });
61
61
  expect(result.trim()).toBe(unindent `
62
- import { ModelDefinition } from "@casekit/orm2";
62
+ import type { ModelDefinition } from "@casekit/orm2";
63
63
 
64
64
  export const foo = {
65
65
  fields: {},
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@casekit/orm2-cli",
3
3
  "description": "",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "author": "",
6
6
  "bin": {
7
7
  "orm": "./build/cli.js"
@@ -17,10 +17,10 @@
17
17
  "pluralize": "^8.0.0",
18
18
  "tsx": "^4.20.3",
19
19
  "yargs": "^18.0.0",
20
- "@casekit/orm2": "1.0.2",
21
- "@casekit/sql": "1.0.2",
22
- "@casekit/toolbox": "1.0.2",
23
- "@casekit/orm2-migrate": "1.0.2"
20
+ "@casekit/orm2": "1.0.4",
21
+ "@casekit/orm2-migrate": "1.0.4",
22
+ "@casekit/toolbox": "1.0.4",
23
+ "@casekit/sql": "1.0.4"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@trivago/prettier-plugin-sort-imports": "^5.2.2",
@@ -39,9 +39,9 @@
39
39
  "vite-tsconfig-paths": "^5.1.4",
40
40
  "vitest": "^3.2.4",
41
41
  "zod": "^4.0.17",
42
- "@casekit/orm2-fixtures": "1.0.2",
43
- "@casekit/tsconfig": "1.0.2",
44
- "@casekit/prettier-config": "1.0.2"
42
+ "@casekit/orm2-fixtures": "1.0.4",
43
+ "@casekit/prettier-config": "1.0.4",
44
+ "@casekit/tsconfig": "1.0.4"
45
45
  },
46
46
  "exports": {
47
47
  ".": "./build/index.js"