Add title to migration
This commit is contained in:
parent
22bc8e1a37
commit
5355238713
|
@ -17,14 +17,14 @@
|
|||
"kill-port": "^1.6.1",
|
||||
"lerna": "7.1.1",
|
||||
"madge": "^6.0.0",
|
||||
"minimist": "^1.2.8",
|
||||
"nx": "16.4.3",
|
||||
"nx-cloud": "16.0.5",
|
||||
"prettier": "2.8.8",
|
||||
"prettier-plugin-svelte": "^2.3.0",
|
||||
"svelte": "3.49.0",
|
||||
"svelte-eslint-parser": "^0.32.0",
|
||||
"typescript": "5.2.2"
|
||||
"typescript": "5.2.2",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"scripts": {
|
||||
"preinstall": "node scripts/syncProPackage.js",
|
||||
|
@ -80,7 +80,7 @@
|
|||
"postinstall": "husky install",
|
||||
"submodules:load": "git submodule init && git submodule update && yarn",
|
||||
"submodules:unload": "git submodule deinit --all && yarn",
|
||||
"add-app-migration": "node scripts/add-app-migration.js"
|
||||
"add-app-migration": "node scripts/add-app-migration.js --title"
|
||||
},
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
|
||||
const argv = require("yargs").demandOption(
|
||||
["title"],
|
||||
"Please provide the required parameter: --title=[title]"
|
||||
).argv
|
||||
|
||||
const { title } = argv
|
||||
|
||||
const generateTimestamp = () => {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
|
@ -14,7 +21,7 @@ const generateTimestamp = () => {
|
|||
}
|
||||
|
||||
const createMigrationFile = () => {
|
||||
const timestamp = generateTimestamp()
|
||||
const migrationFilename = `${generateTimestamp()}_${title}`
|
||||
const migrationsDir = "../packages/server/src/appMigrations"
|
||||
|
||||
const template = `const migration = async () => {
|
||||
|
@ -27,7 +34,7 @@ export default migration
|
|||
const newMigrationPath = path.join(
|
||||
migrationsDir,
|
||||
"migrations",
|
||||
`${timestamp}.ts`
|
||||
`${migrationFilename}.ts`
|
||||
)
|
||||
fs.writeFileSync(path.resolve(__dirname, newMigrationPath), template)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ const {
|
|||
} = require("@esbuild-plugins/tsconfig-paths")
|
||||
const { nodeExternalsPlugin } = require("esbuild-node-externals")
|
||||
|
||||
var argv = require("minimist")(process.argv.slice(2))
|
||||
var { argv } = require("yargs")
|
||||
|
||||
function runBuild(entry, outfile) {
|
||||
const isDev = process.env.NODE_ENV !== "production"
|
||||
|
|
15
yarn.lock
15
yarn.lock
|
@ -15618,7 +15618,7 @@ minimist-options@4.1.0:
|
|||
is-plain-obj "^1.1.0"
|
||||
kind-of "^6.0.3"
|
||||
|
||||
minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5, minimist@^1.2.6, minimist@^1.2.8:
|
||||
minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5, minimist@^1.2.6:
|
||||
version "1.2.8"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
|
||||
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
|
||||
|
@ -22845,6 +22845,19 @@ yargs@^17.3.1, yargs@^17.5.1, yargs@^17.6.2:
|
|||
y18n "^5.0.5"
|
||||
yargs-parser "^21.1.1"
|
||||
|
||||
yargs@^17.7.2:
|
||||
version "17.7.2"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"
|
||||
integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==
|
||||
dependencies:
|
||||
cliui "^8.0.1"
|
||||
escalade "^3.1.1"
|
||||
get-caller-file "^2.0.5"
|
||||
require-directory "^2.1.1"
|
||||
string-width "^4.2.3"
|
||||
y18n "^5.0.5"
|
||||
yargs-parser "^21.1.1"
|
||||
|
||||
yauzl@^2.4.2:
|
||||
version "2.10.0"
|
||||
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
|
||||
|
|
Loading…
Reference in New Issue