@magda/scripts 2.3.3 → 3.0.0-alpha.1
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/acs-cmd/acs-cmd-admin-set.js +6 -5
- package/acs-cmd/acs-cmd-admin-unset.js +6 -5
- package/acs-cmd/acs-cmd-admin.js +3 -2
- package/acs-cmd/acs-cmd-assign-permission.js +7 -6
- package/acs-cmd/acs-cmd-assign-role.js +7 -6
- package/acs-cmd/acs-cmd-assign.js +3 -2
- package/acs-cmd/acs-cmd-create-operation.js +8 -7
- package/acs-cmd/acs-cmd-create-permission.js +6 -6
- package/acs-cmd/acs-cmd-create.js +3 -2
- package/acs-cmd/acs-cmd-jwt.js +6 -6
- package/acs-cmd/acs-cmd-list-permissions.js +5 -4
- package/acs-cmd/acs-cmd-list-resources.js +5 -4
- package/acs-cmd/acs-cmd-list-roles.js +5 -4
- package/acs-cmd/acs-cmd-list-users.js +5 -4
- package/acs-cmd/acs-cmd-list.js +3 -2
- package/acs-cmd/acs-cmd-remove-permission.js +7 -6
- package/acs-cmd/acs-cmd-remove-role.js +7 -6
- package/acs-cmd/acs-cmd-remove.js +3 -2
- package/acs-cmd/index.js +3 -2
- package/acs-cmd/utils.js +2 -5
- package/build-changed.js +8 -7
- package/check-release-version.js +6 -4
- package/create-api-key.js +7 -6
- package/create-docker-context-for-node-component.js +20 -15
- package/create-jwt-token.js +5 -5
- package/create-region-synonym-file.js +12 -27
- package/create-secrets/askQuestions.js +14 -20
- package/create-secrets/index.js +7 -6
- package/create-secrets/k8sExecution.js +9 -9
- package/create-secrets/preloadConfig.js +4 -4
- package/create-secrets/prompts/inquirer-fuzzy-path.js +9 -9
- package/create-secrets/prompts/list-with-transformer.js +5 -5
- package/create-secrets/pwgen.js +2 -2
- package/db/getDBConfig.js +1 -3
- package/db/getDBPool.js +3 -3
- package/docker-util.js +11 -11
- package/findLastModifiedFile.js +2 -2
- package/generate-api-documentation.js +7 -6
- package/generate-registry-typescript.js +5 -4
- package/getAllPackages.js +6 -2
- package/isScalaPackage.js +3 -3
- package/isTypeScriptPackage.js +4 -3
- package/loaders/remove-hashbag-loader.js +2 -2
- package/org-tree/getNodeIdFromNameOrId.js +2 -2
- package/org-tree/getUserIdFromNameOrId.js +2 -2
- package/org-tree/index.js +3 -2
- package/org-tree/org-tree-assign.js +9 -9
- package/org-tree/org-tree-create.js +6 -6
- package/org-tree/org-tree-delete.js +7 -7
- package/org-tree/org-tree-insert.js +8 -8
- package/org-tree/org-tree-move.js +8 -8
- package/org-tree/org-tree-unassign.js +6 -8
- package/org-tree/org-tree-view.js +5 -5
- package/package.json +18 -13
- package/retag-and-push.js +3 -8
- package/run-in-submodules.js +11 -9
- package/run-typescript-in-nodemon.js +6 -9
- package/set-scss-vars.js +1 -0
- package/tools/swagger-codegen-cli.jar +0 -0
- package/tools/swagger-codegen-cli.md +1 -1
- package/update-helm-chart-version.js +1 -0
- package/create-all-tsconfigs.js +0 -51
- package/create-pod-and-forward.js +0 -108
- package/generate-connector-jobs.js +0 -192
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { recordExist, ADMIN_ROLE_ID } from "./utils.js";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
10
11
|
program
|
|
11
12
|
.description("Make a user an Admin user")
|
|
12
|
-
.
|
|
13
|
+
.argument("<userId>", "User ID")
|
|
13
14
|
.version(pkg.version)
|
|
14
15
|
.action(async (userId) => {
|
|
15
16
|
try {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { recordExist, ADMIN_ROLE_ID } from "./utils.js";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
10
11
|
program
|
|
11
12
|
.description("Remove Admin role / status from a user")
|
|
12
|
-
.
|
|
13
|
+
.argument("<userId>", "User ID")
|
|
13
14
|
.version(pkg.version)
|
|
14
15
|
.action(async (userId) => {
|
|
15
16
|
try {
|
package/acs-cmd/acs-cmd-admin.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
5
6
|
|
|
6
7
|
program
|
|
7
8
|
.version(pkg.version)
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { recordExist } from "./utils.js";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
10
11
|
program
|
|
11
12
|
.description("assign the permission to a role")
|
|
12
|
-
.
|
|
13
|
-
.
|
|
13
|
+
.argument("<permissionId>", "Permission ID")
|
|
14
|
+
.argument("<roleId>", "Role ID")
|
|
14
15
|
.version(pkg.version)
|
|
15
16
|
.action(async (permissionId, roleId) => {
|
|
16
17
|
try {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { recordExist } from "./utils.js";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
10
11
|
program
|
|
11
12
|
.description("assign the role to a user")
|
|
12
|
-
.
|
|
13
|
-
.
|
|
13
|
+
.argument("<roleId>", "Role ID")
|
|
14
|
+
.argument("<userId>", "User ID")
|
|
14
15
|
.version(pkg.version)
|
|
15
16
|
.action(async (roleId, userId) => {
|
|
16
17
|
try {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
5
6
|
|
|
6
7
|
program
|
|
7
8
|
.version(pkg.version)
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
6
7
|
|
|
7
8
|
const pool = getDBPool();
|
|
8
9
|
|
|
9
10
|
program
|
|
10
11
|
.version(pkg.version)
|
|
11
12
|
.description(`A tool for creating operations. Version: ${pkg.version}`)
|
|
12
|
-
.
|
|
13
|
-
.
|
|
14
|
-
.
|
|
15
|
-
.
|
|
13
|
+
.argument("<permission>", "Permission name")
|
|
14
|
+
.argument("<uri>", "Operation uri")
|
|
15
|
+
.argument("<name>", "Operation name")
|
|
16
|
+
.argument("<description>", "Operation description")
|
|
16
17
|
.action(async (permissionName, uri, name, description) => {
|
|
17
18
|
try {
|
|
18
19
|
await pool.query("BEGIN TRANSACTION");
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { recordExist } = require("./utils");
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
7
|
|
|
8
8
|
const pool = getDBPool();
|
|
9
9
|
|
|
10
10
|
program
|
|
11
11
|
.version(pkg.version)
|
|
12
12
|
.description(`A tool for creating permissions. Version: ${pkg.version}`)
|
|
13
|
-
.
|
|
14
|
-
.
|
|
13
|
+
.argument("<name>", "Permission name")
|
|
14
|
+
.argument("<description>", "Permission description")
|
|
15
15
|
.action(async (name, description) => {
|
|
16
16
|
try {
|
|
17
17
|
await pool.query(
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
5
6
|
|
|
6
7
|
program
|
|
7
8
|
.version(pkg.version)
|
package/acs-cmd/acs-cmd-jwt.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.default;
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import buildJwt from "@magda/typescript-common/dist/session/buildJwt.js";
|
|
7
7
|
|
|
8
8
|
const DEFAULT_JWT_SECRET = "squirrel";
|
|
9
9
|
|
|
@@ -11,8 +11,8 @@ program
|
|
|
11
11
|
.description(
|
|
12
12
|
`calculate JWT token (only for testing purpose). Version: ${pkg.version}`
|
|
13
13
|
)
|
|
14
|
-
.
|
|
15
|
-
.
|
|
14
|
+
.argument("<userId>", "User ID")
|
|
15
|
+
.argument(
|
|
16
16
|
"[jwtSecret]",
|
|
17
17
|
"Optional JWT secret. Default value: `" + DEFAULT_JWT_SECRET + "`"
|
|
18
18
|
)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { table } from "table";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { table } from "table";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { table } from "table";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { table } from "table";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
package/acs-cmd/acs-cmd-list.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
5
6
|
|
|
6
7
|
program
|
|
7
8
|
.version(pkg.version)
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { recordExist } from "./utils.js";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
10
11
|
program
|
|
11
12
|
.description("Remove a permission from a role")
|
|
12
|
-
.
|
|
13
|
-
.
|
|
13
|
+
.argument("<permissionId>", "Permission ID")
|
|
14
|
+
.argument("<roleId>", "Role ID")
|
|
14
15
|
.version(pkg.version)
|
|
15
16
|
.action(async (permissionId, roleId) => {
|
|
16
17
|
try {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import getDBPool from "../db/getDBPool.js";
|
|
7
|
+
import { recordExist } from "./utils.js";
|
|
7
8
|
|
|
8
9
|
const pool = getDBPool();
|
|
9
10
|
|
|
10
11
|
program
|
|
11
12
|
.description("Remove a role from a user")
|
|
12
|
-
.
|
|
13
|
-
.
|
|
13
|
+
.argument("<roleId>", "Role ID")
|
|
14
|
+
.argument("<userId>", "User ID")
|
|
14
15
|
.version(pkg.version)
|
|
15
16
|
.action(async (roleId, userId) => {
|
|
16
17
|
try {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
5
6
|
|
|
6
7
|
program
|
|
7
8
|
.version(pkg.version)
|
package/acs-cmd/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("../package.json");
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
5
6
|
|
|
6
7
|
program
|
|
7
8
|
.version(pkg.version)
|
package/acs-cmd/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function recordExist(pool, table, record) {
|
|
1
|
+
export async function recordExist(pool, table, record) {
|
|
2
2
|
if (!Object.keys(record).length) {
|
|
3
3
|
throw new Error("record cannot be an empty object!");
|
|
4
4
|
}
|
|
@@ -19,7 +19,4 @@ async function recordExist(pool, table, record) {
|
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const ADMIN_ROLE_ID = "00000000-0000-0003-0000-000000000000";
|
|
23
|
-
|
|
24
|
-
module.exports.recordExist = recordExist;
|
|
25
|
-
module.exports.ADMIN_ROLE_ID = ADMIN_ROLE_ID;
|
|
22
|
+
export const ADMIN_ROLE_ID = "00000000-0000-0003-0000-000000000000";
|
package/build-changed.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { require } from "@magda/esm-utils";
|
|
2
|
+
import childProcess from "child_process";
|
|
3
|
+
import getAllPackages from "./getAllPackages.js";
|
|
4
|
+
import isScalaPackage from "./isScalaPackage";
|
|
5
|
+
import findLastModifiedFile from "./findLastModifiedFile";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import toposort from "toposort";
|
|
8
|
+
import yargs from "yargs";
|
|
8
9
|
|
|
9
10
|
const argv = yargs.config().help().option("skipDocker", {
|
|
10
11
|
describe: "Skip the build/push of the docker image.",
|
package/check-release-version.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
3
|
+
const pkg = require("./package.json");
|
|
4
|
+
import path from "path";
|
|
5
|
+
import fse from "fs-extra";
|
|
6
|
+
import chalk from "chalk";
|
|
5
7
|
|
|
6
8
|
const cwdPath = process.cwd();
|
|
7
|
-
|
|
9
|
+
|
|
8
10
|
if (!pkg || !pkg["version"]) {
|
|
9
11
|
console.error(chalk.red("Cannot find package.json at: " + cwdPath));
|
|
10
12
|
process.exit(-1);
|
package/create-api-key.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("./package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import bcrypt from "bcrypt";
|
|
7
|
+
import crypto from "crypto";
|
|
8
|
+
import getDBPool from "./db/getDBPool.js";
|
|
9
|
+
import isUuid from "isuuid";
|
|
9
10
|
const { table } = require("table");
|
|
10
11
|
|
|
11
12
|
program
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getRepository
|
|
15
|
-
} = require("./docker-util");
|
|
3
|
+
import childProcess from "child_process";
|
|
4
|
+
import fse from "fs-extra";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import process from "process";
|
|
7
|
+
import yargs from "yargs";
|
|
8
|
+
import _ from "lodash";
|
|
9
|
+
import isSubDir from "is-subdir";
|
|
10
|
+
import { getVersions, getTags, getName, getRepository } from "./docker-util.js";
|
|
11
|
+
import { __dirname as getCurDirPath, require } from "@magda/esm-utils";
|
|
12
|
+
|
|
13
|
+
const __dirname = getCurDirPath();
|
|
16
14
|
|
|
17
15
|
// --- cache dependencies data from package.json
|
|
18
16
|
const packageDependencyDataCache = {};
|
|
@@ -315,7 +313,7 @@ function preparePackage(packageDir, destDir) {
|
|
|
315
313
|
|
|
316
314
|
const productionPackages = _.uniqBy(
|
|
317
315
|
getPackageList(packageDir, path.resolve(packageDir, "..")),
|
|
318
|
-
(
|
|
316
|
+
(pkg) => pkg.path
|
|
319
317
|
);
|
|
320
318
|
|
|
321
319
|
prepareNodeModules(src, dest, productionPackages);
|
|
@@ -349,7 +347,14 @@ function prepareNodeModules(packageDir, destDir, productionPackages) {
|
|
|
349
347
|
const type = stat.isFile() ? "file" : "junction";
|
|
350
348
|
fse.ensureSymlinkSync(srcPath, dest, type);
|
|
351
349
|
} catch (e) {
|
|
352
|
-
|
|
350
|
+
// see all error codes here: https://man7.org/linux/man-pages/man2/symlink.2.html#ERRORS
|
|
351
|
+
if (e?.code === "EEXIST") {
|
|
352
|
+
//console.log(`symlink ${srcPath} already exists, skip.`);
|
|
353
|
+
// the link already exists, we choose to not attempt to overwrite it.
|
|
354
|
+
// this means that the local dependency (in nearest node_modules) will higher priority than hoisted dependency (in root node_modules).
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
throw e;
|
|
353
358
|
}
|
|
354
359
|
});
|
|
355
360
|
}
|
package/create-jwt-token.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { require } from "@magda/esm-utils";
|
|
2
3
|
const pkg = require("./package.json");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.default;
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import isUuid from "isuuid";
|
|
7
|
+
import buildJwt from "@magda/typescript-common/dist/session/buildJwt.js";
|
|
8
8
|
|
|
9
9
|
program
|
|
10
10
|
.version(pkg.version)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import yargs from "yargs";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import fetch from "node-fetch";
|
|
6
|
+
import StreamArray from "stream-json/streamers/StreamArray.js";
|
|
7
7
|
|
|
8
8
|
function getDefaultRegionSourceConfig() {
|
|
9
9
|
try {
|
|
@@ -85,28 +85,13 @@ function createLineFromRegionData(regionConfig, item) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
async function getRemoteDataFileStream(url) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
response.statusCode >= 200 &&
|
|
96
|
-
response.statusCode <= 299
|
|
97
|
-
) {
|
|
98
|
-
resolve(response.pipe(StreamArray.withParser()));
|
|
99
|
-
} else {
|
|
100
|
-
throw new Error(
|
|
101
|
-
`Request failed ${url}, statusCode: ${response.statusCode}`
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
} catch (e) {
|
|
105
|
-
console.error(e);
|
|
106
|
-
reject(e);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
88
|
+
const res = await fetch(url);
|
|
89
|
+
if (!res.ok) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Request failed ${url}, statusCode: ${res.status} ${res.statusText}`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return res.body.pipe(StreamArray.withParser());
|
|
110
95
|
}
|
|
111
96
|
|
|
112
97
|
async function processRegionDataPipeline(regionConfig, targetStream) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import trim from "lodash/trim.js";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import moment from "moment";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import pwgen from "./pwgen.js";
|
|
8
|
+
import partial from "lodash/partial.js";
|
|
9
|
+
import stripJsonComments from "strip-json-comments";
|
|
10
10
|
|
|
11
11
|
const questions = [
|
|
12
12
|
{
|
|
@@ -774,7 +774,7 @@ function askStartSecretsCreationWithoutQuestions(config) {
|
|
|
774
774
|
.then((answers) => answers["deploy-now"]);
|
|
775
775
|
}
|
|
776
776
|
|
|
777
|
-
function askIfCreateNamespace(namespace) {
|
|
777
|
+
export function askIfCreateNamespace(namespace) {
|
|
778
778
|
return inquirer
|
|
779
779
|
.prompt([
|
|
780
780
|
{
|
|
@@ -796,7 +796,7 @@ function askIfCreateNamespace(namespace) {
|
|
|
796
796
|
.then((answers) => answers["if-create-namespace"]);
|
|
797
797
|
}
|
|
798
798
|
|
|
799
|
-
function askQuestions(config) {
|
|
799
|
+
export function askQuestions(config) {
|
|
800
800
|
return new Promise(function (resolve, reject) {
|
|
801
801
|
const creationTime = config.get("creation-time");
|
|
802
802
|
let p;
|
|
@@ -817,7 +817,7 @@ function askQuestions(config) {
|
|
|
817
817
|
});
|
|
818
818
|
}
|
|
819
819
|
|
|
820
|
-
function getEnvVarInfo() {
|
|
820
|
+
export function getEnvVarInfo() {
|
|
821
821
|
return questions.map((item) => ({
|
|
822
822
|
name: settingNameToEnvVarName(item.name),
|
|
823
823
|
dataType: item.dataType ? item.dataType : "string",
|
|
@@ -826,14 +826,8 @@ function getEnvVarInfo() {
|
|
|
826
826
|
}));
|
|
827
827
|
}
|
|
828
828
|
|
|
829
|
-
function settingNameToEnvVarName(settingName) {
|
|
829
|
+
export function settingNameToEnvVarName(settingName) {
|
|
830
830
|
return settingName.replace(/\-/g, "_").toUpperCase();
|
|
831
831
|
}
|
|
832
832
|
|
|
833
|
-
|
|
834
|
-
askQuestions,
|
|
835
|
-
getEnvVarInfo,
|
|
836
|
-
settingNameToEnvVarName,
|
|
837
|
-
askIfCreateNamespace,
|
|
838
|
-
settingNameToEnvVarName
|
|
839
|
-
};
|
|
833
|
+
export default askQuestions;
|