node-pg-migrate
Advanced tools
Comparing version 7.5.0-experimental-1187-0 to 7.5.0-experimental-1187-1
@@ -37,16 +37,9 @@ #!/usr/bin/env node | ||
}); | ||
let xRequire; | ||
try { | ||
xRequire = require; | ||
} catch (error) { | ||
if (error instanceof ReferenceError && error.message === "require is not defined") { | ||
xRequire = (0, import_node_module.createRequire)( | ||
// @ts-expect-error: ignore until esm only | ||
import_meta.url | ||
); | ||
} | ||
} | ||
const crossRequire = (0, import_node_module.createRequire)( | ||
// @ts-expect-error: ignore until esm only | ||
import_meta.url || __dirname | ||
); | ||
function tryRequire(moduleName) { | ||
try { | ||
return xRequire(moduleName); | ||
return crossRequire(moduleName); | ||
} catch (error) { | ||
@@ -390,3 +383,3 @@ if ( | ||
if (configFileName) { | ||
const jsonConfig = xRequire((0, import_node_path.resolve)(configFileName)); | ||
const jsonConfig = crossRequire((0, import_node_path.resolve)(configFileName)); | ||
readJson(jsonConfig); | ||
@@ -393,0 +386,0 @@ } |
@@ -24,21 +24,10 @@ #!/usr/bin/env node | ||
let xRequire!: NodeRequire; | ||
const crossRequire = createRequire( | ||
// @ts-expect-error: ignore until esm only | ||
import.meta.url || __dirname | ||
); | ||
try { | ||
xRequire = require; | ||
} catch (error) { | ||
if ( | ||
error instanceof ReferenceError && | ||
error.message === 'require is not defined' | ||
) { | ||
xRequire = createRequire( | ||
// @ts-expect-error: ignore until esm only | ||
import.meta.url | ||
); | ||
} | ||
} | ||
function tryRequire<TModule = unknown>(moduleName: string): TModule | null { | ||
try { | ||
return xRequire(moduleName); | ||
return crossRequire(moduleName); | ||
} catch (error) { | ||
@@ -447,3 +436,3 @@ if ( | ||
if (configFileName) { | ||
const jsonConfig = xRequire(resolve(configFileName)); | ||
const jsonConfig = crossRequire(resolve(configFileName)); | ||
readJson(jsonConfig); | ||
@@ -450,0 +439,0 @@ } |
@@ -39,4 +39,6 @@ "use strict"; | ||
module.exports = __toCommonJS(migration_exports); | ||
const import_meta = {}; | ||
var import_node_fs = require("node:fs"); | ||
var import_promises = require("node:fs/promises"); | ||
var import_node_module = require("node:module"); | ||
var import_node_path = require("node:path"); | ||
@@ -121,6 +123,12 @@ var import_migrationBuilder = __toESM(require("./migrationBuilder")); | ||
const time = filenameFormat === "utc" /* utc */ ? now.toISOString().replace(/\D/g, "") : now.valueOf(); | ||
const crossRequire = (0, import_node_module.createRequire)( | ||
// @ts-expect-error: ignore until esm only | ||
import_meta.url || __dirname | ||
); | ||
const moduleDir = (0, import_node_path.dirname)( | ||
crossRequire.resolve("node-pg-migrate/package.json") | ||
); | ||
const templateFileName = "templateFileName" in options ? (0, import_node_path.resolve)(process.cwd(), options.templateFileName) : (0, import_node_path.resolve)( | ||
__dirname, | ||
moduleDir, | ||
(0, import_node_path.join)( | ||
"..", | ||
"templates", | ||
@@ -127,0 +135,0 @@ `migration-template.${await resolveSuffix(directory, options)}` |
@@ -35,9 +35,5 @@ "use strict"; | ||
const cascadeStr = cascade ? " CASCADE" : ""; | ||
const columnsStr = (0, import_utils.formatLines)( | ||
columns.map(mOptions.literal), | ||
` DROP ${ifExistsStr}`, | ||
`${cascadeStr},` | ||
); | ||
const lines = columns.map(mOptions.literal).map((column) => `DROP ${ifExistsStr}${column}${cascadeStr}`); | ||
return `ALTER TABLE ${mOptions.literal(tableName)} | ||
${columnsStr};`; | ||
${(0, import_utils.formatLines)(lines)};`; | ||
}; | ||
@@ -44,0 +40,0 @@ return _drop; |
{ | ||
"name": "node-pg-migrate", | ||
"version": "7.5.0-experimental-1187-0", | ||
"version": "7.5.0-experimental-1187-1", | ||
"description": "PostgreSQL database migration management tool for node.js", | ||
@@ -107,3 +107,3 @@ "scripts": { | ||
"@types/config": "3.3.4", | ||
"@types/node": "18.19.33", | ||
"@types/node": "18.19.34", | ||
"@types/pg": "8.11.6", | ||
@@ -128,4 +128,4 @@ "@types/yargs": "17.0.32", | ||
"npm-run-all2": "6.2.0", | ||
"pg": "8.11.5", | ||
"prettier": "3.3.0", | ||
"pg": "8.12.0", | ||
"prettier": "3.3.1", | ||
"prettier-plugin-organize-imports": "3.2.4", | ||
@@ -136,3 +136,3 @@ "rimraf": "5.0.7", | ||
"typescript": "4.8.4", | ||
"vitepress": "1.2.2", | ||
"vitepress": "1.2.3", | ||
"vitest": "1.6.0" | ||
@@ -149,3 +149,3 @@ }, | ||
}, | ||
"packageManager": "pnpm@9.1.4", | ||
"packageManager": "pnpm@9.3.0", | ||
"engines": { | ||
@@ -152,0 +152,0 @@ "node": ">=18.19.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
527843
13151