Skip to content

Commit

Permalink
chore: make script executable
Browse files Browse the repository at this point in the history
  • Loading branch information
ruheni committed Oct 9, 2022
1 parent f464be4 commit d88ac8b
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 18 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {}
}
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"arrowParens": "always",
"printWidth": 80,
"singleQuote": false,
"jsxSingleQuote": false,
"semi": true,
"trailingComma": "all",
"tabWidth": 2
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"db-diff": "./dist/index.js"
},
"scripts": {
"dev": "tsup src/index.ts --format esm --watch --clean --onSuccess \"node dist/index.js\"",
"build": "tsup src/index.ts --format esm --clean --sourcemap --minify --metafile",
"dev": "tsup src/index.ts --format esm --watch --clean --onSuccess \"node dist/index.js\"",
"build": "tsup src/index.ts --format esm --clean --sourcemap --minify --metafile --treeshake",
"format": "prettier --write --plugin-search-dir=. \"**/*.ts\"",
"local": "npm run build && npm i -g && npx db-diff",
"format:check": "prettier --check --plugin-search-dir=. \"**/*.ts\"",
"lint": "eslint **/*.ts",
"lint:fix": "eslint **/*.ts --fix",
Expand All @@ -29,6 +30,8 @@
},
"devDependencies": {
"@types/node": "18.8.3",
"@typescript-eslint/eslint-plugin": "5.39.0",
"@typescript-eslint/parser": "5.39.0",
"eslint": "8.25.0",
"prettier": "2.7.1",
"tsup": "6.2.3",
Expand Down
180 changes: 180 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export default () => {
.option(
"--schema <path-to-your-schema-file>",
"Path to your Prisma schema file. Default value is `./prisma/schema.prisma`",
"./prisma/schema.prisma"
"./prisma/schema.prisma",
)
.option(
"--migrations-dir <path-to-your-migrations-dir>",
"Path to your migrations directory. Default value is `migrations`",
"./migrations"
"./migrations",
)
.option("--up", "Generates the `up` migration only", false)
.option("--down", "Generates the `down` migration only", false)
Expand Down
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
import logger from "./lib/logger";
import generateMigrations from "./lib/migration";
import CLI from "./cli";
Expand All @@ -11,25 +12,25 @@ async function main() {
await generateMigrations(
normalizedMigrationsDirPath,
normalizedSchemaPath,
"up"
"up",
);
} else if (down) {
await generateMigrations(
normalizedMigrationsDirPath,
normalizedSchemaPath,
"down"
"down",
);
} else {
Promise.all([
await generateMigrations(
normalizedMigrationsDirPath,
normalizedSchemaPath,
"down"
"down",
),
await generateMigrations(
normalizedMigrationsDirPath,
normalizedSchemaPath,
"up"
"up",
),
]);
}
Expand All @@ -41,7 +42,7 @@ main().catch((e) => {
logger.error(e.message);
} else {
logger.error("Oops, something went wrong...");
console.log(e);
logger.error(e);
}
});

Expand Down
Loading

0 comments on commit d88ac8b

Please sign in to comment.