@akanjs/cli 0.9.12 → 0.9.14
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/cjs/index.js +205 -149
- package/cjs/src/templates/module/__Model__.Template.js +4 -5
- package/cjs/src/templates/module/__model__.constant.js +2 -7
- package/cjs/src/templates/workspaceRoot/.gitignore.template +1 -0
- package/esm/index.js +193 -136
- package/esm/src/templates/module/__Model__.Template.js +4 -5
- package/esm/src/templates/module/__model__.constant.js +2 -7
- package/esm/src/templates/workspaceRoot/.gitignore.template +1 -0
- package/package.json +4 -1
- package/src/cloud/cloud.runner.d.ts +1 -0
- package/src/module/module.command.d.ts +1 -1
package/cjs/index.js
CHANGED
|
@@ -400,8 +400,8 @@ var fs3 = __toESM(require("fs"));
|
|
|
400
400
|
var import_ora2 = __toESM(require("ora"));
|
|
401
401
|
var ts = __toESM(require("typescript"));
|
|
402
402
|
var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
|
|
403
|
-
const configFile = ts.readConfigFile(tsConfigPath, (
|
|
404
|
-
return ts.sys.readFile(
|
|
403
|
+
const configFile = ts.readConfigFile(tsConfigPath, (path9) => {
|
|
404
|
+
return ts.sys.readFile(path9);
|
|
405
405
|
});
|
|
406
406
|
return ts.parseJsonConfigFileContent(
|
|
407
407
|
configFile.config,
|
|
@@ -564,14 +564,12 @@ var import_openai = require("@langchain/openai");
|
|
|
564
564
|
|
|
565
565
|
// pkgs/@akanjs/config/src/akanConfig.ts
|
|
566
566
|
var import_fs3 = __toESM(require("fs"));
|
|
567
|
-
var
|
|
567
|
+
var import_path = __toESM(require("path"));
|
|
568
568
|
|
|
569
569
|
// pkgs/@akanjs/config/src/nextConfig.ts
|
|
570
570
|
var import_bundle_analyzer = __toESM(require("@next/bundle-analyzer"));
|
|
571
571
|
var import_next_pwa = __toESM(require("next-pwa"));
|
|
572
572
|
var import_cache = __toESM(require("next-pwa/cache.js"));
|
|
573
|
-
var import_path = __toESM(require("path"));
|
|
574
|
-
var import_meta = {};
|
|
575
573
|
var composePlugins = (...plugins) => {
|
|
576
574
|
return function(baseConfig) {
|
|
577
575
|
return async function combined(phase, context2) {
|
|
@@ -591,7 +589,6 @@ var composePlugins = (...plugins) => {
|
|
|
591
589
|
var commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
|
|
592
590
|
var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
|
|
593
591
|
var withBase = (appName, config, libs, routes = []) => {
|
|
594
|
-
const __dirname = import_path.default.dirname(new URL(import_meta.url).pathname);
|
|
595
592
|
const withPWA = (0, import_next_pwa.default)({
|
|
596
593
|
dest: "public",
|
|
597
594
|
register: true,
|
|
@@ -662,15 +659,13 @@ var withBase = (appName, config, libs, routes = []) => {
|
|
|
662
659
|
webpack: (config2) => {
|
|
663
660
|
config2.resolve.alias.canvas = false;
|
|
664
661
|
config2.resolve.alias.encoding = false;
|
|
665
|
-
if (process.env.USE_AKANJS_PKGS === "true")
|
|
666
|
-
config2.resolve.alias["@akanjs/config"] = import_path.default.resolve(__dirname, "../../../../pkgs/@akanjs/config");
|
|
667
662
|
return config2;
|
|
668
663
|
},
|
|
669
664
|
turbopack: {
|
|
670
665
|
resolveAlias: {
|
|
671
666
|
// canvas: false,
|
|
672
667
|
// encoding: false,
|
|
673
|
-
...process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config":
|
|
668
|
+
// ...(process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {}),
|
|
674
669
|
...config.turbopack?.resolveAlias ?? {}
|
|
675
670
|
}
|
|
676
671
|
},
|
|
@@ -729,43 +724,11 @@ var makeAppConfig = (config, props) => {
|
|
|
729
724
|
rootLib: config.rootLib,
|
|
730
725
|
libs: config.libs ?? [],
|
|
731
726
|
backend: {
|
|
732
|
-
|
|
733
|
-
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
734
|
-
RUN apt-get update && apt-get upgrade -y && apt-get install -y git redis build-essential python3 ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils udev ffmpeg && rm -rf /var/lib/apt/lists/*
|
|
735
|
-
ARG TARGETARCH
|
|
736
|
-
RUN if [ "$TARGETARCH" = "amd64" ]; then wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian92-x86_64-100.3.1.deb && apt-get install -y ./mongodb-database-tools-*.deb && rm -f mongodb-database-tools-*.deb; fi
|
|
737
|
-
RUN mkdir -p /workspace
|
|
738
|
-
WORKDIR /workspace
|
|
739
|
-
COPY ./package.json ./package.json
|
|
740
|
-
RUN npx pnpm i --prod
|
|
741
|
-
COPY . .
|
|
742
|
-
ENV PORT 8080
|
|
743
|
-
ENV NODE_OPTIONS=--max_old_space_size=8192
|
|
744
|
-
ENV NEXT_PUBLIC_REPO_NAME=${repoName}
|
|
745
|
-
ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
|
|
746
|
-
ENV NEXT_PUBLIC_APP_NAME=${name}
|
|
747
|
-
ENV NEXT_PUBLIC_ENV=${env}
|
|
748
|
-
ENV NEXT_PUBLIC_OPERATION_MODE=cloud
|
|
749
|
-
CMD ["node", "main.js"]`,
|
|
727
|
+
docker: makeDockerfile("backend", config.backend?.docker ?? {}, props),
|
|
750
728
|
explicitDependencies: config.backend?.explicitDependencies ?? []
|
|
751
729
|
},
|
|
752
730
|
frontend: {
|
|
753
|
-
|
|
754
|
-
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
755
|
-
RUN apk --no-cache add git
|
|
756
|
-
RUN mkdir -p /workspace
|
|
757
|
-
WORKDIR /workspace
|
|
758
|
-
COPY ./package.json ./package.json
|
|
759
|
-
RUN npx pnpm i --prod
|
|
760
|
-
COPY . .
|
|
761
|
-
ENV PORT 4200
|
|
762
|
-
ENV NODE_OPTIONS=--max_old_space_size=8192
|
|
763
|
-
ENV NEXT_PUBLIC_REPO_NAME=${repoName}
|
|
764
|
-
ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
|
|
765
|
-
ENV NEXT_PUBLIC_APP_NAME=${name}
|
|
766
|
-
ENV NEXT_PUBLIC_ENV=${env}
|
|
767
|
-
ENV NEXT_PUBLIC_OPERATION_MODE=cloud
|
|
768
|
-
CMD ["npm", "start"]`,
|
|
731
|
+
docker: makeDockerfile("frontend", config.frontend?.docker ?? {}, props),
|
|
769
732
|
nextConfig: withBase(
|
|
770
733
|
name,
|
|
771
734
|
config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
|
|
@@ -784,7 +747,7 @@ CMD ["npm", "start"]`,
|
|
|
784
747
|
};
|
|
785
748
|
};
|
|
786
749
|
var getAppConfig = async (appRoot, props) => {
|
|
787
|
-
const akanConfigPath =
|
|
750
|
+
const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
|
|
788
751
|
if (!import_fs3.default.existsSync(akanConfigPath))
|
|
789
752
|
throw new Error(`application akan.config.ts is not found ${appRoot}`);
|
|
790
753
|
const configImp = (await import(`${appRoot}/akan.config.ts`)).default;
|
|
@@ -804,13 +767,95 @@ var makeLibConfig = (config, props) => {
|
|
|
804
767
|
};
|
|
805
768
|
};
|
|
806
769
|
var getLibConfig = async (libRoot, props) => {
|
|
807
|
-
const akanConfigPath =
|
|
770
|
+
const akanConfigPath = import_path.default.join(libRoot, "akan.config.ts");
|
|
808
771
|
if (!import_fs3.default.existsSync(akanConfigPath))
|
|
809
772
|
throw new Error(`library akan.config.ts is not found ${libRoot}`);
|
|
810
773
|
const configImp = (await import(`${libRoot}/akan.config.ts`)).default;
|
|
811
774
|
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
812
775
|
return makeLibConfig(config, props);
|
|
813
776
|
};
|
|
777
|
+
var getDockerRunScripts = (runs) => {
|
|
778
|
+
return runs.map((run) => {
|
|
779
|
+
if (typeof run === "string")
|
|
780
|
+
return `RUN ${run}`;
|
|
781
|
+
else
|
|
782
|
+
return Object.entries(run).map(([arch, script]) => `RUN if [ "$TARGETARCH" = "${arch}" ]; then ${script}; fi`).join("\n");
|
|
783
|
+
});
|
|
784
|
+
};
|
|
785
|
+
var getDockerImageScript = (image) => {
|
|
786
|
+
if (typeof image === "string")
|
|
787
|
+
return `FROM ${image}`;
|
|
788
|
+
else
|
|
789
|
+
return Object.entries(image).map(([arch, image2]) => `FROM ${image2} AS ${arch}`).join("\n");
|
|
790
|
+
};
|
|
791
|
+
var makeDockerfile = (type, config, props) => {
|
|
792
|
+
const { name, repoName, serveDomain, env } = props;
|
|
793
|
+
if (config.content)
|
|
794
|
+
return { content: config.content, image: {}, preRuns: [], postRuns: [], command: [] };
|
|
795
|
+
const preRunScripts = getDockerRunScripts(config.preRuns ?? []);
|
|
796
|
+
const postRunScripts = getDockerRunScripts(config.postRuns ?? []);
|
|
797
|
+
if (type === "backend") {
|
|
798
|
+
const imageScript = config.image ? getDockerImageScript(config.image) : "FROM node:22-slim";
|
|
799
|
+
const command = config.command ?? ["node", "main.js"];
|
|
800
|
+
const content = `${imageScript}
|
|
801
|
+
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
802
|
+
RUN apt-get update && apt-get upgrade -y
|
|
803
|
+
RUN apt-get install -y git redis build-essential python3 ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils udev ffmpeg && rm -rf /var/lib/apt/lists/*
|
|
804
|
+
ARG TARGETARCH
|
|
805
|
+
RUN if [ "$TARGETARCH" = "amd64" ]; then wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian92-x86_64-100.3.1.deb && apt-get install -y ./mongodb-database-tools-*.deb && rm -f mongodb-database-tools-*.deb; fi
|
|
806
|
+
${preRunScripts.join("\n")}
|
|
807
|
+
RUN mkdir -p /workspace
|
|
808
|
+
WORKDIR /workspace
|
|
809
|
+
COPY ./package.json ./package.json
|
|
810
|
+
RUN npx pnpm i --prod
|
|
811
|
+
COPY . .
|
|
812
|
+
ENV PORT 8080
|
|
813
|
+
ENV NODE_OPTIONS=--max_old_space_size=8192
|
|
814
|
+
ENV NEXT_PUBLIC_REPO_NAME=${repoName}
|
|
815
|
+
ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
|
|
816
|
+
ENV NEXT_PUBLIC_APP_NAME=${name}
|
|
817
|
+
ENV NEXT_PUBLIC_ENV=${env}
|
|
818
|
+
ENV NEXT_PUBLIC_OPERATION_MODE=cloud
|
|
819
|
+
${postRunScripts.join("\n")}
|
|
820
|
+
CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
821
|
+
return {
|
|
822
|
+
content,
|
|
823
|
+
image: imageScript,
|
|
824
|
+
preRuns: config.preRuns ?? [],
|
|
825
|
+
postRuns: config.postRuns ?? [],
|
|
826
|
+
command
|
|
827
|
+
};
|
|
828
|
+
} else {
|
|
829
|
+
const imageScript = config.image ? getDockerImageScript(config.image) : "FROM node:22-alpine";
|
|
830
|
+
const command = config.command ?? ["npm", "start"];
|
|
831
|
+
const content = `${imageScript}
|
|
832
|
+
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
|
|
833
|
+
ARG TARGETARCH
|
|
834
|
+
RUN apk --no-cache add git
|
|
835
|
+
${preRunScripts.join("\n")}
|
|
836
|
+
RUN mkdir -p /workspace
|
|
837
|
+
WORKDIR /workspace
|
|
838
|
+
COPY ./package.json ./package.json
|
|
839
|
+
RUN npx pnpm i --prod
|
|
840
|
+
COPY . .
|
|
841
|
+
ENV PORT 4200
|
|
842
|
+
ENV NODE_OPTIONS=--max_old_space_size=8192
|
|
843
|
+
ENV NEXT_PUBLIC_REPO_NAME=${repoName}
|
|
844
|
+
ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
|
|
845
|
+
ENV NEXT_PUBLIC_APP_NAME=${name}
|
|
846
|
+
ENV NEXT_PUBLIC_ENV=${env}
|
|
847
|
+
ENV NEXT_PUBLIC_OPERATION_MODE=cloud
|
|
848
|
+
${postRunScripts.join("\n")}
|
|
849
|
+
CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
850
|
+
return {
|
|
851
|
+
content,
|
|
852
|
+
image: imageScript,
|
|
853
|
+
preRuns: config.preRuns ?? [],
|
|
854
|
+
postRuns: config.postRuns ?? [],
|
|
855
|
+
command
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
};
|
|
814
859
|
|
|
815
860
|
// pkgs/@akanjs/config/src/types.ts
|
|
816
861
|
var getDefaultFileScan = () => ({
|
|
@@ -855,11 +900,11 @@ var import_child_process = require("child_process");
|
|
|
855
900
|
var import_dotenv = __toESM(require("dotenv"));
|
|
856
901
|
var import_fs4 = __toESM(require("fs"));
|
|
857
902
|
var import_promises = __toESM(require("fs/promises"));
|
|
858
|
-
var
|
|
903
|
+
var import_path3 = __toESM(require("path"));
|
|
859
904
|
|
|
860
905
|
// pkgs/@akanjs/devkit/src/dependencyScanner.ts
|
|
861
906
|
var fs5 = __toESM(require("fs"));
|
|
862
|
-
var
|
|
907
|
+
var path2 = __toESM(require("path"));
|
|
863
908
|
var ts2 = __toESM(require("typescript"));
|
|
864
909
|
var TypeScriptDependencyScanner = class {
|
|
865
910
|
constructor(directory) {
|
|
@@ -905,7 +950,7 @@ var TypeScriptDependencyScanner = class {
|
|
|
905
950
|
const processDirectory = async (dir) => {
|
|
906
951
|
const entries = await fs5.promises.readdir(dir, { withFileTypes: true });
|
|
907
952
|
for (const entry of entries) {
|
|
908
|
-
const fullPath =
|
|
953
|
+
const fullPath = path2.join(dir, entry.name);
|
|
909
954
|
if (entry.isDirectory()) {
|
|
910
955
|
if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
|
|
911
956
|
await processDirectory(fullPath);
|
|
@@ -925,12 +970,12 @@ var TypeScriptDependencyScanner = class {
|
|
|
925
970
|
const imports = this.#extractImports(fileContent, filePath);
|
|
926
971
|
const resolvedImports = imports.map((importPath) => {
|
|
927
972
|
if (importPath.startsWith(".")) {
|
|
928
|
-
const resolvedPath = "./" +
|
|
973
|
+
const resolvedPath = "./" + path2.join(path2.relative(baseDir, filePath), importPath);
|
|
929
974
|
return this.#ensureExtension(resolvedPath);
|
|
930
975
|
}
|
|
931
976
|
return importPath;
|
|
932
977
|
});
|
|
933
|
-
const relativePath =
|
|
978
|
+
const relativePath = path2.relative(baseDir, filePath);
|
|
934
979
|
this.#fileDependencies.set(relativePath, resolvedImports);
|
|
935
980
|
} catch (error) {
|
|
936
981
|
}
|
|
@@ -1005,14 +1050,14 @@ var TypeScriptDependencyScanner = class {
|
|
|
1005
1050
|
};
|
|
1006
1051
|
|
|
1007
1052
|
// pkgs/@akanjs/devkit/src/getDirname.ts
|
|
1008
|
-
var
|
|
1009
|
-
var getDirname = (url) =>
|
|
1053
|
+
var import_path2 = __toESM(require("path"));
|
|
1054
|
+
var getDirname = (url) => import_path2.default.dirname(new URL(url).pathname);
|
|
1010
1055
|
|
|
1011
1056
|
// pkgs/@akanjs/devkit/src/linter.ts
|
|
1012
1057
|
var import_chalk = __toESM(require("chalk"));
|
|
1013
1058
|
var import_eslint = require("eslint");
|
|
1014
1059
|
var fs6 = __toESM(require("fs"));
|
|
1015
|
-
var
|
|
1060
|
+
var path4 = __toESM(require("path"));
|
|
1016
1061
|
var Linter = class {
|
|
1017
1062
|
#logger = new Logger("Linter");
|
|
1018
1063
|
#eslint;
|
|
@@ -1022,10 +1067,10 @@ var Linter = class {
|
|
|
1022
1067
|
this.#eslint = new import_eslint.ESLint({ cwd: this.lintRoot, errorOnUnmatchedPattern: false });
|
|
1023
1068
|
}
|
|
1024
1069
|
#findEslintRootPath(dir) {
|
|
1025
|
-
const configPath2 =
|
|
1070
|
+
const configPath2 = path4.join(dir, "eslint.config.ts");
|
|
1026
1071
|
if (fs6.existsSync(configPath2))
|
|
1027
1072
|
return dir;
|
|
1028
|
-
const parentDir =
|
|
1073
|
+
const parentDir = path4.dirname(dir);
|
|
1029
1074
|
return this.#findEslintRootPath(parentDir);
|
|
1030
1075
|
}
|
|
1031
1076
|
async lint(filePath, { fix = false, dryRun = false } = {}) {
|
|
@@ -1214,7 +1259,7 @@ ${errorText}, ${warningText} found`];
|
|
|
1214
1259
|
// pkgs/@akanjs/devkit/src/typeChecker.ts
|
|
1215
1260
|
var import_chalk2 = __toESM(require("chalk"));
|
|
1216
1261
|
var fs7 = __toESM(require("fs"));
|
|
1217
|
-
var
|
|
1262
|
+
var path5 = __toESM(require("path"));
|
|
1218
1263
|
var ts3 = __toESM(require("typescript"));
|
|
1219
1264
|
var TypeChecker = class {
|
|
1220
1265
|
configPath;
|
|
@@ -1229,7 +1274,7 @@ var TypeChecker = class {
|
|
|
1229
1274
|
const parsedConfig = ts3.parseJsonConfigFileContent(
|
|
1230
1275
|
this.configFile.config,
|
|
1231
1276
|
ts3.sys,
|
|
1232
|
-
|
|
1277
|
+
path5.dirname(this.configPath),
|
|
1233
1278
|
void 0,
|
|
1234
1279
|
this.configPath
|
|
1235
1280
|
);
|
|
@@ -1384,7 +1429,7 @@ ${summary.join(", ")} found` + output.join("\n");
|
|
|
1384
1429
|
};
|
|
1385
1430
|
|
|
1386
1431
|
// pkgs/@akanjs/devkit/src/executors.ts
|
|
1387
|
-
var
|
|
1432
|
+
var import_meta = {};
|
|
1388
1433
|
var execEmoji = {
|
|
1389
1434
|
workspace: "\u{1F3E0}",
|
|
1390
1435
|
app: "\u{1F680}",
|
|
@@ -1496,7 +1541,7 @@ var Executor = class _Executor {
|
|
|
1496
1541
|
});
|
|
1497
1542
|
}
|
|
1498
1543
|
getPath(filePath) {
|
|
1499
|
-
if (
|
|
1544
|
+
if (import_path3.default.isAbsolute(filePath))
|
|
1500
1545
|
return filePath;
|
|
1501
1546
|
const baseParts = this.cwdPath.split("/").filter(Boolean);
|
|
1502
1547
|
const targetParts = filePath.split("/").filter(Boolean);
|
|
@@ -1549,7 +1594,7 @@ var Executor = class _Executor {
|
|
|
1549
1594
|
}
|
|
1550
1595
|
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
1551
1596
|
const writePath = this.getPath(filePath);
|
|
1552
|
-
const dir =
|
|
1597
|
+
const dir = import_path3.default.dirname(writePath);
|
|
1553
1598
|
if (!import_fs4.default.existsSync(dir))
|
|
1554
1599
|
import_fs4.default.mkdirSync(dir, { recursive: true });
|
|
1555
1600
|
let contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
@@ -1573,7 +1618,7 @@ var Executor = class _Executor {
|
|
|
1573
1618
|
return this;
|
|
1574
1619
|
}
|
|
1575
1620
|
getLocalFile(targetPath) {
|
|
1576
|
-
const filePath =
|
|
1621
|
+
const filePath = import_path3.default.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
|
|
1577
1622
|
const content = this.readFile(filePath);
|
|
1578
1623
|
return { filePath, content };
|
|
1579
1624
|
}
|
|
@@ -1624,11 +1669,11 @@ var Executor = class _Executor {
|
|
|
1624
1669
|
const result = getContent.default(scanResult ?? null, dict);
|
|
1625
1670
|
if (result === null)
|
|
1626
1671
|
return null;
|
|
1627
|
-
const filename = typeof result === "object" ? result.filename :
|
|
1672
|
+
const filename = typeof result === "object" ? result.filename : import_path3.default.basename(targetPath).replace(".js", ".ts");
|
|
1628
1673
|
const content = typeof result === "object" ? result.content : result;
|
|
1629
|
-
const dirname3 =
|
|
1674
|
+
const dirname3 = import_path3.default.dirname(targetPath);
|
|
1630
1675
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1631
|
-
(
|
|
1676
|
+
(path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1632
1677
|
`${dirname3}/${filename}`
|
|
1633
1678
|
);
|
|
1634
1679
|
this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
|
|
@@ -1636,7 +1681,7 @@ var Executor = class _Executor {
|
|
|
1636
1681
|
} else if (targetPath.endsWith(".template")) {
|
|
1637
1682
|
const content = await import_promises.default.readFile(templatePath, "utf8");
|
|
1638
1683
|
const convertedTargetPath = Object.entries(dict).reduce(
|
|
1639
|
-
(
|
|
1684
|
+
(path9, [key, value]) => path9.replace(new RegExp(`__${key}__`, "g"), value),
|
|
1640
1685
|
targetPath.slice(0, -9)
|
|
1641
1686
|
);
|
|
1642
1687
|
const convertedContent = Object.entries(dict).reduce(
|
|
@@ -1655,12 +1700,12 @@ var Executor = class _Executor {
|
|
|
1655
1700
|
dict = {},
|
|
1656
1701
|
overwrite = true
|
|
1657
1702
|
}) {
|
|
1658
|
-
const templatePath = `${getDirname(
|
|
1703
|
+
const templatePath = `${getDirname(import_meta.url)}/src/templates${template ? `/${template}` : ""}`;
|
|
1659
1704
|
const prefixTemplatePath = templatePath.endsWith(".tsx") ? templatePath : templatePath.replace(".ts", ".js");
|
|
1660
1705
|
if (import_fs4.default.statSync(prefixTemplatePath).isFile()) {
|
|
1661
|
-
const filename =
|
|
1706
|
+
const filename = import_path3.default.basename(prefixTemplatePath);
|
|
1662
1707
|
const fileContent = await this.#applyTemplateFile(
|
|
1663
|
-
{ templatePath: prefixTemplatePath, targetPath:
|
|
1708
|
+
{ templatePath: prefixTemplatePath, targetPath: import_path3.default.join(basePath2, filename), scanResult, overwrite },
|
|
1664
1709
|
dict
|
|
1665
1710
|
);
|
|
1666
1711
|
return fileContent ? [fileContent] : [];
|
|
@@ -1668,17 +1713,17 @@ var Executor = class _Executor {
|
|
|
1668
1713
|
const subdirs = await this.readdir(templatePath);
|
|
1669
1714
|
const fileContents = (await Promise.all(
|
|
1670
1715
|
subdirs.map(async (subdir) => {
|
|
1671
|
-
const subpath =
|
|
1716
|
+
const subpath = import_path3.default.join(templatePath, subdir);
|
|
1672
1717
|
if (import_fs4.default.statSync(subpath).isFile()) {
|
|
1673
1718
|
const fileContent = await this.#applyTemplateFile(
|
|
1674
|
-
{ templatePath: subpath, targetPath:
|
|
1719
|
+
{ templatePath: subpath, targetPath: import_path3.default.join(basePath2, subdir), scanResult, overwrite },
|
|
1675
1720
|
dict
|
|
1676
1721
|
);
|
|
1677
1722
|
return fileContent ? [fileContent] : [];
|
|
1678
1723
|
} else
|
|
1679
1724
|
return await this._applyTemplate({
|
|
1680
|
-
basePath:
|
|
1681
|
-
template:
|
|
1725
|
+
basePath: import_path3.default.join(basePath2, subdir),
|
|
1726
|
+
template: import_path3.default.join(template, subdir),
|
|
1682
1727
|
scanResult,
|
|
1683
1728
|
dict,
|
|
1684
1729
|
overwrite
|
|
@@ -1702,9 +1747,9 @@ var Executor = class _Executor {
|
|
|
1702
1747
|
return this.typeChecker;
|
|
1703
1748
|
}
|
|
1704
1749
|
typeCheck(filePath) {
|
|
1705
|
-
const
|
|
1750
|
+
const path9 = this.getPath(filePath);
|
|
1706
1751
|
const typeChecker = this.getTypeChecker();
|
|
1707
|
-
const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(
|
|
1752
|
+
const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path9);
|
|
1708
1753
|
const message = typeChecker.formatDiagnostics(fileDiagnostics);
|
|
1709
1754
|
return { fileDiagnostics, fileErrors, fileWarnings, message };
|
|
1710
1755
|
}
|
|
@@ -1713,9 +1758,9 @@ var Executor = class _Executor {
|
|
|
1713
1758
|
return this.linter;
|
|
1714
1759
|
}
|
|
1715
1760
|
async lint(filePath, { fix = false, dryRun = false } = {}) {
|
|
1716
|
-
const
|
|
1761
|
+
const path9 = this.getPath(filePath);
|
|
1717
1762
|
const linter = this.getLinter();
|
|
1718
|
-
const { results, errors, warnings } = await linter.lint(
|
|
1763
|
+
const { results, errors, warnings } = await linter.lint(path9, { fix, dryRun });
|
|
1719
1764
|
const message = linter.formatLintResults(results);
|
|
1720
1765
|
return { results, message, errors, warnings };
|
|
1721
1766
|
}
|
|
@@ -1730,7 +1775,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1730
1775
|
this.repoName = repoName;
|
|
1731
1776
|
}
|
|
1732
1777
|
static fromRoot() {
|
|
1733
|
-
const repoName =
|
|
1778
|
+
const repoName = import_path3.default.basename(process.cwd());
|
|
1734
1779
|
return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
|
|
1735
1780
|
}
|
|
1736
1781
|
getBaseDevEnv() {
|
|
@@ -1839,7 +1884,7 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1839
1884
|
dirs.map(async (dir) => {
|
|
1840
1885
|
if (dir.includes("_") || AVOID_DIRS.includes(dir))
|
|
1841
1886
|
return;
|
|
1842
|
-
const dirPath =
|
|
1887
|
+
const dirPath = import_path3.default.join(dirname3, dir);
|
|
1843
1888
|
if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
|
|
1844
1889
|
results.push(`${prefix}${dir}`);
|
|
1845
1890
|
if (maxDepth > 0)
|
|
@@ -1866,9 +1911,9 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
|
1866
1911
|
dirs.map(async (dir) => {
|
|
1867
1912
|
if (AVOID_DIRS.includes(dir))
|
|
1868
1913
|
return;
|
|
1869
|
-
const dirPath =
|
|
1914
|
+
const dirPath = import_path3.default.join(dirname3, dir);
|
|
1870
1915
|
if (import_fs4.default.lstatSync(dirPath).isDirectory()) {
|
|
1871
|
-
const hasTargetFile = import_fs4.default.existsSync(
|
|
1916
|
+
const hasTargetFile = import_fs4.default.existsSync(import_path3.default.join(dirPath, targetFilename));
|
|
1872
1917
|
if (hasTargetFile)
|
|
1873
1918
|
results.push(`${prefix}${dir}`);
|
|
1874
1919
|
if (maxDepth > 0)
|
|
@@ -1929,8 +1974,8 @@ var SysExecutor = class extends Executor {
|
|
|
1929
1974
|
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name, command }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name, command });
|
|
1930
1975
|
}
|
|
1931
1976
|
async getModules() {
|
|
1932
|
-
const
|
|
1933
|
-
return await this.workspace.getDirInModule(
|
|
1977
|
+
const path9 = this.type === "app" ? `apps/${this.name}/lib` : `libs/${this.name}/lib`;
|
|
1978
|
+
return await this.workspace.getDirInModule(path9, this.name);
|
|
1934
1979
|
}
|
|
1935
1980
|
async scan({
|
|
1936
1981
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
|
|
@@ -1942,19 +1987,19 @@ var SysExecutor = class extends Executor {
|
|
|
1942
1987
|
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
1943
1988
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
1944
1989
|
const pkgPathSet = new Set(
|
|
1945
|
-
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((
|
|
1990
|
+
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
|
|
1946
1991
|
);
|
|
1947
1992
|
const libPathSet = new Set(
|
|
1948
|
-
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((
|
|
1993
|
+
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("libs/"))).map((path9) => path9.replace("/*", ""))
|
|
1949
1994
|
);
|
|
1950
1995
|
const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
|
|
1951
|
-
const pkgDeps = [...pkgPathDepSet].map((
|
|
1952
|
-
const pathSplitLength =
|
|
1953
|
-
return (tsconfig.compilerOptions.paths?.[
|
|
1996
|
+
const pkgDeps = [...pkgPathDepSet].map((path9) => {
|
|
1997
|
+
const pathSplitLength = path9.split("/").length;
|
|
1998
|
+
return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1954
1999
|
});
|
|
1955
|
-
const libDeps = [...libPathDepSet].map((
|
|
1956
|
-
const pathSplitLength =
|
|
1957
|
-
return (tsconfig.compilerOptions.paths?.[
|
|
2000
|
+
const libDeps = [...libPathDepSet].map((path9) => {
|
|
2001
|
+
const pathSplitLength = path9.split("/").length;
|
|
2002
|
+
return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
1958
2003
|
}).filter((libName) => libName !== this.name);
|
|
1959
2004
|
if (!import_fs4.default.existsSync(`${this.cwdPath}/lib/__scalar`))
|
|
1960
2005
|
import_fs4.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
|
|
@@ -1966,7 +2011,7 @@ var SysExecutor = class extends Executor {
|
|
|
1966
2011
|
const serviceDirs = dirnames.filter((name) => name.startsWith("_") && !name.startsWith("__"));
|
|
1967
2012
|
await Promise.all(
|
|
1968
2013
|
databaseDirs.map(async (name) => {
|
|
1969
|
-
const filenames = await this.readdir(
|
|
2014
|
+
const filenames = await this.readdir(import_path3.default.join("lib", name));
|
|
1970
2015
|
filenames.forEach((filename) => {
|
|
1971
2016
|
if (filename.endsWith(".constant.ts"))
|
|
1972
2017
|
files.constants.databases.push(name);
|
|
@@ -1988,7 +2033,7 @@ var SysExecutor = class extends Executor {
|
|
|
1988
2033
|
await Promise.all(
|
|
1989
2034
|
serviceDirs.map(async (dirname3) => {
|
|
1990
2035
|
const name = dirname3.slice(1);
|
|
1991
|
-
const filenames = await this.readdir(
|
|
2036
|
+
const filenames = await this.readdir(import_path3.default.join("lib", dirname3));
|
|
1992
2037
|
filenames.forEach((filename) => {
|
|
1993
2038
|
if (filename.endsWith(".dictionary.ts"))
|
|
1994
2039
|
files.dictionary.services.push(name);
|
|
@@ -2006,7 +2051,7 @@ var SysExecutor = class extends Executor {
|
|
|
2006
2051
|
const scalarDirs = (await this.readdir("lib/__scalar")).filter((name) => !name.startsWith("_"));
|
|
2007
2052
|
await Promise.all(
|
|
2008
2053
|
scalarDirs.map(async (name) => {
|
|
2009
|
-
const filenames = await this.readdir(
|
|
2054
|
+
const filenames = await this.readdir(import_path3.default.join("lib/__scalar", name));
|
|
2010
2055
|
filenames.forEach((filename) => {
|
|
2011
2056
|
if (filename.endsWith(".constant.ts"))
|
|
2012
2057
|
files.constants.scalars.push(name);
|
|
@@ -2081,7 +2126,7 @@ var SysExecutor = class extends Executor {
|
|
|
2081
2126
|
return scanResult;
|
|
2082
2127
|
}
|
|
2083
2128
|
getLocalFile(targetPath) {
|
|
2084
|
-
const filePath =
|
|
2129
|
+
const filePath = import_path3.default.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
|
|
2085
2130
|
const content = this.workspace.readFile(filePath);
|
|
2086
2131
|
return { filePath, content };
|
|
2087
2132
|
}
|
|
@@ -2196,17 +2241,28 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2196
2241
|
}
|
|
2197
2242
|
async syncAssets(libDeps) {
|
|
2198
2243
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
2199
|
-
|
|
2200
|
-
|
|
2244
|
+
const projectAssetsLibPath = `${this.cwdPath}/assets/libs`;
|
|
2245
|
+
await Promise.all([
|
|
2246
|
+
import_fs4.default.existsSync(projectPublicLibPath) && import_promises.default.rm(projectPublicLibPath, { recursive: true }),
|
|
2247
|
+
import_fs4.default.existsSync(projectAssetsLibPath) && import_promises.default.rm(projectAssetsLibPath, { recursive: true })
|
|
2248
|
+
]);
|
|
2201
2249
|
const targetDeps = libDeps.filter((dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
|
|
2202
|
-
await Promise.all(
|
|
2203
|
-
|
|
2204
|
-
targetDeps.map(
|
|
2205
|
-
|
|
2250
|
+
await Promise.all([
|
|
2251
|
+
...targetDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })),
|
|
2252
|
+
...targetDeps.map((dep) => import_promises.default.mkdir(`${projectAssetsLibPath}/${dep}`, { recursive: true }))
|
|
2253
|
+
]);
|
|
2254
|
+
await Promise.all([
|
|
2255
|
+
...targetDeps.map(
|
|
2256
|
+
(dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`) && import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
|
|
2257
|
+
recursive: true
|
|
2258
|
+
})
|
|
2259
|
+
),
|
|
2260
|
+
...targetDeps.map(
|
|
2261
|
+
(dep) => import_fs4.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`) && import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`, {
|
|
2206
2262
|
recursive: true
|
|
2207
2263
|
})
|
|
2208
2264
|
)
|
|
2209
|
-
);
|
|
2265
|
+
]);
|
|
2210
2266
|
}
|
|
2211
2267
|
};
|
|
2212
2268
|
var LibExecutor = class _LibExecutor extends SysExecutor {
|
|
@@ -2256,12 +2312,12 @@ var PkgExecutor = class _PkgExecutor extends Executor {
|
|
|
2256
2312
|
const scanner = new TypeScriptDependencyScanner(this.cwdPath);
|
|
2257
2313
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
2258
2314
|
const pkgPathSet = new Set(
|
|
2259
|
-
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((
|
|
2315
|
+
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path9) => tsconfig.compilerOptions.paths?.[path9]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path9) => path9.replace("/*", ""))
|
|
2260
2316
|
);
|
|
2261
2317
|
const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
|
|
2262
|
-
const pkgDeps = [...pkgPathDepSet].map((
|
|
2263
|
-
const pathSplitLength =
|
|
2264
|
-
return (tsconfig.compilerOptions.paths?.[
|
|
2318
|
+
const pkgDeps = [...pkgPathDepSet].map((path9) => {
|
|
2319
|
+
const pathSplitLength = path9.split("/").length;
|
|
2320
|
+
return (tsconfig.compilerOptions.paths?.[path9]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
|
|
2265
2321
|
}).filter((pkg) => pkg !== this.name);
|
|
2266
2322
|
const pkgScanResult = {
|
|
2267
2323
|
name: this.name,
|
|
@@ -2571,8 +2627,8 @@ var extractDependencies = (filepaths, pacakgeJson, defaultDependencies = []) =>
|
|
|
2571
2627
|
...pacakgeJson.dependencies ?? {},
|
|
2572
2628
|
...pacakgeJson.devDependencies ?? {}
|
|
2573
2629
|
};
|
|
2574
|
-
const requireRegex = /require\s*\(\s*['"`]([^'"`]+)['"`]
|
|
2575
|
-
for (const { text } of filepaths.filter(({ path:
|
|
2630
|
+
const requireRegex = /(?:require\s*\(|import\s*(?:[\w\s{},*]*\s+from\s*)?|import\s*\()\s*['"`]([^'"`]+)['"`]/g;
|
|
2631
|
+
for (const { text } of filepaths.filter(({ path: path9 }) => path9.endsWith(".js"))) {
|
|
2576
2632
|
let requireMatch;
|
|
2577
2633
|
while ((requireMatch = requireRegex.exec(text)) !== null) {
|
|
2578
2634
|
const moduleName = requireMatch[1];
|
|
@@ -2677,7 +2733,7 @@ var import_prompts3 = require("@inquirer/prompts");
|
|
|
2677
2733
|
var import_chalk4 = __toESM(require("chalk"));
|
|
2678
2734
|
var import_commander = require("commander");
|
|
2679
2735
|
var import_fs7 = __toESM(require("fs"));
|
|
2680
|
-
var
|
|
2736
|
+
var import_meta2 = {};
|
|
2681
2737
|
var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2682
2738
|
var handleOption = (programCommand, argMeta) => {
|
|
2683
2739
|
const {
|
|
@@ -2853,7 +2909,7 @@ var runCommands = async (...commands) => {
|
|
|
2853
2909
|
process.on("unhandledRejection", (error) => {
|
|
2854
2910
|
process.exit(1);
|
|
2855
2911
|
});
|
|
2856
|
-
const __dirname = getDirname(
|
|
2912
|
+
const __dirname = getDirname(import_meta2.url);
|
|
2857
2913
|
const hasPackageJson = import_fs7.default.existsSync(`${__dirname}/../package.json`);
|
|
2858
2914
|
const version = hasPackageJson ? JSON.parse(import_fs7.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
|
|
2859
2915
|
import_commander.program.version(version).description("Akan CLI");
|
|
@@ -3282,21 +3338,21 @@ var Builder = class {
|
|
|
3282
3338
|
// pkgs/@akanjs/devkit/src/prompter.ts
|
|
3283
3339
|
var import_prompts5 = require("@inquirer/prompts");
|
|
3284
3340
|
var import_promises2 = __toESM(require("fs/promises"));
|
|
3285
|
-
var
|
|
3341
|
+
var import_meta3 = {};
|
|
3286
3342
|
var Prompter = class {
|
|
3287
3343
|
static async selectGuideline() {
|
|
3288
|
-
const guideNames = (await import_promises2.default.readdir(`${getDirname(
|
|
3344
|
+
const guideNames = (await import_promises2.default.readdir(`${getDirname(import_meta3.url)}/src/guidelines`)).filter(
|
|
3289
3345
|
(name) => !name.startsWith("_")
|
|
3290
3346
|
);
|
|
3291
3347
|
return await (0, import_prompts5.select)({ message: "Select a guideline", choices: guideNames.map((name) => ({ name, value: name })) });
|
|
3292
3348
|
}
|
|
3293
3349
|
static async getGuideJson(guideName) {
|
|
3294
|
-
const filePath = `${getDirname(
|
|
3350
|
+
const filePath = `${getDirname(import_meta3.url)}/src/guidelines/${guideName}/${guideName}.generate.json`;
|
|
3295
3351
|
const guideJson = await import_promises2.default.readFile(filePath, "utf-8");
|
|
3296
3352
|
return JSON.parse(guideJson);
|
|
3297
3353
|
}
|
|
3298
3354
|
static async getInstruction(guideName) {
|
|
3299
|
-
const filePath = `${getDirname(
|
|
3355
|
+
const filePath = `${getDirname(import_meta3.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
|
|
3300
3356
|
const content = await import_promises2.default.readFile(filePath, "utf-8");
|
|
3301
3357
|
return content;
|
|
3302
3358
|
}
|
|
@@ -3320,7 +3376,7 @@ ${request}
|
|
|
3320
3376
|
`;
|
|
3321
3377
|
}
|
|
3322
3378
|
async getDocumentation(guideName) {
|
|
3323
|
-
const filePath = `${getDirname(
|
|
3379
|
+
const filePath = `${getDirname(import_meta3.url)}/src/guidelines/${guideName}/${guideName}.instruction.md`;
|
|
3324
3380
|
const document = await import_promises2.default.readFile(filePath, "utf-8");
|
|
3325
3381
|
return `\`\`\`markdown
|
|
3326
3382
|
${document}
|
|
@@ -3495,7 +3551,7 @@ var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
|
3495
3551
|
var import_js_yaml2 = __toESM(require("js-yaml"), 1);
|
|
3496
3552
|
var import_open = __toESM(require("open"), 1);
|
|
3497
3553
|
var import_ora3 = __toESM(require("ora"), 1);
|
|
3498
|
-
var
|
|
3554
|
+
var import_path4 = __toESM(require("path"), 1);
|
|
3499
3555
|
var vite = __toESM(require("vite"), 1);
|
|
3500
3556
|
var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"), 1);
|
|
3501
3557
|
var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
|
|
@@ -3934,6 +3990,8 @@ var ApplicationRunner = class {
|
|
|
3934
3990
|
app.writeFile("next.config.ts", defaultNextConfigFile);
|
|
3935
3991
|
} else if (target === "csr")
|
|
3936
3992
|
await app.workspace.exec("rm -rf node_modules/.vite");
|
|
3993
|
+
else if (target === "backend")
|
|
3994
|
+
await app.cp("assets", import_path4.default.join(app.dist.cwdPath, "backend", "assets"));
|
|
3937
3995
|
return { env: this.#getEnv(app, { AKAN_COMMAND_TYPE: type }) };
|
|
3938
3996
|
}
|
|
3939
3997
|
async buildBackend(app) {
|
|
@@ -3962,7 +4020,7 @@ var ApplicationRunner = class {
|
|
|
3962
4020
|
dependencies
|
|
3963
4021
|
};
|
|
3964
4022
|
app.dist.writeJson("backend/package.json", appPackageJson);
|
|
3965
|
-
app.dist.writeFile(
|
|
4023
|
+
app.dist.writeFile(import_path4.default.join(app.dist.cwdPath, "backend", "Dockerfile"), akanConfig.backend.docker.content);
|
|
3966
4024
|
}
|
|
3967
4025
|
async startBackend(app, { open: open2 = false, onStart } = {}) {
|
|
3968
4026
|
const { env } = await this.#prepareCommand(app, "start", "backend");
|
|
@@ -3973,7 +4031,7 @@ var ApplicationRunner = class {
|
|
|
3973
4031
|
packages: "external",
|
|
3974
4032
|
platform: "node",
|
|
3975
4033
|
format: "cjs",
|
|
3976
|
-
outdir:
|
|
4034
|
+
outdir: import_path4.default.join(app.dist.cwdPath, "backend"),
|
|
3977
4035
|
logLevel: "warning"
|
|
3978
4036
|
});
|
|
3979
4037
|
await ctx.watch();
|
|
@@ -3981,7 +4039,7 @@ var ApplicationRunner = class {
|
|
|
3981
4039
|
onStart?.();
|
|
3982
4040
|
if (open2)
|
|
3983
4041
|
setTimeout(() => (0, import_open.default)("http://localhost:8080/backend/graphql"), 3e3);
|
|
3984
|
-
await app.dist.spawn("node", ["--watch", "
|
|
4042
|
+
await app.dist.spawn("node", ["--watch", "main.js"], { env, stdio: "inherit", cwd: `${app.dist.cwdPath}/backend` });
|
|
3985
4043
|
}
|
|
3986
4044
|
async buildFrontend(app, { spawnOptions } = {}) {
|
|
3987
4045
|
const { env } = await this.#prepareCommand(app, "build", "frontend");
|
|
@@ -3996,7 +4054,6 @@ var ApplicationRunner = class {
|
|
|
3996
4054
|
format: "esm",
|
|
3997
4055
|
write: false,
|
|
3998
4056
|
logLevel: "warning"
|
|
3999
|
-
// footer: { js: "module.exports = module.exports.default;" },
|
|
4000
4057
|
});
|
|
4001
4058
|
const rootPackageJson = app.workspace.readJson("package.json");
|
|
4002
4059
|
const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson, ["next", "react", "react-dom"]);
|
|
@@ -4011,10 +4068,10 @@ var ApplicationRunner = class {
|
|
|
4011
4068
|
};
|
|
4012
4069
|
app.dist.writeJson("frontend/package.json", appPackageJson);
|
|
4013
4070
|
await Promise.all([
|
|
4014
|
-
app.cp(".next",
|
|
4015
|
-
app.cp("public",
|
|
4071
|
+
app.cp(".next", import_path4.default.join(app.dist.cwdPath, "frontend", ".next")),
|
|
4072
|
+
app.cp("public", import_path4.default.join(app.dist.cwdPath, "frontend", "public"))
|
|
4016
4073
|
]);
|
|
4017
|
-
app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.
|
|
4074
|
+
app.dist.writeFile("frontend/Dockerfile", akanConfig.frontend.docker.content);
|
|
4018
4075
|
}
|
|
4019
4076
|
async startFrontend(app, { open: open2 = false, turbo = true, onStart } = {}) {
|
|
4020
4077
|
const { env } = await this.#prepareCommand(app, "start", "frontend");
|
|
@@ -4274,8 +4331,8 @@ var ApplicationRunner = class {
|
|
|
4274
4331
|
)
|
|
4275
4332
|
);
|
|
4276
4333
|
await Promise.all(
|
|
4277
|
-
[".next", "ios", "android", "public/libs"].map(async (
|
|
4278
|
-
const targetPath = `${sourceRoot}/apps/${app.name}/${
|
|
4334
|
+
[".next", "ios", "android", "public/libs"].map(async (path9) => {
|
|
4335
|
+
const targetPath = `${sourceRoot}/apps/${app.name}/${path9}`;
|
|
4279
4336
|
if (import_fs10.default.existsSync(targetPath))
|
|
4280
4337
|
await import_promises3.default.rm(targetPath, { recursive: true, force: true });
|
|
4281
4338
|
})
|
|
@@ -4293,7 +4350,7 @@ var ApplicationRunner = class {
|
|
|
4293
4350
|
];
|
|
4294
4351
|
await Promise.all(
|
|
4295
4352
|
syncPaths.map(
|
|
4296
|
-
(
|
|
4353
|
+
(path9) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path9}`, `${sourceRoot}/${path9}`, { recursive: true })
|
|
4297
4354
|
)
|
|
4298
4355
|
);
|
|
4299
4356
|
const tsconfig = app.workspace.readJson("tsconfig.json");
|
|
@@ -4997,6 +5054,15 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
|
|
|
4997
5054
|
Logger.info("All libraries are published to npm");
|
|
4998
5055
|
}
|
|
4999
5056
|
async update(workspace) {
|
|
5057
|
+
if (!workspace.exists("package.json"))
|
|
5058
|
+
await workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest"]);
|
|
5059
|
+
else
|
|
5060
|
+
await Promise.all([
|
|
5061
|
+
workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest"]),
|
|
5062
|
+
this.#updateAkanPkgs(workspace)
|
|
5063
|
+
]);
|
|
5064
|
+
}
|
|
5065
|
+
async #updateAkanPkgs(workspace) {
|
|
5000
5066
|
const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base");
|
|
5001
5067
|
const rootPackageJson = workspace.readJson("package.json");
|
|
5002
5068
|
if (!rootPackageJson.dependencies)
|
|
@@ -5010,10 +5076,7 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
|
|
|
5010
5076
|
Object.assign(rootPackageJson.devDependencies ?? {}, { [dependency]: latestPublishedVersionOfBase });
|
|
5011
5077
|
});
|
|
5012
5078
|
workspace.writeJson("package.json", rootPackageJson);
|
|
5013
|
-
await
|
|
5014
|
-
workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest"]),
|
|
5015
|
-
workspace.spawn("pnpm", ["install"])
|
|
5016
|
-
]);
|
|
5079
|
+
await workspace.spawn("pnpm", ["install"]);
|
|
5017
5080
|
}
|
|
5018
5081
|
};
|
|
5019
5082
|
|
|
@@ -5669,13 +5732,9 @@ var ModuleScript = class {
|
|
|
5669
5732
|
// pkgs/@akanjs/cli/src/module/module.command.ts
|
|
5670
5733
|
var ModuleCommand = class {
|
|
5671
5734
|
moduleScript = new ModuleScript();
|
|
5672
|
-
async createModule(
|
|
5735
|
+
async createModule(moduleName, sys3) {
|
|
5673
5736
|
const name = lowerlize(moduleName.replace(/ /g, ""));
|
|
5674
|
-
|
|
5675
|
-
await this.moduleScript.createModule(sys3, name, description, schemaDescription);
|
|
5676
|
-
} else {
|
|
5677
|
-
await this.moduleScript.createModuleTemplate(sys3, name);
|
|
5678
|
-
}
|
|
5737
|
+
await this.moduleScript.createModuleTemplate(sys3, name);
|
|
5679
5738
|
}
|
|
5680
5739
|
removeModule(module2) {
|
|
5681
5740
|
this.moduleScript.removeModule(module2);
|
|
@@ -5692,11 +5751,8 @@ var ModuleCommand = class {
|
|
|
5692
5751
|
};
|
|
5693
5752
|
__decorateClass([
|
|
5694
5753
|
Target.Public(),
|
|
5695
|
-
__decorateParam(0,
|
|
5696
|
-
__decorateParam(1,
|
|
5697
|
-
__decorateParam(2, Option("description", { desc: "description of module" })),
|
|
5698
|
-
__decorateParam(3, Option("schemaDescription", { desc: "schema description of module" })),
|
|
5699
|
-
__decorateParam(4, Option("ai", { type: "boolean", default: false, desc: "use ai to create module" }))
|
|
5754
|
+
__decorateParam(0, Argument("moduleName", { desc: "name of module" })),
|
|
5755
|
+
__decorateParam(1, Sys())
|
|
5700
5756
|
], ModuleCommand.prototype, "createModule", 1);
|
|
5701
5757
|
__decorateClass([
|
|
5702
5758
|
Target.Public(),
|
|
@@ -5793,12 +5849,12 @@ PageCommand = __decorateClass([
|
|
|
5793
5849
|
|
|
5794
5850
|
// pkgs/@akanjs/cli/src/workspace/workspace.runner.ts
|
|
5795
5851
|
var import_latest_version2 = __toESM(require("latest-version"), 1);
|
|
5796
|
-
var
|
|
5852
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
5797
5853
|
var import_uuid2 = require("uuid");
|
|
5798
5854
|
var WorkspaceRunner = class {
|
|
5799
5855
|
async createWorkspace(repoName, appName, dirname3 = ".") {
|
|
5800
5856
|
const cwdPath = process.cwd();
|
|
5801
|
-
const workspaceRoot =
|
|
5857
|
+
const workspaceRoot = import_path5.default.join(cwdPath, dirname3, repoName);
|
|
5802
5858
|
const workspace = new WorkspaceExecutor({ workspaceRoot, repoName });
|
|
5803
5859
|
const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
|
|
5804
5860
|
await workspace.applyTemplate({
|
|
@@ -5987,7 +6043,7 @@ WorkspaceCommand = __decorateClass([
|
|
|
5987
6043
|
// pkgs/@akanjs/cli/src/guideline/guideline.prompt.ts
|
|
5988
6044
|
var import_fs12 = __toESM(require("fs"), 1);
|
|
5989
6045
|
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
5990
|
-
var
|
|
6046
|
+
var import_meta4 = {};
|
|
5991
6047
|
var GuidelinePrompt = class extends Prompter {
|
|
5992
6048
|
constructor(workspace, name) {
|
|
5993
6049
|
super();
|
|
@@ -5997,15 +6053,15 @@ var GuidelinePrompt = class extends Prompter {
|
|
|
5997
6053
|
async #getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
|
|
5998
6054
|
const matchingPaths = import_promises5.default.glob(matchPattern, {
|
|
5999
6055
|
cwd: this.workspace.workspaceRoot,
|
|
6000
|
-
exclude: (
|
|
6056
|
+
exclude: (path9) => avoidDirs.some((dir) => path9.includes(dir))
|
|
6001
6057
|
});
|
|
6002
6058
|
const paths = [];
|
|
6003
|
-
for await (const
|
|
6004
|
-
const fileContent = import_fs12.default.readFileSync(
|
|
6059
|
+
for await (const path9 of matchingPaths) {
|
|
6060
|
+
const fileContent = import_fs12.default.readFileSync(path9, "utf-8");
|
|
6005
6061
|
const textFilter = filterText ? new RegExp(filterText) : null;
|
|
6006
6062
|
if (filterText && !textFilter?.test(fileContent))
|
|
6007
6063
|
continue;
|
|
6008
|
-
paths.push(
|
|
6064
|
+
paths.push(path9);
|
|
6009
6065
|
}
|
|
6010
6066
|
return paths;
|
|
6011
6067
|
}
|
|
@@ -6018,7 +6074,7 @@ var GuidelinePrompt = class extends Prompter {
|
|
|
6018
6074
|
const scanResult = targetFilePaths.map((filePath) => ({ ...scan, ...this.workspace.getLocalFile(filePath) }));
|
|
6019
6075
|
scanFiles.push(...scanResult);
|
|
6020
6076
|
}
|
|
6021
|
-
const resultPath = `${getDirname(
|
|
6077
|
+
const resultPath = `${getDirname(import_meta4.url)}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
6022
6078
|
const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/src/guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
6023
6079
|
const isResultExists = this.workspace.exists(writePath);
|
|
6024
6080
|
const existingResult = isResultExists ? this.workspace.readFile(resultPath) : null;
|
|
@@ -6060,7 +6116,7 @@ ${guideJson.update.rules.map((rule) => `- ${rule}`).join("\n")}
|
|
|
6060
6116
|
}
|
|
6061
6117
|
async requestUpdateInstruction(updateRequest) {
|
|
6062
6118
|
const guideJson = await Prompter.getGuideJson(this.name);
|
|
6063
|
-
const resultPath = `${getDirname(
|
|
6119
|
+
const resultPath = `${getDirname(import_meta4.url)}/src/guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
6064
6120
|
const writePath = `${this.workspace.workspaceRoot}/pkgs/@akanjs/cli/src/guidelines/${this.name}/${guideJson.update.filePath}`;
|
|
6065
6121
|
const isResultExists = this.workspace.exists(writePath);
|
|
6066
6122
|
if (!isResultExists)
|