nestia 12.0.0-rc.3 → 12.0.0
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/NestiaProjectTemplate.d.ts +29 -0
- package/bin/NestiaProjectTemplate.js +104 -0
- package/bin/NestiaProjectTemplate.js.map +1 -0
- package/bin/NestiaStarter.d.ts +2 -1
- package/bin/NestiaStarter.js +5 -41
- package/bin/NestiaStarter.js.map +1 -1
- package/bin/NestiaTemplate.d.ts +2 -1
- package/bin/NestiaTemplate.js +5 -38
- package/bin/NestiaTemplate.js.map +1 -1
- package/bin/index.d.ts +1 -1
- package/bin/index.js +2 -2
- package/package.json +3 -3
- package/src/NestiaProjectTemplate.ts +137 -0
- package/src/NestiaStarter.ts +6 -38
- package/src/NestiaTemplate.ts +6 -34
- package/src/index.ts +2 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare namespace NestiaProjectTemplate {
|
|
2
|
+
/**
|
|
3
|
+
* Side effects performed while scaffolding a template project.
|
|
4
|
+
*
|
|
5
|
+
* Injected so that the scaffolding flow can be unit tested without touching
|
|
6
|
+
* the network, the file system, or a real package manager.
|
|
7
|
+
*/
|
|
8
|
+
interface IContext {
|
|
9
|
+
/** Runs a command, inheriting stdio. Throws on non-zero exit. */
|
|
10
|
+
execute: (command: string) => void;
|
|
11
|
+
/** Silently checks whether a command succeeds. */
|
|
12
|
+
probe: (command: string) => boolean;
|
|
13
|
+
/** Changes the working directory. */
|
|
14
|
+
chdir: (directory: string) => void;
|
|
15
|
+
/** Checks whether a path exists. */
|
|
16
|
+
exists: (path: string) => boolean;
|
|
17
|
+
/** Removes a path recursively, ignoring missing entries. */
|
|
18
|
+
remove: (path: string) => void;
|
|
19
|
+
}
|
|
20
|
+
interface IProps {
|
|
21
|
+
/** Banner title printed before cloning. */
|
|
22
|
+
title: string;
|
|
23
|
+
/** Default repository URL, overridable through `--repository <url>`. */
|
|
24
|
+
repository: string;
|
|
25
|
+
/** Whether to run the test suite after building. */
|
|
26
|
+
test: boolean;
|
|
27
|
+
}
|
|
28
|
+
const clone: (props: IProps) => (halter: (msg?: string) => never, context?: IContext) => (argv: string[]) => Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.NestiaProjectTemplate = void 0;
|
|
16
|
+
const child_process_1 = __importDefault(require("child_process"));
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
var NestiaProjectTemplate;
|
|
19
|
+
(function (NestiaProjectTemplate) {
|
|
20
|
+
NestiaProjectTemplate.clone = (props) => (halter, context = CONTEXT) => (argv) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
// VALIDATION
|
|
22
|
+
const { dest, repository } = parse(argv, halter);
|
|
23
|
+
if (dest === undefined)
|
|
24
|
+
halter();
|
|
25
|
+
else if (context.exists(dest) === true)
|
|
26
|
+
halter("The target directory already exists.");
|
|
27
|
+
console.log("-----------------------------------------");
|
|
28
|
+
console.log(` ${props.title}`);
|
|
29
|
+
console.log("-----------------------------------------");
|
|
30
|
+
// COPY PROJECTS
|
|
31
|
+
context.execute(`git clone "${repository !== null && repository !== void 0 ? repository : props.repository}" "${dest}"`);
|
|
32
|
+
console.log(`cd "${dest}"`);
|
|
33
|
+
context.chdir(dest);
|
|
34
|
+
// TEMPLATE REPOSITORIES ARE PNPM MONOREPOS.
|
|
35
|
+
//
|
|
36
|
+
// Their workspace manifests use the `catalog:` dependency protocol,
|
|
37
|
+
// which npm cannot resolve. Only pnpm (directly installed, or served
|
|
38
|
+
// through corepack) can set them up.
|
|
39
|
+
const pm = getPackageManager(halter, context);
|
|
40
|
+
// INSTALL DEPENDENCIES
|
|
41
|
+
context.execute(`${pm} install`);
|
|
42
|
+
// BUILD TYPESCRIPT
|
|
43
|
+
context.execute(`${pm} run build`);
|
|
44
|
+
// DO TEST
|
|
45
|
+
if (props.test === true)
|
|
46
|
+
context.execute(`${pm} run test`);
|
|
47
|
+
// REMOVE REPOSITORY ONLY FILES
|
|
48
|
+
context.remove(".git");
|
|
49
|
+
context.remove(".github/dependabot.yml");
|
|
50
|
+
});
|
|
51
|
+
function parse(argv, halter) {
|
|
52
|
+
const output = {};
|
|
53
|
+
for (let i = 0; i < argv.length; ++i) {
|
|
54
|
+
const value = argv[i];
|
|
55
|
+
if (value === "--repository") {
|
|
56
|
+
const url = argv[i + 1];
|
|
57
|
+
if (url === undefined)
|
|
58
|
+
halter("The --repository option requires a URL value.");
|
|
59
|
+
output.repository = url;
|
|
60
|
+
++i;
|
|
61
|
+
}
|
|
62
|
+
else if (value.startsWith("--") === false && output.dest === undefined)
|
|
63
|
+
output.dest = value;
|
|
64
|
+
}
|
|
65
|
+
return output;
|
|
66
|
+
}
|
|
67
|
+
function getPackageManager(halter, context) {
|
|
68
|
+
if (context.probe("pnpm --version") === true)
|
|
69
|
+
return "pnpm";
|
|
70
|
+
else if (context.probe("corepack --version") === true) {
|
|
71
|
+
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT = "0";
|
|
72
|
+
return "corepack pnpm";
|
|
73
|
+
}
|
|
74
|
+
return halter([
|
|
75
|
+
"The template project is a pnpm monorepo, but neither pnpm nor",
|
|
76
|
+
"corepack could be found. Install pnpm and try again:",
|
|
77
|
+
"",
|
|
78
|
+
" npm install --global pnpm",
|
|
79
|
+
"",
|
|
80
|
+
"or activate it through corepack (bundled with Node.js):",
|
|
81
|
+
"",
|
|
82
|
+
" corepack enable",
|
|
83
|
+
].join("\n"));
|
|
84
|
+
}
|
|
85
|
+
const CONTEXT = {
|
|
86
|
+
execute: (command) => {
|
|
87
|
+
console.log(`\n$ ${command}`);
|
|
88
|
+
child_process_1.default.execSync(command, { stdio: "inherit" });
|
|
89
|
+
},
|
|
90
|
+
probe: (command) => {
|
|
91
|
+
try {
|
|
92
|
+
child_process_1.default.execSync(command, { stdio: "ignore" });
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch (_a) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
chdir: (directory) => process.chdir(directory),
|
|
100
|
+
exists: (path) => fs_1.default.existsSync(path),
|
|
101
|
+
remove: (path) => fs_1.default.rmSync(path, { recursive: true, force: true }),
|
|
102
|
+
};
|
|
103
|
+
})(NestiaProjectTemplate || (exports.NestiaProjectTemplate = NestiaProjectTemplate = {}));
|
|
104
|
+
//# sourceMappingURL=NestiaProjectTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NestiaProjectTemplate.js","sourceRoot":"","sources":["../src/NestiaProjectTemplate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAA+B;AAC/B,4CAAoB;AAEpB,IAAiB,qBAAqB,CAqIrC;AArID,WAAiB,qBAAqB;IA6BvB,2BAAK,GAChB,CAAC,KAAa,EAAE,EAAE,CAClB,CAAC,MAA+B,EAAE,OAAO,GAAa,OAAO,EAAE,EAAE,CACjE,CAAO,IAAc,EAAiB,EAAE;QACtC,aAAa;QACb,MAAM,EAAE,IAAI,EA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AAO,OAAO,EAAE,CAAC,CAAC;YAC9B,uBAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,KAAK,EAAE,CAAC,OAAe,EAAW,EAAE;YAClC,IAAI,CAAC;gBACH,uBAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAC1C,OAAO,IAAI,CAAC;YACd,CAAC;uBAAO,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,KAAK,EAAE,CAAC,SAAiB,EAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QAC5D,MAAM,EAAE,CAAC,IAAY,EAAW,EAAE,CAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QACtD,MAAM,EAAE,CAAC,IAAY,EAAQ,EAAE,CAC7B,YAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC,EArIgB,qBAAqB,aAArB,qBAAqB,GAArB,qBAAqB,QAqIrC"}
|
package/bin/NestiaStarter.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NestiaProjectTemplate } from "./NestiaProjectTemplate.js";
|
|
1
2
|
export declare namespace NestiaStarter {
|
|
2
|
-
const clone: (halter: (msg?: string) => never) => (argv: string[]) => Promise<void>;
|
|
3
|
+
const clone: (halter: (msg?: string) => never, context?: NestiaProjectTemplate.IContext) => (argv: string[]) => Promise<void>;
|
|
3
4
|
}
|
package/bin/NestiaStarter.js
CHANGED
|
@@ -1,49 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.NestiaStarter = void 0;
|
|
16
|
-
const
|
|
17
|
-
const fs_1 = __importDefault(require("fs"));
|
|
4
|
+
const NestiaProjectTemplate_js_1 = require("./NestiaProjectTemplate.js");
|
|
18
5
|
var NestiaStarter;
|
|
19
6
|
(function (NestiaStarter) {
|
|
20
|
-
NestiaStarter.clone = (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
halter();
|
|
25
|
-
else if (fs_1.default.existsSync(dest) === true)
|
|
26
|
-
halter("The target directory already exists.");
|
|
27
|
-
console.log("-----------------------------------------");
|
|
28
|
-
console.log(" Nestia Starter Kit");
|
|
29
|
-
console.log("-----------------------------------------");
|
|
30
|
-
// COPY PROJECTS
|
|
31
|
-
execute(`git clone https://github.com/samchon/nestia-template ${dest}`);
|
|
32
|
-
console.log(`cd "${dest}"`);
|
|
33
|
-
process.chdir(dest);
|
|
34
|
-
// INSTALL DEPENDENCIES
|
|
35
|
-
execute("npm install");
|
|
36
|
-
// BUILD TYPESCRIPT
|
|
37
|
-
execute("npm run build");
|
|
38
|
-
// DO TEST
|
|
39
|
-
execute("npm run test");
|
|
40
|
-
// REMOVE .GIT DIRECTORY
|
|
41
|
-
child_process_1.default.execSync("npx rimraf .git");
|
|
42
|
-
child_process_1.default.execSync("npx rimraf .github/dependabot.yml");
|
|
7
|
+
NestiaStarter.clone = NestiaProjectTemplate_js_1.NestiaProjectTemplate.clone({
|
|
8
|
+
title: "Nestia Starter Kit",
|
|
9
|
+
repository: "https://github.com/samchon/nestia-start",
|
|
10
|
+
test: true,
|
|
43
11
|
});
|
|
44
|
-
function execute(command) {
|
|
45
|
-
console.log(`\n$ ${command}`);
|
|
46
|
-
child_process_1.default.execSync(command, { stdio: "inherit" });
|
|
47
|
-
}
|
|
48
12
|
})(NestiaStarter || (exports.NestiaStarter = NestiaStarter = {}));
|
|
49
13
|
//# sourceMappingURL=NestiaStarter.js.map
|
package/bin/NestiaStarter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaStarter.js","sourceRoot":"","sources":["../src/NestiaStarter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NestiaStarter.js","sourceRoot":"","sources":["../src/NestiaStarter.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AAEnE,IAAiB,aAAa,CAM7B;AAND,WAAiB,aAAa;IACf,mBAAK,GAAG,gDAAqB,CAAC,KAAK,CAAC;QAC/C,KAAK,EAAE,oBAAoB;QAC3B,UAAU,EAAE,yCAAyC;QACrD,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC,EANgB,aAAa,aAAb,aAAa,GAAb,aAAa,QAM7B"}
|
package/bin/NestiaTemplate.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NestiaProjectTemplate } from "./NestiaProjectTemplate.js";
|
|
1
2
|
export declare namespace NestiaTemplate {
|
|
2
|
-
const clone: (halter: (msg?: string) => never) => (argv: string[]) => Promise<void>;
|
|
3
|
+
const clone: (halter: (msg?: string) => never, context?: NestiaProjectTemplate.IContext) => (argv: string[]) => Promise<void>;
|
|
3
4
|
}
|
package/bin/NestiaTemplate.js
CHANGED
|
@@ -1,46 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.NestiaTemplate = void 0;
|
|
16
|
-
const
|
|
17
|
-
const fs_1 = __importDefault(require("fs"));
|
|
4
|
+
const NestiaProjectTemplate_js_1 = require("./NestiaProjectTemplate.js");
|
|
18
5
|
var NestiaTemplate;
|
|
19
6
|
(function (NestiaTemplate) {
|
|
20
|
-
NestiaTemplate.clone = (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
halter();
|
|
25
|
-
else if (fs_1.default.existsSync(dest) === true)
|
|
26
|
-
halter("The target directory already exists.");
|
|
27
|
-
console.log("-----------------------------------------");
|
|
28
|
-
console.log(" Nestia Template Kit");
|
|
29
|
-
console.log("-----------------------------------------");
|
|
30
|
-
// COPY PROJECTS
|
|
31
|
-
execute(`git clone https://github.com/samchon/backend ${dest}`);
|
|
32
|
-
console.log(`cd "${dest}"`);
|
|
33
|
-
process.chdir(dest);
|
|
34
|
-
// INSTALL DEPENDENCIES
|
|
35
|
-
execute("npm install");
|
|
36
|
-
// BUILD TYPESCRIPT
|
|
37
|
-
execute("npm run build");
|
|
38
|
-
// REMOVE .GIT DIRECTORY
|
|
39
|
-
child_process_1.default.execSync("npx rimraf .git");
|
|
7
|
+
NestiaTemplate.clone = NestiaProjectTemplate_js_1.NestiaProjectTemplate.clone({
|
|
8
|
+
title: "Nestia Template Kit",
|
|
9
|
+
repository: "https://github.com/samchon/backend",
|
|
10
|
+
test: false,
|
|
40
11
|
});
|
|
41
|
-
function execute(command) {
|
|
42
|
-
console.log(`\n$ ${command}`);
|
|
43
|
-
child_process_1.default.execSync(command, { stdio: "inherit" });
|
|
44
|
-
}
|
|
45
12
|
})(NestiaTemplate || (exports.NestiaTemplate = NestiaTemplate = {}));
|
|
46
13
|
//# sourceMappingURL=NestiaTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaTemplate.js","sourceRoot":"","sources":["../src/NestiaTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NestiaTemplate.js","sourceRoot":"","sources":["../src/NestiaTemplate.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AAEnE,IAAiB,cAAc,CAM9B;AAND,WAAiB,cAAc;IAChB,oBAAK,GAAG,gDAAqB,CAAC,KAAK,CAAC;QAC/C,KAAK,EAAE,qBAAqB;QAC5B,UAAU,EAAE,oCAAoC;QAChD,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;AACL,CAAC,EANgB,cAAc,aAAd,cAAc,GAAd,cAAc,QAM9B"}
|
package/bin/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
declare const USAGE = "Wrong command has been detected. Use like below:\n\nnpx nestia [command] [options?]\n\n 1. npx nestia start <directory
|
|
2
|
+
declare const USAGE = "Wrong command has been detected. Use like below:\n\nnpx nestia [command] [options?]\n\n 1. npx nestia start <directory> [--repository <url>]\n 2. npx nestia template <directory> [--repository <url>]\n 3. npx nestia dependencies\n 4. npx nestia init\n 5. npx nestia sdk\n 6. npx nestia swagger [--watch]\n 7. npx nestia e2e\n 8. npx nestia all\n";
|
|
3
3
|
declare function halt(desc: string): never;
|
|
4
4
|
declare function main(): Promise<void>;
|
package/bin/index.js
CHANGED
|
@@ -46,8 +46,8 @@ const USAGE = `Wrong command has been detected. Use like below:
|
|
|
46
46
|
|
|
47
47
|
npx nestia [command] [options?]
|
|
48
48
|
|
|
49
|
-
1. npx nestia start <directory>
|
|
50
|
-
2. npx nestia template <directory>
|
|
49
|
+
1. npx nestia start <directory> [--repository <url>]
|
|
50
|
+
2. npx nestia template <directory> [--repository <url>]
|
|
51
51
|
3. npx nestia dependencies
|
|
52
52
|
4. npx nestia init
|
|
53
53
|
5. npx nestia sdk
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestia",
|
|
3
|
-
"version": "12.0.0
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Nestia CLI tool",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^25.3.3",
|
|
37
37
|
"rimraf": "^6.1.3",
|
|
38
|
-
"@nestia/core": "^12.0.0
|
|
39
|
-
"@nestia/sdk": "^12.0.0
|
|
38
|
+
"@nestia/core": "^12.0.0",
|
|
39
|
+
"@nestia/sdk": "^12.0.0"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
42
|
"bin",
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import cp from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
export namespace NestiaProjectTemplate {
|
|
5
|
+
/**
|
|
6
|
+
* Side effects performed while scaffolding a template project.
|
|
7
|
+
*
|
|
8
|
+
* Injected so that the scaffolding flow can be unit tested without touching
|
|
9
|
+
* the network, the file system, or a real package manager.
|
|
10
|
+
*/
|
|
11
|
+
export interface IContext {
|
|
12
|
+
/** Runs a command, inheriting stdio. Throws on non-zero exit. */
|
|
13
|
+
execute: (command: string) => void;
|
|
14
|
+
/** Silently checks whether a command succeeds. */
|
|
15
|
+
probe: (command: string) => boolean;
|
|
16
|
+
/** Changes the working directory. */
|
|
17
|
+
chdir: (directory: string) => void;
|
|
18
|
+
/** Checks whether a path exists. */
|
|
19
|
+
exists: (path: string) => boolean;
|
|
20
|
+
/** Removes a path recursively, ignoring missing entries. */
|
|
21
|
+
remove: (path: string) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IProps {
|
|
25
|
+
/** Banner title printed before cloning. */
|
|
26
|
+
title: string;
|
|
27
|
+
/** Default repository URL, overridable through `--repository <url>`. */
|
|
28
|
+
repository: string;
|
|
29
|
+
/** Whether to run the test suite after building. */
|
|
30
|
+
test: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const clone =
|
|
34
|
+
(props: IProps) =>
|
|
35
|
+
(halter: (msg?: string) => never, context: IContext = CONTEXT) =>
|
|
36
|
+
async (argv: string[]): Promise<void> => {
|
|
37
|
+
// VALIDATION
|
|
38
|
+
const { dest, repository } = parse(argv, halter);
|
|
39
|
+
if (dest === undefined) halter();
|
|
40
|
+
else if (context.exists(dest) === true)
|
|
41
|
+
halter("The target directory already exists.");
|
|
42
|
+
|
|
43
|
+
console.log("-----------------------------------------");
|
|
44
|
+
console.log(` ${props.title}`);
|
|
45
|
+
console.log("-----------------------------------------");
|
|
46
|
+
|
|
47
|
+
// COPY PROJECTS
|
|
48
|
+
context.execute(
|
|
49
|
+
`git clone "${repository ?? props.repository}" "${dest}"`,
|
|
50
|
+
);
|
|
51
|
+
console.log(`cd "${dest}"`);
|
|
52
|
+
context.chdir(dest);
|
|
53
|
+
|
|
54
|
+
// TEMPLATE REPOSITORIES ARE PNPM MONOREPOS.
|
|
55
|
+
//
|
|
56
|
+
// Their workspace manifests use the `catalog:` dependency protocol,
|
|
57
|
+
// which npm cannot resolve. Only pnpm (directly installed, or served
|
|
58
|
+
// through corepack) can set them up.
|
|
59
|
+
const pm: string = getPackageManager(halter, context);
|
|
60
|
+
|
|
61
|
+
// INSTALL DEPENDENCIES
|
|
62
|
+
context.execute(`${pm} install`);
|
|
63
|
+
|
|
64
|
+
// BUILD TYPESCRIPT
|
|
65
|
+
context.execute(`${pm} run build`);
|
|
66
|
+
|
|
67
|
+
// DO TEST
|
|
68
|
+
if (props.test === true) context.execute(`${pm} run test`);
|
|
69
|
+
|
|
70
|
+
// REMOVE REPOSITORY ONLY FILES
|
|
71
|
+
context.remove(".git");
|
|
72
|
+
context.remove(".github/dependabot.yml");
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
interface IArguments {
|
|
76
|
+
dest?: string;
|
|
77
|
+
repository?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function parse(argv: string[], halter: (msg?: string) => never): IArguments {
|
|
81
|
+
const output: IArguments = {};
|
|
82
|
+
for (let i: number = 0; i < argv.length; ++i) {
|
|
83
|
+
const value: string = argv[i]!;
|
|
84
|
+
if (value === "--repository") {
|
|
85
|
+
const url: string | undefined = argv[i + 1];
|
|
86
|
+
if (url === undefined)
|
|
87
|
+
halter("The --repository option requires a URL value.");
|
|
88
|
+
output.repository = url;
|
|
89
|
+
++i;
|
|
90
|
+
} else if (value.startsWith("--") === false && output.dest === undefined)
|
|
91
|
+
output.dest = value;
|
|
92
|
+
}
|
|
93
|
+
return output;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getPackageManager(
|
|
97
|
+
halter: (msg?: string) => never,
|
|
98
|
+
context: IContext,
|
|
99
|
+
): string {
|
|
100
|
+
if (context.probe("pnpm --version") === true) return "pnpm";
|
|
101
|
+
else if (context.probe("corepack --version") === true) {
|
|
102
|
+
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT = "0";
|
|
103
|
+
return "corepack pnpm";
|
|
104
|
+
}
|
|
105
|
+
return halter(
|
|
106
|
+
[
|
|
107
|
+
"The template project is a pnpm monorepo, but neither pnpm nor",
|
|
108
|
+
"corepack could be found. Install pnpm and try again:",
|
|
109
|
+
"",
|
|
110
|
+
" npm install --global pnpm",
|
|
111
|
+
"",
|
|
112
|
+
"or activate it through corepack (bundled with Node.js):",
|
|
113
|
+
"",
|
|
114
|
+
" corepack enable",
|
|
115
|
+
].join("\n"),
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const CONTEXT: IContext = {
|
|
120
|
+
execute: (command: string): void => {
|
|
121
|
+
console.log(`\n$ ${command}`);
|
|
122
|
+
cp.execSync(command, { stdio: "inherit" });
|
|
123
|
+
},
|
|
124
|
+
probe: (command: string): boolean => {
|
|
125
|
+
try {
|
|
126
|
+
cp.execSync(command, { stdio: "ignore" });
|
|
127
|
+
return true;
|
|
128
|
+
} catch {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
chdir: (directory: string): void => process.chdir(directory),
|
|
133
|
+
exists: (path: string): boolean => fs.existsSync(path),
|
|
134
|
+
remove: (path: string): void =>
|
|
135
|
+
fs.rmSync(path, { recursive: true, force: true }),
|
|
136
|
+
};
|
|
137
|
+
}
|
package/src/NestiaStarter.ts
CHANGED
|
@@ -1,41 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from "fs";
|
|
1
|
+
import { NestiaProjectTemplate } from "./NestiaProjectTemplate.js";
|
|
3
2
|
|
|
4
3
|
export namespace NestiaStarter {
|
|
5
|
-
export const clone =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (dest === undefined) halter();
|
|
11
|
-
else if (fs.existsSync(dest) === true)
|
|
12
|
-
halter("The target directory already exists.");
|
|
13
|
-
|
|
14
|
-
console.log("-----------------------------------------");
|
|
15
|
-
console.log(" Nestia Starter Kit");
|
|
16
|
-
console.log("-----------------------------------------");
|
|
17
|
-
|
|
18
|
-
// COPY PROJECTS
|
|
19
|
-
execute(`git clone https://github.com/samchon/nestia-template ${dest}`);
|
|
20
|
-
console.log(`cd "${dest}"`);
|
|
21
|
-
process.chdir(dest);
|
|
22
|
-
|
|
23
|
-
// INSTALL DEPENDENCIES
|
|
24
|
-
execute("npm install");
|
|
25
|
-
|
|
26
|
-
// BUILD TYPESCRIPT
|
|
27
|
-
execute("npm run build");
|
|
28
|
-
|
|
29
|
-
// DO TEST
|
|
30
|
-
execute("npm run test");
|
|
31
|
-
|
|
32
|
-
// REMOVE .GIT DIRECTORY
|
|
33
|
-
cp.execSync("npx rimraf .git");
|
|
34
|
-
cp.execSync("npx rimraf .github/dependabot.yml");
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
function execute(command: string): void {
|
|
38
|
-
console.log(`\n$ ${command}`);
|
|
39
|
-
cp.execSync(command, { stdio: "inherit" });
|
|
40
|
-
}
|
|
4
|
+
export const clone = NestiaProjectTemplate.clone({
|
|
5
|
+
title: "Nestia Starter Kit",
|
|
6
|
+
repository: "https://github.com/samchon/nestia-start",
|
|
7
|
+
test: true,
|
|
8
|
+
});
|
|
41
9
|
}
|
package/src/NestiaTemplate.ts
CHANGED
|
@@ -1,37 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from "fs";
|
|
1
|
+
import { NestiaProjectTemplate } from "./NestiaProjectTemplate.js";
|
|
3
2
|
|
|
4
3
|
export namespace NestiaTemplate {
|
|
5
|
-
export const clone =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (dest === undefined) halter();
|
|
11
|
-
else if (fs.existsSync(dest) === true)
|
|
12
|
-
halter("The target directory already exists.");
|
|
13
|
-
|
|
14
|
-
console.log("-----------------------------------------");
|
|
15
|
-
console.log(" Nestia Template Kit");
|
|
16
|
-
console.log("-----------------------------------------");
|
|
17
|
-
|
|
18
|
-
// COPY PROJECTS
|
|
19
|
-
execute(`git clone https://github.com/samchon/backend ${dest}`);
|
|
20
|
-
console.log(`cd "${dest}"`);
|
|
21
|
-
process.chdir(dest);
|
|
22
|
-
|
|
23
|
-
// INSTALL DEPENDENCIES
|
|
24
|
-
execute("npm install");
|
|
25
|
-
|
|
26
|
-
// BUILD TYPESCRIPT
|
|
27
|
-
execute("npm run build");
|
|
28
|
-
|
|
29
|
-
// REMOVE .GIT DIRECTORY
|
|
30
|
-
cp.execSync("npx rimraf .git");
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function execute(command: string): void {
|
|
34
|
-
console.log(`\n$ ${command}`);
|
|
35
|
-
cp.execSync(command, { stdio: "inherit" });
|
|
36
|
-
}
|
|
4
|
+
export const clone = NestiaProjectTemplate.clone({
|
|
5
|
+
title: "Nestia Template Kit",
|
|
6
|
+
repository: "https://github.com/samchon/backend",
|
|
7
|
+
test: false,
|
|
8
|
+
});
|
|
37
9
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,8 @@ const USAGE = `Wrong command has been detected. Use like below:
|
|
|
3
3
|
|
|
4
4
|
npx nestia [command] [options?]
|
|
5
5
|
|
|
6
|
-
1. npx nestia start <directory>
|
|
7
|
-
2. npx nestia template <directory>
|
|
6
|
+
1. npx nestia start <directory> [--repository <url>]
|
|
7
|
+
2. npx nestia template <directory> [--repository <url>]
|
|
8
8
|
3. npx nestia dependencies
|
|
9
9
|
4. npx nestia init
|
|
10
10
|
5. npx nestia sdk
|