biz-a-cli 2.3.74 → 2.3.76
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/bin/migrate.js +12 -10
- package/envs/env.dev.js +1 -1
- package/package.json +2 -2
- package/worker/cliWorkerPool.js +8 -1
package/bin/migrate.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { queryData, save as dbSave, executeBlock } from "../db/db.js";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
const migrationDir = path.resolve(__dirname, "migrations");
|
|
4
9
|
|
|
5
10
|
const flattenSql = (sqlString) => {
|
|
6
11
|
return sqlString
|
|
@@ -12,9 +17,8 @@ const flattenSql = (sqlString) => {
|
|
|
12
17
|
};
|
|
13
18
|
|
|
14
19
|
export const newMigration = (argv) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
20
|
+
if (!fs.existsSync(migrationDir)) {
|
|
21
|
+
fs.mkdirSync(migrationDir, { recursive: true });
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
const safeName = argv.name
|
|
@@ -37,16 +41,14 @@ export const newMigration = (argv) => {
|
|
|
37
41
|
"",
|
|
38
42
|
].join("\n");
|
|
39
43
|
|
|
40
|
-
fs.writeFileSync(path.join(
|
|
44
|
+
fs.writeFileSync(path.join(migrationDir, filename), template);
|
|
41
45
|
console.log(`[Success] Created new migration file: migrations/${filename}`);
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
export const runMigrations = async (argv) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!fs.existsSync(migrationsDir)) {
|
|
49
|
+
if (!fs.existsSync(migrationDir)) {
|
|
48
50
|
console.log(
|
|
49
|
-
`[Migrate] No 'migrations' folder found at ${
|
|
51
|
+
`[Migrate] No 'migrations' folder found at ${migrationDir}`,
|
|
50
52
|
);
|
|
51
53
|
return { success: false, error: "Missing migrations folder" };
|
|
52
54
|
}
|
|
@@ -75,7 +77,7 @@ export const runMigrations = async (argv) => {
|
|
|
75
77
|
|
|
76
78
|
try {
|
|
77
79
|
const files = fs
|
|
78
|
-
.readdirSync(
|
|
80
|
+
.readdirSync(migrationDir)
|
|
79
81
|
.filter((f) => f.endsWith(".sql"))
|
|
80
82
|
.sort();
|
|
81
83
|
|
|
@@ -102,7 +104,7 @@ export const runMigrations = async (argv) => {
|
|
|
102
104
|
|
|
103
105
|
console.log(`[Migrate] Executing ${file}...`);
|
|
104
106
|
const sqlContent = fs.readFileSync(
|
|
105
|
-
path.join(
|
|
107
|
+
path.join(migrationDir, file),
|
|
106
108
|
"utf8",
|
|
107
109
|
);
|
|
108
110
|
|
package/envs/env.dev.js
CHANGED
|
@@ -6,5 +6,5 @@ export const envDev = {
|
|
|
6
6
|
encodeURIComponent('imm@2019') + '@imm-cdm-dev.rf6wr.mongodb.net/?retryWrites=true&w=majority',
|
|
7
7
|
COMPANY_REGISTER: 'companyregister-dev',
|
|
8
8
|
BIZA_SERVER_LINK: 'https://biz-a-dev-41e7c93a25e5.herokuapp.com',
|
|
9
|
-
BIZA_HUB_SERVER_LINK: 'https://
|
|
9
|
+
BIZA_HUB_SERVER_LINK: 'https://devHub.biz-a.id' // https://biz-a-hub-ed77b066db87.herokuapp.com/
|
|
10
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "biz-a-cli",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.76",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"mailController.js",
|
|
22
22
|
"proxyController.js",
|
|
23
23
|
"readme.md"
|
|
24
|
-
],
|
|
24
|
+
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch a",
|
|
27
27
|
"testOnce": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
package/worker/cliWorkerPool.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import workerpool from "workerpool";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
2
7
|
|
|
3
8
|
export const cliScriptWorkerPool = workerpool.pool(
|
|
4
|
-
"./worker/cliScriptWorker.js",
|
|
9
|
+
// "./worker/cliScriptWorker.js",
|
|
10
|
+
// path.join(import.meta.dirname, "cliScriptWorker.js"),
|
|
11
|
+
path.join(__dirname, "cliScriptWorker.js"),
|
|
5
12
|
{
|
|
6
13
|
workerType: "thread",
|
|
7
14
|
emitStdStreams: true, // the worker will emit stdout and stderr events instead of passing it through to the parent streams
|