@avleon/cli 0.0.1 → 0.0.3
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/package.json +10 -10
- package/readme.md +1 -0
- package/src/av-cli.ts +95 -0
- package/src/cli.interface.ts +55 -0
- package/src/cli.ts +241 -0
- package/src/commands.ts +56 -0
- package/src/controller.ts +106 -0
- package/src/create.ts +117 -0
- package/src/index.ts +1 -0
- package/src/paths.ts +29 -0
- package/src/stubs/basic-controller.stub +7 -0
- package/src/stubs/model.stub +0 -0
- package/dist/av-cli.js +0 -93
- package/dist/cli.interface.js +0 -2
- package/dist/cli.js +0 -239
- package/dist/commands.js +0 -54
- package/dist/controller.js +0 -118
- package/dist/create.js +0 -131
- package/dist/index.js +0 -17
- package/dist/paths.js +0 -22
package/dist/create.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.createApplication = createApplication;
|
|
40
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
41
|
-
const paths_1 = require("./paths");
|
|
42
|
-
const prettier = __importStar(require("prettier"));
|
|
43
|
-
const win32_1 = __importDefault(require("path/win32"));
|
|
44
|
-
const child_process_1 = require("child_process");
|
|
45
|
-
async function createApplication(fname) {
|
|
46
|
-
const appPaths = (0, paths_1.appPaths)(fname);
|
|
47
|
-
const dirs = Object.values(appPaths);
|
|
48
|
-
for (let i = 0; i < dirs.length; i++) {
|
|
49
|
-
await fs_extra_1.default.ensureDir(dirs[i]);
|
|
50
|
-
}
|
|
51
|
-
await fs_extra_1.default.ensureDir(appPaths.root + "/public");
|
|
52
|
-
// copy
|
|
53
|
-
//
|
|
54
|
-
const mainFunc = `
|
|
55
|
-
import 'reflect-metadata';
|
|
56
|
-
import { AppBuilder } from '@avleon/core';
|
|
57
|
-
|
|
58
|
-
async function main() {
|
|
59
|
-
const builder = AppBuilder.createBuilder();
|
|
60
|
-
// builder.useLogger();
|
|
61
|
-
builder.useDatabase();
|
|
62
|
-
|
|
63
|
-
const app = await builder.build();
|
|
64
|
-
await app.mapControllers();
|
|
65
|
-
await app.run();
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
main().catch(err=> console.log(err));
|
|
69
|
-
`;
|
|
70
|
-
const formatMainFunc = await prettier.format(mainFunc, {
|
|
71
|
-
singleQuote: true,
|
|
72
|
-
singleAttributePerLine: true,
|
|
73
|
-
parser: "typescript",
|
|
74
|
-
});
|
|
75
|
-
await fs_extra_1.default.writeFile(win32_1.default.join(appPaths.src, 'app.ts'), formatMainFunc);
|
|
76
|
-
// create package.json
|
|
77
|
-
const packageJson = `
|
|
78
|
-
{
|
|
79
|
-
"name": "${fname}",
|
|
80
|
-
"version": "1.0.0",
|
|
81
|
-
"description": "",
|
|
82
|
-
"main": "index.js",
|
|
83
|
-
"scripts": {
|
|
84
|
-
"test": "echo \\"Error: no test specified\\" && exit 1",
|
|
85
|
-
"dev": "nodemon src/app.ts",
|
|
86
|
-
"start": "node dist/app.js",
|
|
87
|
-
"build": "rimraf dist && tsc"
|
|
88
|
-
},
|
|
89
|
-
"keywords": [],
|
|
90
|
-
"author": "",
|
|
91
|
-
"license": "ISC",
|
|
92
|
-
"dependencies": {
|
|
93
|
-
"class-transformer": "^0.5.1",
|
|
94
|
-
"class-validator": "^0.14.1",
|
|
95
|
-
"reflect-metadata": "^0.2.2"
|
|
96
|
-
},
|
|
97
|
-
"devDependencies": {
|
|
98
|
-
"nodemon": "^3.1.7",
|
|
99
|
-
"ts-node": "^10.9.2",
|
|
100
|
-
"typescript": "^5.7.2"
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
`;
|
|
105
|
-
const formattedPackageJson = await prettier.format(packageJson, {
|
|
106
|
-
parser: "json",
|
|
107
|
-
});
|
|
108
|
-
await fs_extra_1.default.writeFile(win32_1.default.join(appPaths.root, 'package.json'), formattedPackageJson);
|
|
109
|
-
const tsconfigJson = await prettier.format(`{
|
|
110
|
-
"compilerOptions": {
|
|
111
|
-
"target": "ES2017",
|
|
112
|
-
"module": "CommonJS",
|
|
113
|
-
"moduleResolution": "node",
|
|
114
|
-
"outDir": "./dist",
|
|
115
|
-
"rootDir": "./src",
|
|
116
|
-
"esModuleInterop": true,
|
|
117
|
-
"allowSyntheticDefaultImports": true,
|
|
118
|
-
"forceConsistentCasingInFileNames": true,
|
|
119
|
-
"skipLibCheck": true
|
|
120
|
-
},
|
|
121
|
-
"include": ["src/**/*"],
|
|
122
|
-
"exclude": ["node_modules", "dist"]
|
|
123
|
-
}`, { parser: 'json' });
|
|
124
|
-
await fs_extra_1.default.writeFile(win32_1.default.join(appPaths.root, 'tsconfig.json'), tsconfigJson);
|
|
125
|
-
await fs_extra_1.default.writeFile(win32_1.default.join(appPaths.root, '.gitignore'), `node_modules/\ndist/\n.env`);
|
|
126
|
-
// create basic service
|
|
127
|
-
// create basic controller
|
|
128
|
-
console.info("Running pnpm install");
|
|
129
|
-
(0, child_process_1.execSync)(`cd ${fname}&& pnpm install && pnpm link @avleon/core && pnpm link @avleon/data`, { stdio: 'inherit' });
|
|
130
|
-
console.info("App create successfully.");
|
|
131
|
-
}
|
package/dist/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./cli"), exports);
|
package/dist/paths.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.appPaths = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const appPaths = (rootPath) => {
|
|
9
|
-
const root = rootPath ? rootPath : node_path_1.default.join(process.cwd(), "./");
|
|
10
|
-
return {
|
|
11
|
-
root: root,
|
|
12
|
-
src: node_path_1.default.join(root, "src"),
|
|
13
|
-
test: node_path_1.default.join(root, "test"),
|
|
14
|
-
controllers: node_path_1.default.join(root, "src/controllers"),
|
|
15
|
-
models: node_path_1.default.join(root, "src/models"),
|
|
16
|
-
services: node_path_1.default.join(root, "src/services"),
|
|
17
|
-
requests: node_path_1.default.join(root, "src/requests"),
|
|
18
|
-
responses: node_path_1.default.join(root, "src/responses"),
|
|
19
|
-
configs: node_path_1.default.join(root, "src/configs")
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.appPaths = appPaths;
|