orchid-orm 1.5.15 → 1.5.17
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 +14 -0
- package/dist/bin.js +19 -0
- package/dist/bin.js.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/bin/init.test.ts +2 -0
- package/src/bin/init.ts +21 -0
- package/src/codegen/testUtils.ts +6 -5
- package/src/codegen/updateMainFile.test.ts +35 -20
- package/src/codegen/updateMainFile.ts +8 -2
- package/src/codegen/updateTableFile/changeTable.test.ts +72 -72
- package/src/codegen/updateTableFile/createTable.test.ts +6 -6
- package/src/codegen/updateTableFile/renameTable.test.ts +17 -17
- package/src/codegen/updateTableFile/renameTable.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1644,9 +1644,14 @@ const updateMainFile = async (filePath, tablePath, ast, options) => {
|
|
|
1644
1644
|
};
|
|
1645
1645
|
const createTable$1 = ({ filePath, tablePath, statements, object, content, spaces }, ast) => {
|
|
1646
1646
|
const key = toCamelCase(ast.name);
|
|
1647
|
-
const value = toPascalCase(ast.name)
|
|
1647
|
+
const value = `${toPascalCase(ast.name)}Table`;
|
|
1648
1648
|
const changes = new FileChanges(content);
|
|
1649
1649
|
const importPath = getImportPath(filePath, tablePath(ast.name));
|
|
1650
|
+
const existing = Array.from(
|
|
1651
|
+
ts.import.iterateWithSource(statements, importPath)
|
|
1652
|
+
);
|
|
1653
|
+
if (existing.length)
|
|
1654
|
+
return;
|
|
1650
1655
|
const importPos = ts.import.getEndPos(statements);
|
|
1651
1656
|
changes.add(
|
|
1652
1657
|
importPos,
|
|
@@ -1667,7 +1672,7 @@ ${spaces}`;
|
|
|
1667
1672
|
const dropTable = ({ filePath, tablePath, statements, object, content }, ast) => {
|
|
1668
1673
|
const changes = new FileChanges(content);
|
|
1669
1674
|
const importPath = getImportPath(filePath, tablePath(ast.name));
|
|
1670
|
-
const tableClassName = toPascalCase(ast.name)
|
|
1675
|
+
const tableClassName = `${toPascalCase(ast.name)}Table`;
|
|
1671
1676
|
const importNames = [];
|
|
1672
1677
|
for (const node of ts.import.iterateWithSource(statements, importPath)) {
|
|
1673
1678
|
changes.remove(node.pos, node.end);
|
|
@@ -2234,7 +2239,7 @@ const renameTable = async (_a) => {
|
|
|
2234
2239
|
}
|
|
2235
2240
|
}
|
|
2236
2241
|
}
|
|
2237
|
-
await fs.writeFile(
|
|
2242
|
+
await fs.writeFile(tablePath, changes.apply());
|
|
2238
2243
|
};
|
|
2239
2244
|
|
|
2240
2245
|
var __defProp$1 = Object.defineProperty;
|