@nestia/migrate 8.0.5-dev.20250904-2 → 8.0.6

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.
@@ -1,125 +1,125 @@
1
- const { version } = require("../../../../package.json");
2
- const cp = require("child_process");
3
- const fs = require("fs");
4
-
5
- const ROOT = `${__dirname}/../..`;
6
- const ASSETS = `${ROOT}/assets`;
7
-
8
- const update = (content) => {
9
- const parsed = JSON.parse(content);
10
- for (const record of [
11
- parsed.dependencies ?? {},
12
- parsed.devDependencies ?? {},
13
- ])
14
- for (const key of Object.keys(record))
15
- if (key.startsWith("@nestia/") || key === "nestia")
16
- record[key] = `^${version}`;
17
- return JSON.stringify(parsed, null, 2);
18
- };
19
-
20
- const bundle = async ({ mode, repository, exceptions, transform }) => {
21
- const root = `${__dirname}/../..`;
22
- const assets = `${root}/assets`;
23
- const template = `${assets}/${mode}`;
24
-
25
- const clone = async () => {
26
- // CLONE REPOSITORY
27
- if (fs.existsSync(template))
28
- await fs.promises.rm(template, { recursive: true });
29
- else
30
- try {
31
- await fs.promises.mkdir(ASSETS);
32
- } catch {}
33
-
34
- cp.execSync(`git clone https://github.com/samchon/${repository} ${mode}`, {
35
- cwd: ASSETS,
36
- });
37
-
38
- // REMOVE VULNERABLE FILES
39
- for (const location of exceptions ?? [])
40
- await fs.promises.rm(`${template}/${location}`, { recursive: true });
41
- };
42
-
43
- const iterate = (collection) => async (location) => {
44
- const directory = await fs.promises.readdir(location);
45
- for (const file of directory) {
46
- const absolute = location + "/" + file;
47
- const stats = await fs.promises.stat(absolute);
48
- if (stats.isDirectory()) await iterate(collection)(absolute);
49
- else {
50
- const content = await fs.promises.readFile(absolute, "utf-8");
51
- collection[
52
- (() => {
53
- const str = absolute.replace(template, "");
54
- return str[0] === "/" ? str.substring(1) : str;
55
- })()
56
- ] = content;
57
- }
58
- }
59
- };
60
-
61
- const archive = async (collection) => {
62
- const name = `${mode.toUpperCase()}_TEMPLATE`;
63
- const body = JSON.stringify(collection, null, 2);
64
- const content = `export const ${name}: Record<string, string> = ${body}`;
65
-
66
- try {
67
- await fs.promises.mkdir(`${ROOT}/src/bundles`);
68
- } catch {}
69
- await fs.promises.writeFile(
70
- `${ROOT}/src/bundles/${name}.ts`,
71
- content,
72
- "utf8",
73
- );
74
- };
75
-
76
- const collection = {};
77
- await clone();
78
- await iterate(collection)(template);
79
- if (transform)
80
- for (const [key, value] of Object.entries(collection))
81
- collection[key] = transform(key, value);
82
- await archive(collection);
83
- };
84
-
85
- const main = async () => {
86
- await bundle({
87
- mode: "nest",
88
- repository: "nestia-start",
89
- exceptions: [
90
- ".git",
91
- ".github/dependabot.yml",
92
- ".github/workflows/dependabot-automerge.yml",
93
- "src/api/functional",
94
- "src/controllers",
95
- "src/MyModule.ts",
96
- "src/providers",
97
- "test/features",
98
- ],
99
- transform: (key, value) => {
100
- if (key === "package.json") return update(value);
101
- return value;
102
- },
103
- });
104
- await bundle({
105
- mode: "sdk",
106
- repository: "nestia-sdk-template",
107
- exceptions: [
108
- ".git",
109
- ".github/dependabot.yml",
110
- ".github/workflows/build.yml",
111
- ".github/workflows/dependabot-automerge.yml",
112
- "src/functional",
113
- "src/structures",
114
- "test/features",
115
- ],
116
- transform: (key, value) => {
117
- if (key === "package.json") return update(value);
118
- return value;
119
- },
120
- });
121
- };
122
- main().catch((exp) => {
123
- console.error(exp);
124
- process.exit(-1);
125
- });
1
+ const { version } = require("../../../../package.json");
2
+ const cp = require("child_process");
3
+ const fs = require("fs");
4
+
5
+ const ROOT = `${__dirname}/../..`;
6
+ const ASSETS = `${ROOT}/assets`;
7
+
8
+ const update = (content) => {
9
+ const parsed = JSON.parse(content);
10
+ for (const record of [
11
+ parsed.dependencies ?? {},
12
+ parsed.devDependencies ?? {},
13
+ ])
14
+ for (const key of Object.keys(record))
15
+ if (key.startsWith("@nestia/") || key === "nestia")
16
+ record[key] = `^${version}`;
17
+ return JSON.stringify(parsed, null, 2);
18
+ };
19
+
20
+ const bundle = async ({ mode, repository, exceptions, transform }) => {
21
+ const root = `${__dirname}/../..`;
22
+ const assets = `${root}/assets`;
23
+ const template = `${assets}/${mode}`;
24
+
25
+ const clone = async () => {
26
+ // CLONE REPOSITORY
27
+ if (fs.existsSync(template))
28
+ await fs.promises.rm(template, { recursive: true });
29
+ else
30
+ try {
31
+ await fs.promises.mkdir(ASSETS);
32
+ } catch {}
33
+
34
+ cp.execSync(`git clone https://github.com/samchon/${repository} ${mode}`, {
35
+ cwd: ASSETS,
36
+ });
37
+
38
+ // REMOVE VULNERABLE FILES
39
+ for (const location of exceptions ?? [])
40
+ await fs.promises.rm(`${template}/${location}`, { recursive: true });
41
+ };
42
+
43
+ const iterate = (collection) => async (location) => {
44
+ const directory = await fs.promises.readdir(location);
45
+ for (const file of directory) {
46
+ const absolute = location + "/" + file;
47
+ const stats = await fs.promises.stat(absolute);
48
+ if (stats.isDirectory()) await iterate(collection)(absolute);
49
+ else {
50
+ const content = await fs.promises.readFile(absolute, "utf-8");
51
+ collection[
52
+ (() => {
53
+ const str = absolute.replace(template, "");
54
+ return str[0] === "/" ? str.substring(1) : str;
55
+ })()
56
+ ] = content;
57
+ }
58
+ }
59
+ };
60
+
61
+ const archive = async (collection) => {
62
+ const name = `${mode.toUpperCase()}_TEMPLATE`;
63
+ const body = JSON.stringify(collection, null, 2);
64
+ const content = `export const ${name}: Record<string, string> = ${body}`;
65
+
66
+ try {
67
+ await fs.promises.mkdir(`${ROOT}/src/bundles`);
68
+ } catch {}
69
+ await fs.promises.writeFile(
70
+ `${ROOT}/src/bundles/${name}.ts`,
71
+ content,
72
+ "utf8",
73
+ );
74
+ };
75
+
76
+ const collection = {};
77
+ await clone();
78
+ await iterate(collection)(template);
79
+ if (transform)
80
+ for (const [key, value] of Object.entries(collection))
81
+ collection[key] = transform(key, value);
82
+ await archive(collection);
83
+ };
84
+
85
+ const main = async () => {
86
+ await bundle({
87
+ mode: "nest",
88
+ repository: "nestia-start",
89
+ exceptions: [
90
+ ".git",
91
+ ".github/dependabot.yml",
92
+ ".github/workflows/dependabot-automerge.yml",
93
+ "src/api/functional",
94
+ "src/controllers",
95
+ "src/MyModule.ts",
96
+ "src/providers",
97
+ "test/features",
98
+ ],
99
+ transform: (key, value) => {
100
+ if (key === "package.json") return update(value);
101
+ return value;
102
+ },
103
+ });
104
+ await bundle({
105
+ mode: "sdk",
106
+ repository: "nestia-sdk-template",
107
+ exceptions: [
108
+ ".git",
109
+ ".github/dependabot.yml",
110
+ ".github/workflows/build.yml",
111
+ ".github/workflows/dependabot-automerge.yml",
112
+ "src/functional",
113
+ "src/structures",
114
+ "test/features",
115
+ ],
116
+ transform: (key, value) => {
117
+ if (key === "package.json") return update(value);
118
+ return value;
119
+ },
120
+ });
121
+ };
122
+ main().catch((exp) => {
123
+ console.error(exp);
124
+ process.exit(-1);
125
+ });