@prosopo/scripts 3.1.138 → 3.1.140
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/.turbo/turbo-build$colon$cjs.log +20 -35
- package/.turbo/turbo-build$colon$tsc.log +28 -28
- package/.turbo/turbo-build.log +24 -38
- package/CHANGELOG.md +35 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/cli/index.cjs +77 -81
- package/dist/cjs/index.cjs +16 -17
- package/dist/cjs/scripts/setVersion.cjs +119 -127
- package/dist/cjs/setup/index.cjs +5 -7
- package/dist/cjs/setup/provider.cjs +8 -8
- package/dist/cjs/setup/setup.cjs +109 -123
- package/dist/cjs/setup/site.cjs +21 -22
- package/dist/cjs/util/exec.cjs +35 -44
- package/dist/cjs/util/fluxLogDappDetails.cjs +10 -15
- package/dist/cjs/util/index.cjs +8 -10
- package/dist/cjs/util/updateEnv.cjs +61 -61
- package/dist/cli/index.js +69 -80
- package/dist/index.js +7 -16
- package/dist/scripts/setVersion.js +110 -126
- package/dist/setup/index.js +2 -6
- package/dist/setup/provider.js +7 -7
- package/dist/setup/setup.js +97 -119
- package/dist/setup/site.js +21 -22
- package/dist/util/exec.js +34 -43
- package/dist/util/fluxLogDappDetails.js +11 -16
- package/dist/util/index.js +1 -7
- package/dist/util/updateEnv.js +52 -59
- package/dist/workspace/dist/_virtual/_rolldown/runtime.js +2 -0
- package/dist/workspace/dist/index.js +2 -41
- package/dist/workspace/dist/projectInfo.js +80 -114
- package/package.json +18 -18
package/dist/cjs/util/exec.cjs
CHANGED
|
@@ -1,46 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
stderr: stderrData.join(""),
|
|
36
|
-
code
|
|
37
|
-
};
|
|
38
|
-
if (code === 0) {
|
|
39
|
-
resolve(output);
|
|
40
|
-
} else {
|
|
41
|
-
reject(output);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
1
|
+
let node_child_process = require("node:child_process");
|
|
2
|
+
let node_process = require("node:process");
|
|
3
|
+
//#region src/util/exec.ts
|
|
4
|
+
var exec = (command, options) => {
|
|
5
|
+
let { pipe, printCmd } = options || {};
|
|
6
|
+
pipe = pipe === void 0 || pipe;
|
|
7
|
+
printCmd = printCmd === void 0 || printCmd;
|
|
8
|
+
if (printCmd) console.log(`[exec] ${command}`);
|
|
9
|
+
const prc = (0, node_child_process.spawn)(command, { shell: true });
|
|
10
|
+
if (pipe || pipe === void 0) {
|
|
11
|
+
prc.stdout.pipe(process.stdout);
|
|
12
|
+
prc.stderr.pipe(process.stderr);
|
|
13
|
+
}
|
|
14
|
+
node_process.stdin.pipe(prc.stdin);
|
|
15
|
+
const stdoutData = [];
|
|
16
|
+
const stderrData = [];
|
|
17
|
+
prc.stdout.on("data", (data) => {
|
|
18
|
+
stdoutData.push(data.toString());
|
|
19
|
+
});
|
|
20
|
+
prc.stderr.on("data", (data) => {
|
|
21
|
+
stderrData.push(data.toString());
|
|
22
|
+
});
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
prc.on("close", (code) => {
|
|
25
|
+
if (pipe || pipe === void 0) console.log("");
|
|
26
|
+
const output = {
|
|
27
|
+
stdout: stdoutData.join(""),
|
|
28
|
+
stderr: stderrData.join(""),
|
|
29
|
+
code
|
|
30
|
+
};
|
|
31
|
+
if (code === 0) resolve(output);
|
|
32
|
+
else reject(output);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
45
35
|
};
|
|
36
|
+
//#endregion
|
|
46
37
|
exports.exec = exec;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
|
+
//#region src/util/fluxLogDappDetails.ts
|
|
3
2
|
function extractReferrersFromLogs(logsText) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return accumulator;
|
|
14
|
-
}, /* @__PURE__ */ new Set())
|
|
15
|
-
];
|
|
16
|
-
return urls.join(" ");
|
|
3
|
+
return [...logsText.split("\n").reduce((accumulator, line) => {
|
|
4
|
+
const matches = line.match(/"(https?:\/\/[^"]+)"/g);
|
|
5
|
+
if (matches) for (const match of matches) {
|
|
6
|
+
const url = match.substring(1, match.length - 1);
|
|
7
|
+
accumulator.add(url);
|
|
8
|
+
}
|
|
9
|
+
return accumulator;
|
|
10
|
+
}, /* @__PURE__ */ new Set())].join(" ");
|
|
17
11
|
}
|
|
12
|
+
//#endregion
|
|
18
13
|
exports.extractReferrersFromLogs = extractReferrersFromLogs;
|
package/dist/cjs/util/index.cjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.findEnvFiles =
|
|
7
|
-
exports.updateDemoHTMLFiles =
|
|
8
|
-
exports.updateEnvFiles =
|
|
9
|
-
exports.exec = exec.exec;
|
|
10
|
-
exports.extractReferrersFromLogs = fluxLogDappDetails.extractReferrersFromLogs;
|
|
1
|
+
const require_updateEnv = require("./updateEnv.cjs");
|
|
2
|
+
const require_exec = require("./exec.cjs");
|
|
3
|
+
const require_fluxLogDappDetails = require("./fluxLogDappDetails.cjs");
|
|
4
|
+
exports.exec = require_exec.exec;
|
|
5
|
+
exports.extractReferrersFromLogs = require_fluxLogDappDetails.extractReferrersFromLogs;
|
|
6
|
+
exports.findEnvFiles = require_updateEnv.findEnvFiles;
|
|
7
|
+
exports.updateDemoHTMLFiles = require_updateEnv.updateDemoHTMLFiles;
|
|
8
|
+
exports.updateEnvFiles = require_updateEnv.updateEnvFiles;
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
4
|
+
let _prosopo_dotenv = require("@prosopo/dotenv");
|
|
5
|
+
let _prosopo_util = require("@prosopo/util");
|
|
6
|
+
let node_fs = require("node:fs");
|
|
7
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
8
|
+
let dotenv = require("dotenv");
|
|
9
|
+
dotenv = require_runtime.__toESM(dotenv, 1);
|
|
10
|
+
let fast_glob = require("fast-glob");
|
|
11
|
+
fast_glob = require_runtime.__toESM(fast_glob, 1);
|
|
12
|
+
//#region src/util/updateEnv.ts
|
|
13
|
+
var ignore = [
|
|
14
|
+
"**/node_modules/**",
|
|
15
|
+
"node_modules/**",
|
|
16
|
+
"../../**/node_modules/**",
|
|
17
|
+
"../node_modules/**",
|
|
18
|
+
"../../node_modules/**"
|
|
15
19
|
];
|
|
16
|
-
|
|
20
|
+
var __dirname$1 = node_path.default.resolve();
|
|
17
21
|
async function findEnvFiles(logger, cwd) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return await fg(`${cwd || "../.."}/**/${fileName}`, {
|
|
22
|
-
ignore
|
|
23
|
-
});
|
|
22
|
+
const fileName = `.env.${(0, _prosopo_dotenv.getEnv)()}`;
|
|
23
|
+
logger.info(() => ({ msg: "Searching for files" }));
|
|
24
|
+
return await (0, fast_glob.default)(`${cwd || "../.."}/**/${fileName}`, { ignore });
|
|
24
25
|
}
|
|
25
26
|
async function updateDemoHTMLFiles(varMatchers, varValue, logger) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
const files = await (0, fast_glob.default)("../../demos/**/*.html", { ignore });
|
|
28
|
+
logger.info(() => ({
|
|
29
|
+
data: { files },
|
|
30
|
+
msg: "HTML files found"
|
|
31
|
+
}));
|
|
32
|
+
files.forEach((file) => {
|
|
33
|
+
const filePath = node_path.default.resolve(process.cwd(), file);
|
|
34
|
+
const contents = node_fs.default.readFileSync(filePath).toString();
|
|
35
|
+
let newContents = contents;
|
|
36
|
+
for (const varMatcher of varMatchers) {
|
|
37
|
+
const matches = contents.match(varMatcher);
|
|
38
|
+
if (matches) {
|
|
39
|
+
const matchedVar = (0, _prosopo_util.at)(matches, 1);
|
|
40
|
+
logger.info(() => ({
|
|
41
|
+
data: { matchedVar },
|
|
42
|
+
msg: "matchedVar"
|
|
43
|
+
}));
|
|
44
|
+
newContents = contents.replaceAll(matchedVar, varValue);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (newContents !== contents) node_fs.default.writeFileSync(node_path.default.resolve(__dirname$1, filePath), newContents);
|
|
49
|
+
});
|
|
47
50
|
}
|
|
48
51
|
async function updateEnvFiles(varNames, varValue, logger, cwd) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Object.keys(envConfig).map((k) => `${k}=${envConfig[k]}`).join("\n")
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
52
|
+
const files = await findEnvFiles(logger, cwd);
|
|
53
|
+
logger.info(() => ({
|
|
54
|
+
data: { files },
|
|
55
|
+
msg: "Env files found"
|
|
56
|
+
}));
|
|
57
|
+
files.forEach((file) => {
|
|
58
|
+
let write = false;
|
|
59
|
+
const filePath = node_path.default.resolve(cwd || process.cwd(), file);
|
|
60
|
+
const envConfig = dotenv.default.parse(node_fs.default.readFileSync(filePath));
|
|
61
|
+
for (const varName of varNames) if (varName in envConfig) {
|
|
62
|
+
envConfig[varName] = varValue;
|
|
63
|
+
write = true;
|
|
64
|
+
}
|
|
65
|
+
if (write) node_fs.default.writeFileSync(node_path.default.resolve(__dirname$1, filePath), Object.keys(envConfig).map((k) => `${k}=${envConfig[k]}`).join("\n"));
|
|
66
|
+
});
|
|
68
67
|
}
|
|
68
|
+
//#endregion
|
|
69
69
|
exports.findEnvFiles = findEnvFiles;
|
|
70
70
|
exports.updateDemoHTMLFiles = updateDemoHTMLFiles;
|
|
71
71
|
exports.updateEnvFiles = updateEnvFiles;
|
package/dist/cli/index.js
CHANGED
|
@@ -1,89 +1,78 @@
|
|
|
1
|
+
import { exec } from "../util/exec.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { setup } from "../setup/setup.js";
|
|
4
|
+
import "../setup/index.js";
|
|
5
|
+
import { getScriptsPkgDir } from "../workspace/dist/projectInfo.js";
|
|
6
|
+
import setVersion from "../scripts/setVersion.js";
|
|
1
7
|
import path from "node:path";
|
|
2
|
-
import {
|
|
3
|
-
import { loadEnv, getEnv } from "@prosopo/dotenv";
|
|
8
|
+
import { getEnv, loadEnv } from "@prosopo/dotenv";
|
|
4
9
|
import { LogLevel, getLogger, parseLogLevel } from "@prosopo/logger";
|
|
5
|
-
import {
|
|
6
|
-
import "
|
|
10
|
+
import { decodeProcaptchaOutput, encodeProcaptchaOutput } from "@prosopo/types";
|
|
11
|
+
import { isHex } from "@polkadot/util";
|
|
7
12
|
import yargs from "yargs";
|
|
8
13
|
import { hideBin } from "yargs/helpers";
|
|
9
|
-
|
|
10
|
-
import "../setup/index.js";
|
|
11
|
-
import "../util/index.js";
|
|
12
|
-
import { getScriptsPkgDir } from "../workspace/dist/projectInfo.js";
|
|
13
|
-
import { exec } from "../util/exec.js";
|
|
14
|
-
import { setup } from "../setup/setup.js";
|
|
15
|
-
const rootDir = path.resolve(".");
|
|
16
|
-
loadEnv(rootDir);
|
|
14
|
+
loadEnv(path.resolve("."));
|
|
17
15
|
async function processArgs(args) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} else {
|
|
73
|
-
log.debug(() => ({ msg: "Decoding token from hex" }));
|
|
74
|
-
log.info(() => ({
|
|
75
|
-
data: { result: decodeProcaptchaOutput(argv.token) }
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}).argv;
|
|
16
|
+
const log = getLogger(parseLogLevel((await yargs(hideBin(args)).option("logLevel", {
|
|
17
|
+
describe: "set log level",
|
|
18
|
+
choices: Object.keys(LogLevel.enum)
|
|
19
|
+
}).argv).logLevel), "CLI");
|
|
20
|
+
await yargs(hideBin(args)).usage("Usage: $0 [global options] <command> [options]").command("create_env_files", "Copies the env.xyz files to .env.xyz", (yargs) => yargs, async () => {
|
|
21
|
+
const env = getEnv();
|
|
22
|
+
const scripts = getScriptsPkgDir();
|
|
23
|
+
await exec(`cp -v ${scripts}/env.${env} ${scripts}/.env.${env}`);
|
|
24
|
+
}, []).command({
|
|
25
|
+
command: "setup",
|
|
26
|
+
describe: "Setup the development environment by registering a provider, staking, loading a data set and then registering a dapp and staking.",
|
|
27
|
+
builder: (yargs) => yargs.option("sites", {
|
|
28
|
+
type: "boolean",
|
|
29
|
+
demandOption: false,
|
|
30
|
+
default: true,
|
|
31
|
+
desc: "Set up sites"
|
|
32
|
+
}).option("provider", {
|
|
33
|
+
type: "boolean",
|
|
34
|
+
demandOption: false,
|
|
35
|
+
default: true,
|
|
36
|
+
desc: "Set up the provider"
|
|
37
|
+
}),
|
|
38
|
+
handler: async (argv) => {
|
|
39
|
+
log.info(() => ({ msg: "Running setup scripts" }));
|
|
40
|
+
await setup(argv.provider, argv.sites);
|
|
41
|
+
}
|
|
42
|
+
}).command({
|
|
43
|
+
command: "version",
|
|
44
|
+
describe: "Set the version of packages",
|
|
45
|
+
builder: (yargs) => yargs.option("v", {
|
|
46
|
+
type: "string",
|
|
47
|
+
demandOption: true
|
|
48
|
+
}),
|
|
49
|
+
handler: async (argv) => {
|
|
50
|
+
await setVersion(String(argv.v));
|
|
51
|
+
}
|
|
52
|
+
}).command({
|
|
53
|
+
command: "token <token>",
|
|
54
|
+
describe: "Encode or Decode a Procaptcha token to the JSON output format",
|
|
55
|
+
builder: (yargs) => yargs.positional("token", {
|
|
56
|
+
describe: "a Procaptcha token to decode",
|
|
57
|
+
type: "string",
|
|
58
|
+
demandOption: true
|
|
59
|
+
}),
|
|
60
|
+
handler: async (argv) => {
|
|
61
|
+
if (!isHex(argv.token)) {
|
|
62
|
+
log.debug(() => ({ msg: "Encoding token to hex" }));
|
|
63
|
+
log.info(() => ({ data: { result: encodeProcaptchaOutput(JSON.parse(argv.token)) } }));
|
|
64
|
+
} else {
|
|
65
|
+
log.debug(() => ({ msg: "Decoding token from hex" }));
|
|
66
|
+
log.info(() => ({ data: { result: decodeProcaptchaOutput(argv.token) } }));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}).argv;
|
|
80
70
|
}
|
|
81
71
|
processArgs(process.argv).then(() => {
|
|
82
|
-
|
|
72
|
+
process.exit(0);
|
|
83
73
|
}).catch((error) => {
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
console.error(error);
|
|
75
|
+
process.exit(1);
|
|
86
76
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { processArgs };
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./util/index.js";
|
|
3
|
-
import { processArgs } from "./cli/index.js";
|
|
4
|
-
import { setup, updateEnvFile } from "./setup/setup.js";
|
|
5
|
-
import { setupProvider } from "./setup/provider.js";
|
|
1
|
+
import "./_virtual/_rolldown/runtime.js";
|
|
6
2
|
import { findEnvFiles, updateDemoHTMLFiles, updateEnvFiles } from "./util/updateEnv.js";
|
|
7
3
|
import { exec } from "./util/exec.js";
|
|
8
4
|
import { extractReferrersFromLogs } from "./util/fluxLogDappDetails.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
setupProvider,
|
|
16
|
-
updateDemoHTMLFiles,
|
|
17
|
-
updateEnvFile,
|
|
18
|
-
updateEnvFiles
|
|
19
|
-
};
|
|
5
|
+
import "./util/index.js";
|
|
6
|
+
import { setupProvider } from "./setup/provider.js";
|
|
7
|
+
import { setup, updateEnvFile } from "./setup/setup.js";
|
|
8
|
+
import "./setup/index.js";
|
|
9
|
+
import { processArgs } from "./cli/index.js";
|
|
10
|
+
export { exec, extractReferrersFromLogs, findEnvFiles, processArgs, setup, setupProvider, updateDemoHTMLFiles, updateEnvFile, updateEnvFiles };
|