@devbro/pashmak 0.1.9 → 0.1.10
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/app/console/DefaultCommand.mjs +3 -1
- package/dist/app/console/DefaultCommand.mjs.map +1 -1
- package/dist/app/console/KeyGenerateCommand.mjs +19 -17
- package/dist/app/console/KeyGenerateCommand.mjs.map +1 -1
- package/dist/app/console/StartCommand.mjs +9 -13
- package/dist/app/console/StartCommand.mjs.map +1 -1
- package/dist/app/console/generate/GenerateControllerCommand.mjs +14 -17
- package/dist/app/console/generate/GenerateControllerCommand.mjs.map +1 -1
- package/dist/app/console/generate/index.mjs +1 -1
- package/dist/app/console/generate/index.mjs.map +1 -1
- package/dist/app/console/index.mjs +7 -7
- package/dist/app/console/index.mjs.map +1 -1
- package/dist/app/console/migrate/GenerateMigrateCommand.mjs +14 -17
- package/dist/app/console/migrate/GenerateMigrateCommand.mjs.map +1 -1
- package/dist/app/console/migrate/MigrateCommand.mjs +5 -10
- package/dist/app/console/migrate/MigrateCommand.mjs.map +1 -1
- package/dist/app/console/migrate/MigrateRollbackCommand.mjs +2 -9
- package/dist/app/console/migrate/MigrateRollbackCommand.mjs.map +1 -1
- package/dist/app/console/migrate/index.mjs +3 -3
- package/dist/app/console/migrate/index.mjs.map +1 -1
- package/dist/app/console/project/CreateProjectCommand.mjs +17 -23
- package/dist/app/console/project/CreateProjectCommand.mjs.map +1 -1
- package/dist/bin/app/console/DefaultCommand.cjs +5 -3
- package/dist/bin/app/console/KeyGenerateCommand.cjs +23 -21
- package/dist/bin/app/console/StartCommand.cjs +11 -15
- package/dist/bin/app/console/generate/GenerateControllerCommand.cjs +20 -23
- package/dist/bin/app/console/generate/index.cjs +20 -23
- package/dist/bin/app/console/index.cjs +110 -134
- package/dist/bin/app/console/migrate/GenerateMigrateCommand.cjs +19 -22
- package/dist/bin/app/console/migrate/MigrateCommand.cjs +9 -14
- package/dist/bin/app/console/migrate/MigrateRollbackCommand.cjs +7 -14
- package/dist/bin/app/console/migrate/index.cjs +33 -48
- package/dist/bin/app/console/project/CreateProjectCommand.cjs +21 -27
- package/dist/bin/bin/pashmak_cli.cjs +21 -27
- package/dist/bin/index.cjs +123 -150
- package/dist/bin/pashmak_cli.mjs +2 -2
- package/dist/bin/pashmak_cli.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +2 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bin/index.cjs
CHANGED
|
@@ -582,26 +582,22 @@ var init_facades = __esm({
|
|
|
582
582
|
}
|
|
583
583
|
});
|
|
584
584
|
|
|
585
|
-
// src/app/console/migrate/MigrateCommand.
|
|
585
|
+
// src/app/console/migrate/MigrateCommand.mts
|
|
586
586
|
var import_clipanion2, import_neko_context3, import_path2, import_promises, import_neko_config2, MigrateCommand;
|
|
587
587
|
var init_MigrateCommand = __esm({
|
|
588
|
-
"src/app/console/migrate/MigrateCommand.
|
|
588
|
+
"src/app/console/migrate/MigrateCommand.mts"() {
|
|
589
589
|
"use strict";
|
|
590
590
|
init_facades();
|
|
591
591
|
import_clipanion2 = require("clipanion");
|
|
592
592
|
import_neko_context3 = require("@devbro/neko-context");
|
|
593
|
-
import_path2 = __toESM(require("path"));
|
|
594
|
-
import_promises = __toESM(require("fs/promises"));
|
|
593
|
+
import_path2 = __toESM(require("path"), 1);
|
|
594
|
+
import_promises = __toESM(require("fs/promises"), 1);
|
|
595
595
|
import_neko_config2 = require("@devbro/neko-config");
|
|
596
596
|
MigrateCommand = class extends import_clipanion2.Command {
|
|
597
597
|
static {
|
|
598
598
|
__name(this, "MigrateCommand");
|
|
599
599
|
}
|
|
600
|
-
static paths = [
|
|
601
|
-
[
|
|
602
|
-
`migrate`
|
|
603
|
-
]
|
|
604
|
-
];
|
|
600
|
+
static paths = [[`migrate`]];
|
|
605
601
|
fresh = import_clipanion2.Option.Boolean("--fresh", false);
|
|
606
602
|
async execute() {
|
|
607
603
|
await import_neko_context3.context_provider.run(async () => {
|
|
@@ -649,7 +645,9 @@ var init_MigrateCommand = __esm({
|
|
|
649
645
|
bindings: []
|
|
650
646
|
});
|
|
651
647
|
const completed_migrations = migrations.map((r) => r.filename);
|
|
652
|
-
const pending_migrations = files.filter(
|
|
648
|
+
const pending_migrations = files.filter(
|
|
649
|
+
(file) => !completed_migrations.includes(file)
|
|
650
|
+
);
|
|
653
651
|
let migrated_count = 0;
|
|
654
652
|
for (const class_to_migrate of pending_migrations) {
|
|
655
653
|
logger().info(`migrating up ${class_to_migrate}`);
|
|
@@ -658,10 +656,7 @@ var init_MigrateCommand = __esm({
|
|
|
658
656
|
await c.up(db2.getSchema());
|
|
659
657
|
await db2.runQuery({
|
|
660
658
|
sql: "insert into migrations (filename, batch) values ($1,$2)",
|
|
661
|
-
bindings: [
|
|
662
|
-
class_to_migrate,
|
|
663
|
-
batch_number
|
|
664
|
-
]
|
|
659
|
+
bindings: [class_to_migrate, batch_number]
|
|
665
660
|
});
|
|
666
661
|
migrated_count++;
|
|
667
662
|
}
|
|
@@ -677,18 +672,18 @@ var init_MigrateCommand = __esm({
|
|
|
677
672
|
}
|
|
678
673
|
});
|
|
679
674
|
|
|
680
|
-
// src/app/console/migrate/GenerateMigrateCommand.
|
|
675
|
+
// src/app/console/migrate/GenerateMigrateCommand.mts
|
|
681
676
|
var import_clipanion3, import_change_case_all, import_path3, fs2, import_neko_config3, import_handlebars, import_url, import_meta, GenerateMigrateCommand;
|
|
682
677
|
var init_GenerateMigrateCommand = __esm({
|
|
683
|
-
"src/app/console/migrate/GenerateMigrateCommand.
|
|
678
|
+
"src/app/console/migrate/GenerateMigrateCommand.mts"() {
|
|
684
679
|
"use strict";
|
|
685
680
|
init_facades();
|
|
686
681
|
import_clipanion3 = require("clipanion");
|
|
687
682
|
import_change_case_all = require("change-case-all");
|
|
688
|
-
import_path3 = __toESM(require("path"));
|
|
689
|
-
fs2 = __toESM(require("fs/promises"));
|
|
683
|
+
import_path3 = __toESM(require("path"), 1);
|
|
684
|
+
fs2 = __toESM(require("fs/promises"), 1);
|
|
690
685
|
import_neko_config3 = require("@devbro/neko-config");
|
|
691
|
-
import_handlebars = __toESM(require("handlebars"));
|
|
686
|
+
import_handlebars = __toESM(require("handlebars"), 1);
|
|
692
687
|
import_url = require("url");
|
|
693
688
|
import_meta = {};
|
|
694
689
|
GenerateMigrateCommand = class extends import_clipanion3.Command {
|
|
@@ -696,41 +691,38 @@ var init_GenerateMigrateCommand = __esm({
|
|
|
696
691
|
__name(this, "GenerateMigrateCommand");
|
|
697
692
|
}
|
|
698
693
|
static paths = [
|
|
699
|
-
[
|
|
700
|
-
|
|
701
|
-
`migrate`
|
|
702
|
-
],
|
|
703
|
-
[
|
|
704
|
-
"generate",
|
|
705
|
-
"migration"
|
|
706
|
-
]
|
|
694
|
+
[`generate`, `migrate`],
|
|
695
|
+
["generate", "migration"]
|
|
707
696
|
];
|
|
708
|
-
name = import_clipanion3.Option.String({
|
|
709
|
-
required: true
|
|
710
|
-
});
|
|
697
|
+
name = import_clipanion3.Option.String({ required: true });
|
|
711
698
|
async execute() {
|
|
712
699
|
const date = /* @__PURE__ */ new Date();
|
|
713
700
|
const year = date.getFullYear();
|
|
714
701
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
715
702
|
const day = String(date.getDate()).padStart(2, "0");
|
|
716
|
-
const secondsOfDay = String(
|
|
703
|
+
const secondsOfDay = String(
|
|
704
|
+
date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds()
|
|
705
|
+
).padStart(5, "0");
|
|
717
706
|
const fixed_name = import_change_case_all.Case.snake(this.name);
|
|
718
707
|
const filename = `${year}_${month}_${day}_${secondsOfDay}_${fixed_name}.ts`;
|
|
719
708
|
this.context.stdout.write(`creating migration file ${filename}
|
|
720
709
|
`);
|
|
721
|
-
await fs2.mkdir(import_neko_config3.config.get("migration.path"), {
|
|
722
|
-
recursive: true
|
|
723
|
-
});
|
|
710
|
+
await fs2.mkdir(import_neko_config3.config.get("migration.path"), { recursive: true });
|
|
724
711
|
let dirname = typeof __dirname === "string" ? __dirname : void 0;
|
|
725
712
|
if (!dirname) {
|
|
726
713
|
dirname = import_path3.default.dirname((0, import_url.fileURLToPath)(import_meta.url));
|
|
727
714
|
}
|
|
728
|
-
const compiledTemplate = import_handlebars.default.compile(
|
|
715
|
+
const compiledTemplate = import_handlebars.default.compile(
|
|
716
|
+
(await fs2.readFile(import_path3.default.join(dirname, "./make_migration.tpl"))).toString()
|
|
717
|
+
);
|
|
729
718
|
const template = await compiledTemplate({
|
|
730
719
|
className: import_change_case_all.Case.pascal(this.name) + "Migration",
|
|
731
720
|
tableName: import_change_case_all.Case.snake(this.name)
|
|
732
721
|
});
|
|
733
|
-
await fs2.writeFile(
|
|
722
|
+
await fs2.writeFile(
|
|
723
|
+
import_path3.default.join(import_neko_config3.config.get("migration.path"), filename),
|
|
724
|
+
template
|
|
725
|
+
);
|
|
734
726
|
}
|
|
735
727
|
};
|
|
736
728
|
cli().register(GenerateMigrateCommand);
|
|
@@ -1889,28 +1881,23 @@ var require_lib = __commonJS({
|
|
|
1889
1881
|
}
|
|
1890
1882
|
});
|
|
1891
1883
|
|
|
1892
|
-
// src/app/console/migrate/MigrateRollbackCommand.
|
|
1884
|
+
// src/app/console/migrate/MigrateRollbackCommand.mts
|
|
1893
1885
|
var import_clipanion4, import_neko_context4, import_path4, import_promises2, import_neko_config4, t, MigrateRollbackCommand;
|
|
1894
1886
|
var init_MigrateRollbackCommand = __esm({
|
|
1895
|
-
"src/app/console/migrate/MigrateRollbackCommand.
|
|
1887
|
+
"src/app/console/migrate/MigrateRollbackCommand.mts"() {
|
|
1896
1888
|
"use strict";
|
|
1897
1889
|
init_facades();
|
|
1898
1890
|
import_clipanion4 = require("clipanion");
|
|
1899
1891
|
import_neko_context4 = require("@devbro/neko-context");
|
|
1900
|
-
import_path4 = __toESM(require("path"));
|
|
1901
|
-
import_promises2 = __toESM(require("fs/promises"));
|
|
1892
|
+
import_path4 = __toESM(require("path"), 1);
|
|
1893
|
+
import_promises2 = __toESM(require("fs/promises"), 1);
|
|
1902
1894
|
import_neko_config4 = require("@devbro/neko-config");
|
|
1903
|
-
t = __toESM(require_lib());
|
|
1895
|
+
t = __toESM(require_lib(), 1);
|
|
1904
1896
|
MigrateRollbackCommand = class extends import_clipanion4.Command {
|
|
1905
1897
|
static {
|
|
1906
1898
|
__name(this, "MigrateRollbackCommand");
|
|
1907
1899
|
}
|
|
1908
|
-
static paths = [
|
|
1909
|
-
[
|
|
1910
|
-
`migrate`,
|
|
1911
|
-
"rollback"
|
|
1912
|
-
]
|
|
1913
|
-
];
|
|
1900
|
+
static paths = [[`migrate`, "rollback"]];
|
|
1914
1901
|
steps = import_clipanion4.Option.String(`--steps`, {
|
|
1915
1902
|
description: `how many migrations to rollback`,
|
|
1916
1903
|
validator: t.isNumber()
|
|
@@ -1936,9 +1923,7 @@ var init_MigrateRollbackCommand = __esm({
|
|
|
1936
1923
|
await c.down(db2.getSchema());
|
|
1937
1924
|
await db2.runQuery({
|
|
1938
1925
|
sql: "delete from migrations where id = $1",
|
|
1939
|
-
bindings: [
|
|
1940
|
-
migration.id
|
|
1941
|
-
]
|
|
1926
|
+
bindings: [migration.id]
|
|
1942
1927
|
});
|
|
1943
1928
|
}
|
|
1944
1929
|
});
|
|
@@ -1948,9 +1933,9 @@ var init_MigrateRollbackCommand = __esm({
|
|
|
1948
1933
|
}
|
|
1949
1934
|
});
|
|
1950
1935
|
|
|
1951
|
-
// src/app/console/migrate/index.
|
|
1936
|
+
// src/app/console/migrate/index.mts
|
|
1952
1937
|
var init_migrate = __esm({
|
|
1953
|
-
"src/app/console/migrate/index.
|
|
1938
|
+
"src/app/console/migrate/index.mts"() {
|
|
1954
1939
|
"use strict";
|
|
1955
1940
|
init_MigrateCommand();
|
|
1956
1941
|
init_GenerateMigrateCommand();
|
|
@@ -1958,10 +1943,10 @@ var init_migrate = __esm({
|
|
|
1958
1943
|
}
|
|
1959
1944
|
});
|
|
1960
1945
|
|
|
1961
|
-
// src/app/console/StartCommand.
|
|
1946
|
+
// src/app/console/StartCommand.mts
|
|
1962
1947
|
var import_clipanion5, import_neko_config5, import_neko_sql, StartCommand;
|
|
1963
1948
|
var init_StartCommand = __esm({
|
|
1964
|
-
"src/app/console/StartCommand.
|
|
1949
|
+
"src/app/console/StartCommand.mts"() {
|
|
1965
1950
|
"use strict";
|
|
1966
1951
|
import_clipanion5 = require("clipanion");
|
|
1967
1952
|
import_neko_config5 = require("@devbro/neko-config");
|
|
@@ -1974,19 +1959,13 @@ var init_StartCommand = __esm({
|
|
|
1974
1959
|
scheduler = import_clipanion5.Option.Boolean(`--scheduler`, false);
|
|
1975
1960
|
http = import_clipanion5.Option.Boolean(`--http`, false);
|
|
1976
1961
|
all = import_clipanion5.Option.Boolean("--all", false);
|
|
1977
|
-
static paths = [
|
|
1978
|
-
[
|
|
1979
|
-
`start`
|
|
1980
|
-
]
|
|
1981
|
-
];
|
|
1962
|
+
static paths = [[`start`]];
|
|
1982
1963
|
async execute() {
|
|
1983
|
-
if ([
|
|
1984
|
-
this.
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
this.context.stdout.write(`No service was selected. please check -h for details
|
|
1989
|
-
`);
|
|
1964
|
+
if ([this.all, this.http, this.scheduler].filter((x) => x).length == 0) {
|
|
1965
|
+
this.context.stdout.write(
|
|
1966
|
+
`No service was selected. please check -h for details
|
|
1967
|
+
`
|
|
1968
|
+
);
|
|
1990
1969
|
return;
|
|
1991
1970
|
}
|
|
1992
1971
|
logger().info(`Starting Server
|
|
@@ -2000,7 +1979,9 @@ var init_StartCommand = __esm({
|
|
|
2000
1979
|
if (this.http || this.all) {
|
|
2001
1980
|
const server = httpServer();
|
|
2002
1981
|
await server.listen(import_neko_config5.config.get("port"), () => {
|
|
2003
|
-
logger().info(
|
|
1982
|
+
logger().info(
|
|
1983
|
+
"Server is running on http://localhost:" + import_neko_config5.config.get("port")
|
|
1984
|
+
);
|
|
2004
1985
|
});
|
|
2005
1986
|
}
|
|
2006
1987
|
}
|
|
@@ -2009,10 +1990,10 @@ var init_StartCommand = __esm({
|
|
|
2009
1990
|
}
|
|
2010
1991
|
});
|
|
2011
1992
|
|
|
2012
|
-
// src/app/console/DefaultCommand.
|
|
1993
|
+
// src/app/console/DefaultCommand.mts
|
|
2013
1994
|
var import_clipanion6, DefaultCommand;
|
|
2014
1995
|
var init_DefaultCommand = __esm({
|
|
2015
|
-
"src/app/console/DefaultCommand.
|
|
1996
|
+
"src/app/console/DefaultCommand.mts"() {
|
|
2016
1997
|
"use strict";
|
|
2017
1998
|
import_clipanion6 = require("clipanion");
|
|
2018
1999
|
init_facades();
|
|
@@ -2033,7 +2014,9 @@ var init_DefaultCommand = __esm({
|
|
|
2033
2014
|
async execute() {
|
|
2034
2015
|
const commandList = cli().registrations;
|
|
2035
2016
|
const paths = [];
|
|
2036
|
-
commandList.forEach(
|
|
2017
|
+
commandList.forEach(
|
|
2018
|
+
(index, val) => paths.push(index.builder.paths[0]?.join(" ") || "")
|
|
2019
|
+
);
|
|
2037
2020
|
console.log("Available commands:");
|
|
2038
2021
|
for (const cmd of paths) {
|
|
2039
2022
|
if (cmd) {
|
|
@@ -2046,26 +2029,21 @@ var init_DefaultCommand = __esm({
|
|
|
2046
2029
|
}
|
|
2047
2030
|
});
|
|
2048
2031
|
|
|
2049
|
-
// src/app/console/KeyGenerateCommand.
|
|
2032
|
+
// src/app/console/KeyGenerateCommand.mts
|
|
2050
2033
|
var import_clipanion7, import_crypto, import_promises3, import_path5, KeyGenerateCommand;
|
|
2051
2034
|
var init_KeyGenerateCommand = __esm({
|
|
2052
|
-
"src/app/console/KeyGenerateCommand.
|
|
2035
|
+
"src/app/console/KeyGenerateCommand.mts"() {
|
|
2053
2036
|
"use strict";
|
|
2054
2037
|
import_clipanion7 = require("clipanion");
|
|
2055
2038
|
import_crypto = require("crypto");
|
|
2056
|
-
import_promises3 = __toESM(require("fs/promises"));
|
|
2057
|
-
import_path5 = __toESM(require("path"));
|
|
2039
|
+
import_promises3 = __toESM(require("fs/promises"), 1);
|
|
2040
|
+
import_path5 = __toESM(require("path"), 1);
|
|
2058
2041
|
init_facades();
|
|
2059
2042
|
KeyGenerateCommand = class extends import_clipanion7.Command {
|
|
2060
2043
|
static {
|
|
2061
2044
|
__name(this, "KeyGenerateCommand");
|
|
2062
2045
|
}
|
|
2063
|
-
static paths = [
|
|
2064
|
-
[
|
|
2065
|
-
`generate`,
|
|
2066
|
-
"key"
|
|
2067
|
-
]
|
|
2068
|
-
];
|
|
2046
|
+
static paths = [[`generate`, "key"]];
|
|
2069
2047
|
static usage = import_clipanion7.Command.Usage({
|
|
2070
2048
|
category: `Main`,
|
|
2071
2049
|
description: `generate keys`,
|
|
@@ -2074,14 +2052,8 @@ var init_KeyGenerateCommand = __esm({
|
|
|
2074
2052
|
Use --rotate flag to preserve old public key.
|
|
2075
2053
|
`,
|
|
2076
2054
|
examples: [
|
|
2077
|
-
[
|
|
2078
|
-
|
|
2079
|
-
`generate key`
|
|
2080
|
-
],
|
|
2081
|
-
[
|
|
2082
|
-
`Rotate existing keys`,
|
|
2083
|
-
`generate key --rotate`
|
|
2084
|
-
]
|
|
2055
|
+
[`Generate new keys`, `generate key`],
|
|
2056
|
+
[`Rotate existing keys`, `generate key --rotate`]
|
|
2085
2057
|
]
|
|
2086
2058
|
});
|
|
2087
2059
|
rotate = import_clipanion7.Option.Boolean(`--rotate`, false, {
|
|
@@ -2091,6 +2063,7 @@ var init_KeyGenerateCommand = __esm({
|
|
|
2091
2063
|
logger().info("generating keys for jwt token and adding to .env file");
|
|
2092
2064
|
const { publicKey, privateKey } = (0, import_crypto.generateKeyPairSync)("rsa", {
|
|
2093
2065
|
modulusLength: 2048,
|
|
2066
|
+
// 2048-bit key is standard for RS256
|
|
2094
2067
|
publicKeyEncoding: {
|
|
2095
2068
|
type: "spki",
|
|
2096
2069
|
format: "pem"
|
|
@@ -2106,10 +2079,22 @@ var init_KeyGenerateCommand = __esm({
|
|
|
2106
2079
|
} catch {
|
|
2107
2080
|
}
|
|
2108
2081
|
let old_public_key = envfile.match(/^jwt_secret_public=(.*)/m);
|
|
2109
|
-
envfile = this.addEnvParam(
|
|
2110
|
-
|
|
2082
|
+
envfile = this.addEnvParam(
|
|
2083
|
+
envfile,
|
|
2084
|
+
"jwt_secret_public",
|
|
2085
|
+
this.stripPemHeaders(publicKey)
|
|
2086
|
+
);
|
|
2087
|
+
envfile = this.addEnvParam(
|
|
2088
|
+
envfile,
|
|
2089
|
+
"jwt_secret_private",
|
|
2090
|
+
this.stripPemHeaders(privateKey)
|
|
2091
|
+
);
|
|
2111
2092
|
if (this.rotate && old_public_key && old_public_key[1]) {
|
|
2112
|
-
envfile = this.addEnvParam(
|
|
2093
|
+
envfile = this.addEnvParam(
|
|
2094
|
+
envfile,
|
|
2095
|
+
"jwt_secret_public_retired",
|
|
2096
|
+
old_public_key[1]
|
|
2097
|
+
);
|
|
2113
2098
|
}
|
|
2114
2099
|
await import_promises3.default.writeFile(import_path5.default.join(process.cwd(), ".env"), envfile, "utf-8");
|
|
2115
2100
|
}
|
|
@@ -2131,100 +2116,92 @@ ${key}=${value}`;
|
|
|
2131
2116
|
}
|
|
2132
2117
|
});
|
|
2133
2118
|
|
|
2134
|
-
// src/app/console/generate/GenerateControllerCommand.
|
|
2119
|
+
// src/app/console/generate/GenerateControllerCommand.mts
|
|
2135
2120
|
var import_clipanion8, import_change_case_all2, import_path6, fs5, import_neko_config6, import_handlebars2, import_url2, import_pluralize, import_meta2, GenerateControllerCommand;
|
|
2136
2121
|
var init_GenerateControllerCommand = __esm({
|
|
2137
|
-
"src/app/console/generate/GenerateControllerCommand.
|
|
2122
|
+
"src/app/console/generate/GenerateControllerCommand.mts"() {
|
|
2138
2123
|
"use strict";
|
|
2139
2124
|
init_facades();
|
|
2140
2125
|
import_clipanion8 = require("clipanion");
|
|
2141
2126
|
import_change_case_all2 = require("change-case-all");
|
|
2142
|
-
import_path6 = __toESM(require("path"));
|
|
2143
|
-
fs5 = __toESM(require("fs/promises"));
|
|
2127
|
+
import_path6 = __toESM(require("path"), 1);
|
|
2128
|
+
fs5 = __toESM(require("fs/promises"), 1);
|
|
2144
2129
|
import_neko_config6 = require("@devbro/neko-config");
|
|
2145
|
-
import_handlebars2 = __toESM(require("handlebars"));
|
|
2130
|
+
import_handlebars2 = __toESM(require("handlebars"), 1);
|
|
2146
2131
|
import_url2 = require("url");
|
|
2147
|
-
import_pluralize = __toESM(require("pluralize"));
|
|
2132
|
+
import_pluralize = __toESM(require("pluralize"), 1);
|
|
2148
2133
|
import_meta2 = {};
|
|
2149
2134
|
GenerateControllerCommand = class extends import_clipanion8.Command {
|
|
2150
2135
|
static {
|
|
2151
2136
|
__name(this, "GenerateControllerCommand");
|
|
2152
2137
|
}
|
|
2153
2138
|
static paths = [
|
|
2154
|
-
[
|
|
2155
|
-
|
|
2156
|
-
`controller`
|
|
2157
|
-
],
|
|
2158
|
-
[
|
|
2159
|
-
`generate`,
|
|
2160
|
-
`controller`
|
|
2161
|
-
]
|
|
2139
|
+
[`make`, `controller`],
|
|
2140
|
+
[`generate`, `controller`]
|
|
2162
2141
|
];
|
|
2163
|
-
name = import_clipanion8.Option.String({
|
|
2164
|
-
required: true
|
|
2165
|
-
});
|
|
2142
|
+
name = import_clipanion8.Option.String({ required: true });
|
|
2166
2143
|
async execute() {
|
|
2167
2144
|
const rootDir = process.cwd();
|
|
2168
2145
|
const date = /* @__PURE__ */ new Date();
|
|
2169
2146
|
const year = date.getFullYear();
|
|
2170
2147
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
2171
2148
|
const day = String(date.getDate()).padStart(2, "0");
|
|
2172
|
-
const secondsOfDay = String(
|
|
2149
|
+
const secondsOfDay = String(
|
|
2150
|
+
date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds()
|
|
2151
|
+
).padStart(5, "0");
|
|
2173
2152
|
const fixed_name = import_change_case_all2.Case.snake(this.name);
|
|
2174
2153
|
const filename = `${import_change_case_all2.Case.capital(this.name)}Controller.ts`;
|
|
2175
2154
|
this.context.stdout.write(`creating migration file ${filename}
|
|
2176
2155
|
`);
|
|
2177
|
-
await fs5.mkdir(import_neko_config6.config.get("migration.path"), {
|
|
2178
|
-
recursive: true
|
|
2179
|
-
});
|
|
2156
|
+
await fs5.mkdir(import_neko_config6.config.get("migration.path"), { recursive: true });
|
|
2180
2157
|
let dirname = typeof __dirname === "string" ? __dirname : void 0;
|
|
2181
2158
|
if (!dirname) {
|
|
2182
2159
|
dirname = import_path6.default.dirname((0, import_url2.fileURLToPath)(import_meta2.url));
|
|
2183
2160
|
}
|
|
2184
|
-
const compiledTemplate = import_handlebars2.default.compile(
|
|
2161
|
+
const compiledTemplate = import_handlebars2.default.compile(
|
|
2162
|
+
(await fs5.readFile(import_path6.default.join(dirname, "./controller.tpl"))).toString()
|
|
2163
|
+
);
|
|
2185
2164
|
const template = await compiledTemplate({
|
|
2186
2165
|
className: import_change_case_all2.Case.pascal(this.name),
|
|
2187
2166
|
classNameLower: import_change_case_all2.Case.snake(this.name),
|
|
2188
2167
|
routeName: import_change_case_all2.Case.kebab((0, import_pluralize.default)(this.name))
|
|
2189
2168
|
});
|
|
2190
|
-
await fs5.writeFile(
|
|
2169
|
+
await fs5.writeFile(
|
|
2170
|
+
import_path6.default.join(rootDir, "src/app/controllers", filename),
|
|
2171
|
+
template
|
|
2172
|
+
);
|
|
2191
2173
|
}
|
|
2192
2174
|
};
|
|
2193
2175
|
cli().register(GenerateControllerCommand);
|
|
2194
2176
|
}
|
|
2195
2177
|
});
|
|
2196
2178
|
|
|
2197
|
-
// src/app/console/generate/index.
|
|
2179
|
+
// src/app/console/generate/index.mts
|
|
2198
2180
|
var init_generate = __esm({
|
|
2199
|
-
"src/app/console/generate/index.
|
|
2181
|
+
"src/app/console/generate/index.mts"() {
|
|
2200
2182
|
"use strict";
|
|
2201
2183
|
init_GenerateControllerCommand();
|
|
2202
2184
|
}
|
|
2203
2185
|
});
|
|
2204
2186
|
|
|
2205
|
-
// src/app/console/project/CreateProjectCommand.
|
|
2187
|
+
// src/app/console/project/CreateProjectCommand.mts
|
|
2206
2188
|
var import_clipanion9, import_change_case_all3, import_path7, fs6, import_url3, import_handlebars3, import_child_process, import_meta3, CreateProjectCommand;
|
|
2207
2189
|
var init_CreateProjectCommand = __esm({
|
|
2208
|
-
"src/app/console/project/CreateProjectCommand.
|
|
2190
|
+
"src/app/console/project/CreateProjectCommand.mts"() {
|
|
2209
2191
|
"use strict";
|
|
2210
2192
|
import_clipanion9 = require("clipanion");
|
|
2211
2193
|
import_change_case_all3 = require("change-case-all");
|
|
2212
|
-
import_path7 = __toESM(require("path"));
|
|
2213
|
-
fs6 = __toESM(require("fs/promises"));
|
|
2194
|
+
import_path7 = __toESM(require("path"), 1);
|
|
2195
|
+
fs6 = __toESM(require("fs/promises"), 1);
|
|
2214
2196
|
import_url3 = require("url");
|
|
2215
|
-
import_handlebars3 = __toESM(require("handlebars"));
|
|
2197
|
+
import_handlebars3 = __toESM(require("handlebars"), 1);
|
|
2216
2198
|
import_child_process = require("child_process");
|
|
2217
2199
|
import_meta3 = {};
|
|
2218
2200
|
CreateProjectCommand = class extends import_clipanion9.Command {
|
|
2219
2201
|
static {
|
|
2220
2202
|
__name(this, "CreateProjectCommand");
|
|
2221
2203
|
}
|
|
2222
|
-
static paths = [
|
|
2223
|
-
[
|
|
2224
|
-
`create`,
|
|
2225
|
-
`project`
|
|
2226
|
-
]
|
|
2227
|
-
];
|
|
2204
|
+
static paths = [[`create`, `project`]];
|
|
2228
2205
|
static usage = import_clipanion9.Command.Usage({
|
|
2229
2206
|
category: `Project`,
|
|
2230
2207
|
description: `Create a new project`,
|
|
@@ -2243,9 +2220,7 @@ var init_CreateProjectCommand = __esm({
|
|
|
2243
2220
|
]
|
|
2244
2221
|
]
|
|
2245
2222
|
});
|
|
2246
|
-
projectPath = import_clipanion9.Option.String("--path", {
|
|
2247
|
-
required: true
|
|
2248
|
-
});
|
|
2223
|
+
projectPath = import_clipanion9.Option.String("--path", { required: true });
|
|
2249
2224
|
git = import_clipanion9.Option.Boolean(`--git`, false, {
|
|
2250
2225
|
description: `Initialize a git repository in the new project`
|
|
2251
2226
|
});
|
|
@@ -2268,9 +2243,7 @@ var init_CreateProjectCommand = __esm({
|
|
|
2268
2243
|
return 1;
|
|
2269
2244
|
} catch {
|
|
2270
2245
|
}
|
|
2271
|
-
await fs6.mkdir(projectPath, {
|
|
2272
|
-
recursive: true
|
|
2273
|
-
});
|
|
2246
|
+
await fs6.mkdir(projectPath, { recursive: true });
|
|
2274
2247
|
console.log(`Created project directory at: ${projectPath}`);
|
|
2275
2248
|
const dirname = typeof __dirname === "undefined" ? import_path7.default.dirname((0, import_url3.fileURLToPath)(import_meta3.url)) : __dirname;
|
|
2276
2249
|
let basePath = import_path7.default.join(dirname, `./base_project`);
|
|
@@ -2288,9 +2261,12 @@ var init_CreateProjectCommand = __esm({
|
|
|
2288
2261
|
console.log(`Updated package.json with project name: ${packageJson.name}`);
|
|
2289
2262
|
if (this.git) {
|
|
2290
2263
|
try {
|
|
2291
|
-
(0, import_child_process.execSync)(
|
|
2292
|
-
|
|
2293
|
-
|
|
2264
|
+
(0, import_child_process.execSync)(
|
|
2265
|
+
'git init; git add --all; git commit --allow-empty -m "chore: first commit for pashmak"',
|
|
2266
|
+
{
|
|
2267
|
+
cwd: projectPath
|
|
2268
|
+
}
|
|
2269
|
+
);
|
|
2294
2270
|
} catch (error) {
|
|
2295
2271
|
console.error(`Failed to create project.`, error);
|
|
2296
2272
|
return 1;
|
|
@@ -2298,26 +2274,26 @@ var init_CreateProjectCommand = __esm({
|
|
|
2298
2274
|
}
|
|
2299
2275
|
}
|
|
2300
2276
|
async processTplFolder(src, dest, data = {}) {
|
|
2301
|
-
const files = await fs6.readdir(src, {
|
|
2302
|
-
withFileTypes: true
|
|
2303
|
-
});
|
|
2277
|
+
const files = await fs6.readdir(src, { withFileTypes: true });
|
|
2304
2278
|
for (const file of files) {
|
|
2305
2279
|
const srcPath = import_path7.default.join(src, file.name);
|
|
2306
2280
|
const destPath = file.isFile() && file.name.endsWith(".tpl") ? import_path7.default.join(dest, file.name.substring(0, file.name.length - 4)) : import_path7.default.join(dest, file.name);
|
|
2307
2281
|
if (file.isDirectory()) {
|
|
2308
|
-
await fs6.mkdir(destPath, {
|
|
2309
|
-
recursive: true
|
|
2310
|
-
});
|
|
2282
|
+
await fs6.mkdir(destPath, { recursive: true });
|
|
2311
2283
|
await this.processTplFolder(srcPath, destPath, data);
|
|
2312
2284
|
} else if (file.name.endsWith(".tpl")) {
|
|
2313
2285
|
await this.processTplFile(srcPath, destPath, {});
|
|
2314
2286
|
} else {
|
|
2315
|
-
throw new Error(
|
|
2287
|
+
throw new Error(
|
|
2288
|
+
"unexpected non tpl file: " + srcPath + " " + file.name
|
|
2289
|
+
);
|
|
2316
2290
|
}
|
|
2317
2291
|
}
|
|
2318
2292
|
}
|
|
2319
2293
|
async processTplFile(src, dest, data = {}) {
|
|
2320
|
-
const compiledTemplate = import_handlebars3.default.compile(
|
|
2294
|
+
const compiledTemplate = import_handlebars3.default.compile(
|
|
2295
|
+
(await fs6.readFile(src)).toString()
|
|
2296
|
+
);
|
|
2321
2297
|
const template = await compiledTemplate(data);
|
|
2322
2298
|
await fs6.writeFile(dest, template);
|
|
2323
2299
|
}
|
|
@@ -2325,7 +2301,7 @@ var init_CreateProjectCommand = __esm({
|
|
|
2325
2301
|
}
|
|
2326
2302
|
});
|
|
2327
2303
|
|
|
2328
|
-
// src/app/console/index.
|
|
2304
|
+
// src/app/console/index.mts
|
|
2329
2305
|
var console_exports = {};
|
|
2330
2306
|
__export(console_exports, {
|
|
2331
2307
|
CreateProjectCommand: () => CreateProjectCommand,
|
|
@@ -2338,7 +2314,7 @@ __export(console_exports, {
|
|
|
2338
2314
|
StartCommand: () => StartCommand
|
|
2339
2315
|
});
|
|
2340
2316
|
var init_console = __esm({
|
|
2341
|
-
"src/app/console/index.
|
|
2317
|
+
"src/app/console/index.mts"() {
|
|
2342
2318
|
"use strict";
|
|
2343
2319
|
init_migrate();
|
|
2344
2320
|
init_StartCommand();
|
|
@@ -2416,16 +2392,13 @@ __export(index_exports, {
|
|
|
2416
2392
|
config: () => import_neko_config8.config
|
|
2417
2393
|
});
|
|
2418
2394
|
module.exports = __toCommonJS(index_exports);
|
|
2419
|
-
var import_dotenv = __toESM(require("dotenv"));
|
|
2420
2395
|
var import_neko_context6 = require("@devbro/neko-context");
|
|
2421
2396
|
init_dist();
|
|
2422
2397
|
var import_neko_config8 = require("@devbro/neko-config");
|
|
2423
2398
|
async function bootstrap(options) {
|
|
2424
|
-
import_dotenv.default.config();
|
|
2425
2399
|
console.log("Bootstrapping application...");
|
|
2426
2400
|
console.log(`Root directory: ${options.root_dir}`);
|
|
2427
|
-
|
|
2428
|
-
import_neko_config8.config.load(a);
|
|
2401
|
+
import_neko_config8.config.load(options.config_data || {});
|
|
2429
2402
|
console.log("Loading application modules...");
|
|
2430
2403
|
await Promise.resolve().then(() => (init_console(), console_exports));
|
|
2431
2404
|
console.log("Loading Database Provider ...");
|
package/dist/bin/pashmak_cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Cli } from "clipanion";
|
|
3
3
|
const [node, app, ...args] = process.argv;
|
|
4
|
-
|
|
4
|
+
const cli = new Cli({
|
|
5
5
|
binaryLabel: `Pashmak CLI`,
|
|
6
6
|
binaryName: `${node} ${app}`,
|
|
7
7
|
binaryVersion: `1.0.0`
|
|
8
8
|
});
|
|
9
|
-
import { CreateProjectCommand } from "../app/console/project/CreateProjectCommand";
|
|
9
|
+
import { CreateProjectCommand } from "../app/console/project/CreateProjectCommand.mjs";
|
|
10
10
|
cli.register(CreateProjectCommand);
|
|
11
11
|
cli.runExit(args).then(() => {
|
|
12
12
|
}).catch((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bin/pashmak_cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Cli } from \"clipanion\";\n\nconst [node, app, ...args] = process.argv;\
|
|
1
|
+
{"version":3,"sources":["../../src/bin/pashmak_cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Cli } from \"clipanion\";\n\nconst [node, app, ...args] = process.argv;\nconst cli = new Cli({\n binaryLabel: `Pashmak CLI`,\n binaryName: `${node} ${app}`,\n binaryVersion: `1.0.0`,\n});\n\nimport { CreateProjectCommand } from \"../app/console/project/CreateProjectCommand.mjs\";\n\ncli.register(CreateProjectCommand);\n\ncli\n .runExit(args)\n .then(() => {})\n .catch((err: any) => {\n console.error(err);\n });\n"],"mappings":";AAEA,SAASA,WAAW;AAEpB,MAAM,CAACC,MAAMC,KAAK,GAAGC,IAAAA,IAAQC,QAAQC;AACrC,MAAMC,MAAM,IAAIN,IAAI;EAClBO,aAAa;EACbC,YAAY,GAAGP,IAAAA,IAAQC,GAAAA;EACvBO,eAAe;AACjB,CAAA;AAEA,SAASC,4BAA4B;AAErCJ,IAAIK,SAASD,oBAAAA;AAEbJ,IACGM,QAAQT,IAAAA,EACRU,KAAK,MAAA;AAAO,CAAA,EACZC,MAAM,CAACC,QAAAA;AACNC,UAAQC,MAAMF,GAAAA;AAChB,CAAA;","names":["Cli","node","app","args","process","argv","cli","binaryLabel","binaryName","binaryVersion","CreateProjectCommand","register","runExit","then","catch","err","console","error"]}
|
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import dotenv from "dotenv";
|
|
4
3
|
import { context_provider } from "@devbro/neko-context";
|
|
5
4
|
import { runNext } from "@devbro/neko-router";
|
|
6
5
|
import { config } from "@devbro/neko-config";
|
|
7
6
|
async function bootstrap(options) {
|
|
8
|
-
dotenv.config();
|
|
9
7
|
console.log("Bootstrapping application...");
|
|
10
8
|
console.log(`Root directory: ${options.root_dir}`);
|
|
11
|
-
|
|
12
|
-
config.load(a);
|
|
9
|
+
config.load(options.config_data || {});
|
|
13
10
|
console.log("Loading application modules...");
|
|
14
|
-
await import("./app/console");
|
|
11
|
+
await import("./app/console/index.mjs");
|
|
15
12
|
console.log("Loading Database Provider ...");
|
|
16
13
|
const { DatabaseServiceProvider } = await import("./DatabaseServiceProvider.mjs");
|
|
17
14
|
console.log("Setting up pre-loader for context provider...");
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { context_provider } from \"@devbro/neko-context\";\nimport { Middleware } from \"@devbro/neko-router\";\nimport { runNext } from \"@devbro/neko-router\";\nimport { Request, Response } from \"@devbro/neko-router\";\nimport { config } from \"@devbro/neko-config\";\n\nexport { config };\nexport async function bootstrap(options: {\n root_dir: string;\n config_data: object;\n}): Promise<void> {\n // This function is used to bootstrap the application.\n // It can be used to initialize the application, load configuration, etc.\n // Currently, it does nothing but can be extended in the future.\n\n console.log(\"Bootstrapping application...\");\n console.log(`Root directory: ${options.root_dir}`);\n\n config.load(options.config_data || {});\n\n console.log(\"Loading application modules...\");\n await import(`./app/console/index.mjs`);\n console.log(\"Loading Database Provider ...\");\n const { DatabaseServiceProvider } = await import(\n \"./DatabaseServiceProvider.mjs\"\n );\n\n console.log(\"Setting up pre-loader for context provider...\");\n context_provider.setPreLoader(async (f: Function) => {\n const middlewares: Middleware[] = [];\n // do I need to use ServiceProvider like a middleware or can I get rid of this logic?\n middlewares.push(DatabaseServiceProvider.getInstance());\n\n return await runNext(\n middlewares,\n {} as Request,\n {} as Response,\n // @ts-ignore\n f,\n );\n });\n console.log(\"Application bootstrapped successfully.\");\n}\n"],"mappings":";;AAAA,SAASA,wBAAwB;AAEjC,SAASC,eAAe;AAExB,SAASC,cAAc;AAGvB,eAAsBC,UAAUC,SAG/B;AAKCC,UAAQC,IAAI,8BAAA;AACZD,UAAQC,IAAI,mBAAmBF,QAAQG,QAAQ,EAAE;AAEjDL,SAAOM,KAAKJ,QAAQK,eAAe,CAAC,CAAA;AAEpCJ,UAAQC,IAAI,gCAAA;AACZ,QAAM,OAAO,yBAAyB;AACtCD,UAAQC,IAAI,+BAAA;AACZ,QAAM,EAAEI,wBAAuB,IAAK,MAAM,OACxC,+BAAA;AAGFL,UAAQC,IAAI,+CAAA;AACZN,mBAAiBW,aAAa,OAAOC,MAAAA;AACnC,UAAMC,cAA4B,CAAA;AAElCA,gBAAYC,KAAKJ,wBAAwBK,YAAW,CAAA;AAEpD,WAAO,MAAMd;MACXY;MACA,CAAC;MACD,CAAC;;MAEDD;IAAAA;EAEJ,CAAA;AACAP,UAAQC,IAAI,wCAAA;AACd;AAnCsBH;","names":["context_provider","runNext","config","bootstrap","options","console","log","root_dir","load","config_data","DatabaseServiceProvider","setPreLoader","f","middlewares","push","getInstance"]}
|