@devbro/pashmak 0.1.7 → 0.1.9
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/dist/{DatabaseServiceProvider.js → DatabaseServiceProvider.mjs} +5 -9
- package/dist/DatabaseServiceProvider.mjs.map +1 -0
- package/dist/app/console/{DefaultCommand.js → DefaultCommand.mjs} +2 -2
- package/dist/app/console/DefaultCommand.mjs.map +1 -0
- package/dist/app/console/{KeyGenerateCommand.js → KeyGenerateCommand.mjs} +6 -6
- package/dist/app/console/KeyGenerateCommand.mjs.map +1 -0
- package/dist/app/console/{StartCommand.js → StartCommand.mjs} +2 -2
- package/dist/app/console/StartCommand.mjs.map +1 -0
- package/dist/app/console/generate/{GenerateControllerCommand.js → GenerateControllerCommand.mjs} +3 -2
- package/dist/app/console/generate/GenerateControllerCommand.mjs.map +1 -0
- package/dist/app/console/generate/controller.tpl +14 -3
- package/dist/app/console/generate/{index.d.ts → index.d.mts} +1 -1
- package/dist/app/console/generate/{index.js → index.mjs} +1 -1
- package/dist/app/console/index.d.mts +9 -0
- package/dist/app/console/{index.js → index.mjs} +2 -2
- package/dist/app/console/index.mjs.map +1 -0
- package/dist/app/console/migrate/{MakeMigrateCommand.d.ts → GenerateMigrateCommand.d.mts} +2 -2
- package/dist/app/console/migrate/{MakeMigrateCommand.js → GenerateMigrateCommand.mjs} +8 -8
- package/dist/app/console/migrate/GenerateMigrateCommand.mjs.map +1 -0
- package/dist/app/console/migrate/{MigrateCommand.js → MigrateCommand.mjs} +2 -2
- package/dist/app/console/migrate/MigrateCommand.mjs.map +1 -0
- package/dist/app/console/migrate/{MigrateRollbackCommand.js → MigrateRollbackCommand.mjs} +2 -2
- package/dist/app/console/migrate/MigrateRollbackCommand.mjs.map +1 -0
- package/dist/app/console/migrate/index.d.mts +4 -0
- package/dist/app/console/migrate/{index.js → index.mjs} +2 -2
- package/dist/app/console/migrate/index.mjs.map +1 -0
- package/dist/app/console/project/{CreateProjectCommand.js → CreateProjectCommand.mjs} +2 -2
- package/dist/app/console/project/CreateProjectCommand.mjs.map +1 -0
- package/dist/app/console/project/base_project/package.json.tpl +1 -1
- package/dist/bin/DatabaseServiceProvider.cjs +88 -0
- package/dist/bin/app/console/DefaultCommand.cjs +506 -0
- package/dist/bin/app/console/KeyGenerateCommand.cjs +554 -0
- package/dist/bin/app/console/StartCommand.cjs +520 -0
- package/dist/bin/app/console/generate/GenerateControllerCommand.cjs +532 -0
- package/dist/bin/app/console/generate/index.cjs +532 -0
- package/dist/bin/app/console/index.cjs +2167 -0
- package/dist/bin/app/console/migrate/GenerateMigrateCommand.cjs +529 -0
- package/dist/bin/app/console/migrate/MigrateCommand.cjs +565 -0
- package/dist/bin/app/console/migrate/MigrateRollbackCommand.cjs +1684 -0
- package/dist/bin/app/console/migrate/index.cjs +1829 -0
- package/dist/bin/app/console/project/CreateProjectCommand.cjs +155 -0
- package/dist/bin/{pashmak_cli.cjs → bin/pashmak_cli.cjs} +4 -4
- package/dist/bin/config.cjs +24 -0
- package/dist/bin/context.cjs +24 -0
- package/dist/bin/facades.cjs +491 -0
- package/dist/bin/helper.cjs +24 -0
- package/dist/bin/http.cjs +24 -0
- package/dist/bin/index.cjs +2452 -0
- package/dist/bin/logger.cjs +24 -0
- package/dist/bin/mailer.cjs +24 -0
- package/dist/bin/middlewares.cjs +512 -0
- package/dist/bin/orm.cjs +24 -0
- package/dist/bin/{pashmak_cli.js → pashmak_cli.mjs} +1 -1
- package/dist/bin/router.cjs +547 -0
- package/dist/bin/sql.cjs +24 -0
- package/dist/{config.js → config.mjs} +1 -1
- package/dist/config.mjs.map +1 -0
- package/dist/{context.js → context.mjs} +1 -1
- package/dist/context.mjs.map +1 -0
- package/dist/{facades.js → facades.mjs} +30 -57
- package/dist/facades.mjs.map +1 -0
- package/dist/{helper.js → helper.mjs} +1 -1
- package/dist/helper.mjs.map +1 -0
- package/dist/{http.js → http.mjs} +1 -1
- package/dist/http.mjs.map +1 -0
- package/dist/{index.js → index.mjs} +2 -2
- package/dist/index.mjs.map +1 -0
- package/dist/{logger.js → logger.mjs} +1 -1
- package/dist/logger.mjs.map +1 -0
- package/dist/{mailer.js → mailer.mjs} +1 -1
- package/dist/mailer.mjs.map +1 -0
- package/dist/{middlewares.js → middlewares.mjs} +3 -5
- package/dist/middlewares.mjs.map +1 -0
- package/dist/{orm.js → orm.mjs} +1 -1
- package/dist/orm.mjs.map +1 -0
- package/dist/{router.d.ts → router.d.mts} +1 -1
- package/dist/{router.js → router.mjs} +2 -4
- package/dist/router.mjs.map +1 -0
- package/dist/{sql.js → sql.mjs} +1 -1
- package/dist/sql.mjs.map +1 -0
- package/package.json +14 -15
- package/dist/DatabaseServiceProvider.js.map +0 -1
- package/dist/app/console/DefaultCommand.js.map +0 -1
- package/dist/app/console/KeyGenerateCommand.js.map +0 -1
- package/dist/app/console/StartCommand.js.map +0 -1
- package/dist/app/console/generate/GenerateControllerCommand.js.map +0 -1
- package/dist/app/console/index.d.ts +0 -9
- package/dist/app/console/index.js.map +0 -1
- package/dist/app/console/migrate/MakeMigrateCommand.js.map +0 -1
- package/dist/app/console/migrate/MigrateCommand.js.map +0 -1
- package/dist/app/console/migrate/MigrateRollbackCommand.js.map +0 -1
- package/dist/app/console/migrate/index.d.ts +0 -4
- package/dist/app/console/migrate/index.js.map +0 -1
- package/dist/app/console/project/CreateProjectCommand.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/facades.js.map +0 -1
- package/dist/helper.js.map +0 -1
- package/dist/http.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/mailer.js.map +0 -1
- package/dist/middlewares.js.map +0 -1
- package/dist/orm.js.map +0 -1
- package/dist/router.js.map +0 -1
- package/dist/sql.js.map +0 -1
- /package/dist/{DatabaseServiceProvider.d.ts → DatabaseServiceProvider.d.mts} +0 -0
- /package/dist/app/console/{DefaultCommand.d.ts → DefaultCommand.d.mts} +0 -0
- /package/dist/app/console/{KeyGenerateCommand.d.ts → KeyGenerateCommand.d.mts} +0 -0
- /package/dist/app/console/{StartCommand.d.ts → StartCommand.d.mts} +0 -0
- /package/dist/app/console/generate/{GenerateControllerCommand.d.ts → GenerateControllerCommand.d.mts} +0 -0
- /package/dist/app/console/generate/{index.js.map → index.mjs.map} +0 -0
- /package/dist/app/console/migrate/{MigrateCommand.d.ts → MigrateCommand.d.mts} +0 -0
- /package/dist/app/console/migrate/{MigrateRollbackCommand.d.ts → MigrateRollbackCommand.d.mts} +0 -0
- /package/dist/app/console/project/{CreateProjectCommand.d.ts → CreateProjectCommand.d.mts} +0 -0
- /package/dist/bin/{pashmak_cli.d.ts → pashmak_cli.d.mts} +0 -0
- /package/dist/bin/{pashmak_cli.js.map → pashmak_cli.mjs.map} +0 -0
- /package/dist/{config.d.ts → config.d.mts} +0 -0
- /package/dist/{context.d.ts → context.d.mts} +0 -0
- /package/dist/{facades.d.ts → facades.d.mts} +0 -0
- /package/dist/{helper.d.ts → helper.d.mts} +0 -0
- /package/dist/{http.d.ts → http.d.mts} +0 -0
- /package/dist/{index.d.ts → index.d.mts} +0 -0
- /package/dist/{logger.d.ts → logger.d.mts} +0 -0
- /package/dist/{mailer.d.ts → mailer.d.mts} +0 -0
- /package/dist/{middlewares.d.ts → middlewares.d.mts} +0 -0
- /package/dist/{orm.d.ts → orm.d.mts} +0 -0
- /package/dist/{sql.d.ts → sql.d.mts} +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/app/console/project/CreateProjectCommand.ts
|
|
32
|
+
var CreateProjectCommand_exports = {};
|
|
33
|
+
__export(CreateProjectCommand_exports, {
|
|
34
|
+
CreateProjectCommand: () => CreateProjectCommand
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(CreateProjectCommand_exports);
|
|
37
|
+
var import_clipanion = require("clipanion");
|
|
38
|
+
var import_change_case_all = require("change-case-all");
|
|
39
|
+
var import_path = __toESM(require("path"));
|
|
40
|
+
var fs = __toESM(require("fs/promises"));
|
|
41
|
+
var import_url = require("url");
|
|
42
|
+
var import_handlebars = __toESM(require("handlebars"));
|
|
43
|
+
var import_child_process = require("child_process");
|
|
44
|
+
var import_meta = {};
|
|
45
|
+
var CreateProjectCommand = class extends import_clipanion.Command {
|
|
46
|
+
static {
|
|
47
|
+
__name(this, "CreateProjectCommand");
|
|
48
|
+
}
|
|
49
|
+
static paths = [
|
|
50
|
+
[
|
|
51
|
+
`create`,
|
|
52
|
+
`project`
|
|
53
|
+
]
|
|
54
|
+
];
|
|
55
|
+
static usage = import_clipanion.Command.Usage({
|
|
56
|
+
category: `Project`,
|
|
57
|
+
description: `Create a new project`,
|
|
58
|
+
details: `
|
|
59
|
+
This command creates a new project with the specified name at the given path.
|
|
60
|
+
If no path is provided, the project will be created in the current directory.
|
|
61
|
+
`,
|
|
62
|
+
examples: [
|
|
63
|
+
[
|
|
64
|
+
`Create a new project in specified directory`,
|
|
65
|
+
`create project --path /path/to/my-project --git`
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
`Create a new project at a specific path with git initialized`,
|
|
69
|
+
`create project --path /path/to/my-project --git`
|
|
70
|
+
]
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
projectPath = import_clipanion.Option.String("--path", {
|
|
74
|
+
required: true
|
|
75
|
+
});
|
|
76
|
+
git = import_clipanion.Option.Boolean(`--git`, false, {
|
|
77
|
+
description: `Initialize a git repository in the new project`
|
|
78
|
+
});
|
|
79
|
+
async folderExists(folderPath) {
|
|
80
|
+
try {
|
|
81
|
+
const stats = await fs.stat(folderPath);
|
|
82
|
+
return stats.isDirectory();
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (error.code === "ENOENT") {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async execute() {
|
|
91
|
+
const projectPath = import_path.default.join(this.projectPath);
|
|
92
|
+
try {
|
|
93
|
+
await fs.access(projectPath);
|
|
94
|
+
console.error(`Error: Directory ${projectPath} already exists.`);
|
|
95
|
+
return 1;
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
await fs.mkdir(projectPath, {
|
|
99
|
+
recursive: true
|
|
100
|
+
});
|
|
101
|
+
console.log(`Created project directory at: ${projectPath}`);
|
|
102
|
+
const dirname = typeof __dirname === "undefined" ? import_path.default.dirname((0, import_url.fileURLToPath)(import_meta.url)) : __dirname;
|
|
103
|
+
let basePath = import_path.default.join(dirname, `./base_project`);
|
|
104
|
+
if (await this.folderExists(basePath) === false) {
|
|
105
|
+
basePath = import_path.default.join(dirname, `../app/console/project/base_project`);
|
|
106
|
+
}
|
|
107
|
+
console.log(`Using base project path: ${basePath}`);
|
|
108
|
+
const baseProjectPath = basePath;
|
|
109
|
+
await this.processTplFolder(baseProjectPath, projectPath, {});
|
|
110
|
+
console.log(`Copied base project files to: ${projectPath}`);
|
|
111
|
+
const packageJsonPath = import_path.default.join(projectPath, `package.json`);
|
|
112
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, `utf-8`));
|
|
113
|
+
packageJson.name = import_change_case_all.Case.snake(import_path.default.basename(projectPath));
|
|
114
|
+
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
115
|
+
console.log(`Updated package.json with project name: ${packageJson.name}`);
|
|
116
|
+
if (this.git) {
|
|
117
|
+
try {
|
|
118
|
+
(0, import_child_process.execSync)('git init; git add --all; git commit --allow-empty -m "chore: first commit for pashmak"', {
|
|
119
|
+
cwd: projectPath
|
|
120
|
+
});
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error(`Failed to create project.`, error);
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async processTplFolder(src, dest, data = {}) {
|
|
128
|
+
const files = await fs.readdir(src, {
|
|
129
|
+
withFileTypes: true
|
|
130
|
+
});
|
|
131
|
+
for (const file of files) {
|
|
132
|
+
const srcPath = import_path.default.join(src, file.name);
|
|
133
|
+
const destPath = file.isFile() && file.name.endsWith(".tpl") ? import_path.default.join(dest, file.name.substring(0, file.name.length - 4)) : import_path.default.join(dest, file.name);
|
|
134
|
+
if (file.isDirectory()) {
|
|
135
|
+
await fs.mkdir(destPath, {
|
|
136
|
+
recursive: true
|
|
137
|
+
});
|
|
138
|
+
await this.processTplFolder(srcPath, destPath, data);
|
|
139
|
+
} else if (file.name.endsWith(".tpl")) {
|
|
140
|
+
await this.processTplFile(srcPath, destPath, {});
|
|
141
|
+
} else {
|
|
142
|
+
throw new Error("unexpected non tpl file: " + srcPath + " " + file.name);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async processTplFile(src, dest, data = {}) {
|
|
147
|
+
const compiledTemplate = import_handlebars.default.compile((await fs.readFile(src)).toString());
|
|
148
|
+
const template = await compiledTemplate(data);
|
|
149
|
+
await fs.writeFile(dest, template);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {
|
|
154
|
+
CreateProjectCommand
|
|
155
|
+
});
|
|
@@ -30,10 +30,10 @@ var import_clipanion2 = require("clipanion");
|
|
|
30
30
|
// src/app/console/project/CreateProjectCommand.ts
|
|
31
31
|
var import_clipanion = require("clipanion");
|
|
32
32
|
var import_change_case_all = require("change-case-all");
|
|
33
|
-
var import_path = __toESM(require("path")
|
|
34
|
-
var fs = __toESM(require("fs/promises")
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
34
|
+
var fs = __toESM(require("fs/promises"));
|
|
35
35
|
var import_url = require("url");
|
|
36
|
-
var import_handlebars = __toESM(require("handlebars")
|
|
36
|
+
var import_handlebars = __toESM(require("handlebars"));
|
|
37
37
|
var import_child_process = require("child_process");
|
|
38
38
|
var import_meta = {};
|
|
39
39
|
var CreateProjectCommand = class extends import_clipanion.Command {
|
|
@@ -93,7 +93,7 @@ var CreateProjectCommand = class extends import_clipanion.Command {
|
|
|
93
93
|
recursive: true
|
|
94
94
|
});
|
|
95
95
|
console.log(`Created project directory at: ${projectPath}`);
|
|
96
|
-
|
|
96
|
+
const dirname = typeof __dirname === "undefined" ? import_path.default.dirname((0, import_url.fileURLToPath)(import_meta.url)) : __dirname;
|
|
97
97
|
let basePath = import_path.default.join(dirname, `./base_project`);
|
|
98
98
|
if (await this.folderExists(basePath) === false) {
|
|
99
99
|
basePath = import_path.default.join(dirname, `../app/console/project/base_project`);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/config.mts
|
|
18
|
+
var config_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(config_exports);
|
|
20
|
+
__reExport(config_exports, require("@devbro/neko-config"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@devbro/neko-config")
|
|
24
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/context.mts
|
|
18
|
+
var context_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(context_exports);
|
|
20
|
+
__reExport(context_exports, require("@devbro/neko-context"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@devbro/neko-context")
|
|
24
|
+
});
|