@akanjs/cli 0.0.127 → 0.0.129
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 +119 -75
- package/cjs/src/templates/app/app/index.html.template +1 -1
- package/esm/index.js +119 -75
- package/esm/src/templates/app/app/index.html.template +1 -1
- package/package.json +1 -1
- package/src/application/application.script.d.ts +1 -3
- package/src/library/library.script.d.ts +1 -3
package/cjs/index.js
CHANGED
|
@@ -679,6 +679,12 @@ CMD ["npm", "start"]`,
|
|
|
679
679
|
config.frontend?.routes
|
|
680
680
|
),
|
|
681
681
|
explicitDependencies: config.frontend?.explicitDependencies ?? []
|
|
682
|
+
},
|
|
683
|
+
mobile: {
|
|
684
|
+
appName: config.mobile?.appName ?? name,
|
|
685
|
+
bundleId: config.mobile?.bundleId ?? `com.${repoName}.${name}`,
|
|
686
|
+
version: config.mobile?.version,
|
|
687
|
+
buildNum: config.mobile?.buildNum
|
|
682
688
|
}
|
|
683
689
|
};
|
|
684
690
|
};
|
|
@@ -905,9 +911,11 @@ var TypeScriptDependencyScanner = class {
|
|
|
905
911
|
|
|
906
912
|
// pkgs/@akanjs/devkit/src/executors.ts
|
|
907
913
|
var Executor = class {
|
|
914
|
+
name;
|
|
908
915
|
logger;
|
|
909
916
|
cwdPath;
|
|
910
917
|
constructor(name, cwdPath) {
|
|
918
|
+
this.name = name;
|
|
911
919
|
this.logger = new Logger(name);
|
|
912
920
|
this.cwdPath = cwdPath;
|
|
913
921
|
if (!import_fs4.default.existsSync(cwdPath))
|
|
@@ -1032,7 +1040,7 @@ var Executor = class {
|
|
|
1032
1040
|
this.logger.verbose(msg);
|
|
1033
1041
|
return this;
|
|
1034
1042
|
}
|
|
1035
|
-
getTsConfig(pathname) {
|
|
1043
|
+
getTsConfig(pathname = "tsconfig.json") {
|
|
1036
1044
|
const tsconfig = this.readJson(pathname);
|
|
1037
1045
|
if (tsconfig.extends) {
|
|
1038
1046
|
const extendsTsconfig = this.getTsConfig(tsconfig.extends);
|
|
@@ -1640,18 +1648,90 @@ var CapacitorApp = class {
|
|
|
1640
1648
|
ios: { path: "ios/App" }
|
|
1641
1649
|
});
|
|
1642
1650
|
await project.load();
|
|
1643
|
-
if (!project.android)
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1651
|
+
if (!project.android) {
|
|
1652
|
+
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
1653
|
+
await project.load();
|
|
1654
|
+
}
|
|
1655
|
+
if (!project.ios) {
|
|
1656
|
+
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
1657
|
+
await project.load();
|
|
1658
|
+
}
|
|
1649
1659
|
this.project = project;
|
|
1650
1660
|
return this;
|
|
1651
1661
|
}
|
|
1652
1662
|
async save() {
|
|
1653
1663
|
await this.project.commit();
|
|
1654
1664
|
}
|
|
1665
|
+
async #prepareIos() {
|
|
1666
|
+
const isAdded = import_fs6.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
1667
|
+
if (!isAdded) {
|
|
1668
|
+
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
1669
|
+
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
1670
|
+
} else
|
|
1671
|
+
this.app.verbose(`iOS already added, skip adding process`);
|
|
1672
|
+
await this.app.spawn("npx", ["cap", "sync", "ios"]);
|
|
1673
|
+
}
|
|
1674
|
+
async buildIos() {
|
|
1675
|
+
await this.#prepareIos();
|
|
1676
|
+
await this.app.spawn("npx", ["cap", "run", "ios"]);
|
|
1677
|
+
}
|
|
1678
|
+
async openIos() {
|
|
1679
|
+
await this.app.spawn("npx", ["cap", "open", "ios"]);
|
|
1680
|
+
}
|
|
1681
|
+
async runIos({ operation, bundleId, version = "0.0.1", buildNum = 1 }) {
|
|
1682
|
+
await this.#prepareIos();
|
|
1683
|
+
this.project.ios.setBundleId("App", "Debug", bundleId);
|
|
1684
|
+
this.project.ios.setBundleId("App", "Release", bundleId);
|
|
1685
|
+
await this.project.ios.setVersion("App", "Debug", version);
|
|
1686
|
+
await this.project.ios.setVersion("App", "Release", version);
|
|
1687
|
+
await this.project.ios.setBuild("App", "Debug", buildNum);
|
|
1688
|
+
await this.project.ios.setBuild("App", "Release", buildNum);
|
|
1689
|
+
await this.project.commit();
|
|
1690
|
+
await this.app.spawn("npx", [
|
|
1691
|
+
"cross-env",
|
|
1692
|
+
`APP_OPERATION_MODE=${operation}`,
|
|
1693
|
+
"npx",
|
|
1694
|
+
"cap",
|
|
1695
|
+
"run",
|
|
1696
|
+
"ios",
|
|
1697
|
+
"--live-reload",
|
|
1698
|
+
"--port",
|
|
1699
|
+
"4201"
|
|
1700
|
+
]);
|
|
1701
|
+
}
|
|
1702
|
+
async #prepareAndroid() {
|
|
1703
|
+
const isAdded = import_fs6.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
1704
|
+
if (!isAdded) {
|
|
1705
|
+
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
1706
|
+
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
1707
|
+
} else
|
|
1708
|
+
this.app.verbose(`Android already added, skip adding process`);
|
|
1709
|
+
await this.app.spawn("npx", ["cap", "sync", "android"]);
|
|
1710
|
+
}
|
|
1711
|
+
async buildAndroid() {
|
|
1712
|
+
await this.#prepareAndroid();
|
|
1713
|
+
await this.app.spawn("npx", ["cap", "build", "android"]);
|
|
1714
|
+
}
|
|
1715
|
+
async openAndroid() {
|
|
1716
|
+
await this.app.spawn("npx", ["cap", "open", "android"]);
|
|
1717
|
+
}
|
|
1718
|
+
async runAndroid({ operation, appName, bundleId, version = "0.0.1", buildNum = 1 }) {
|
|
1719
|
+
await this.project.android.setVersionName(version);
|
|
1720
|
+
await this.project.android.setVersionCode(buildNum);
|
|
1721
|
+
await this.project.android.setPackageName(bundleId);
|
|
1722
|
+
await this.project.android.setAppName(appName);
|
|
1723
|
+
await this.app.spawn("npx", [
|
|
1724
|
+
"cross-env",
|
|
1725
|
+
`APP_OPERATION_MODE=${operation}`,
|
|
1726
|
+
"npx",
|
|
1727
|
+
"cap",
|
|
1728
|
+
"run",
|
|
1729
|
+
"android",
|
|
1730
|
+
"--live-reload",
|
|
1731
|
+
"--port",
|
|
1732
|
+
"4201"
|
|
1733
|
+
]);
|
|
1734
|
+
}
|
|
1655
1735
|
async releaseIos() {
|
|
1656
1736
|
const isAdded = import_fs6.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
1657
1737
|
if (!isAdded) {
|
|
@@ -2059,6 +2139,8 @@ var runCommands = async (...commands) => {
|
|
|
2059
2139
|
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
2060
2140
|
else
|
|
2061
2141
|
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
2142
|
+
if (commandArgs[argMeta.idx] instanceof AppExecutor)
|
|
2143
|
+
process.env.NEXT_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
|
|
2062
2144
|
}
|
|
2063
2145
|
const cmd = new command();
|
|
2064
2146
|
try {
|
|
@@ -2380,11 +2462,8 @@ var LibraryScript = class {
|
|
|
2380
2462
|
lib.logger.rawLog(JSON.stringify(scanResult, null, 2));
|
|
2381
2463
|
return scanResult;
|
|
2382
2464
|
}
|
|
2383
|
-
async syncLibrary(lib
|
|
2465
|
+
async syncLibrary(lib) {
|
|
2384
2466
|
const akanConfig = await lib.getConfig();
|
|
2385
|
-
if (recursive)
|
|
2386
|
-
for (const libName of akanConfig.libs)
|
|
2387
|
-
await this.syncLibrary(LibExecutor.from(lib.workspace, libName), { recursive: false });
|
|
2388
2467
|
return await lib.scan({ akanConfig });
|
|
2389
2468
|
}
|
|
2390
2469
|
async createLibrary(libName, workspace) {
|
|
@@ -4617,7 +4696,8 @@ var ApplicationRunner = class {
|
|
|
4617
4696
|
};
|
|
4618
4697
|
}
|
|
4619
4698
|
async #prepareCommand(app, type, target) {
|
|
4620
|
-
|
|
4699
|
+
if (type === "build")
|
|
4700
|
+
await app.dist.exec(`rm -rf ${target}`);
|
|
4621
4701
|
if (target === "frontend") {
|
|
4622
4702
|
await app.exec("rm -rf .next");
|
|
4623
4703
|
app.writeFile("next.config.ts", defaultNextConfigFile);
|
|
@@ -4711,10 +4791,11 @@ var ApplicationRunner = class {
|
|
|
4711
4791
|
setTimeout(() => (0, import_open.default)("http://localhost:4200"), 3e3);
|
|
4712
4792
|
await app.spawn("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], { env });
|
|
4713
4793
|
}
|
|
4714
|
-
async #getViteConfig(app) {
|
|
4715
|
-
const { env } = await this.#prepareCommand(app,
|
|
4794
|
+
async #getViteConfig(app, command) {
|
|
4795
|
+
const { env } = await this.#prepareCommand(app, command, "csr");
|
|
4796
|
+
const tsconfig = app.workspace.getTsConfig();
|
|
4716
4797
|
const processEnv = env;
|
|
4717
|
-
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? `${app.workspace.workspaceRoot}/pkgs/` :
|
|
4798
|
+
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? `${app.workspace.workspaceRoot}/pkgs/` : `${app.workspace.workspaceRoot}/pkgs/`;
|
|
4718
4799
|
const config = vite.defineConfig({
|
|
4719
4800
|
root: `${app.cwdPath}/app`,
|
|
4720
4801
|
base: "/",
|
|
@@ -4722,7 +4803,7 @@ var ApplicationRunner = class {
|
|
|
4722
4803
|
outDir: `${app.dist.cwdPath}/csr`,
|
|
4723
4804
|
sourcemap: false,
|
|
4724
4805
|
emptyOutDir: true,
|
|
4725
|
-
rollupOptions: {
|
|
4806
|
+
rollupOptions: { input: `${app.cwdPath}/app/index.html` }
|
|
4726
4807
|
},
|
|
4727
4808
|
css: { postcss: `${app.cwdPath}/postcss.config.js` },
|
|
4728
4809
|
publicDir: `${app.cwdPath}/public`,
|
|
@@ -4739,6 +4820,12 @@ var ApplicationRunner = class {
|
|
|
4739
4820
|
],
|
|
4740
4821
|
resolve: {
|
|
4741
4822
|
alias: {
|
|
4823
|
+
...Object.fromEntries(
|
|
4824
|
+
Object.entries(tsconfig.compilerOptions.paths).map(([key, value]) => [
|
|
4825
|
+
key.replace("/*", ""),
|
|
4826
|
+
`${app.workspace.workspaceRoot}/${value[0].replace("/*", "").replace("/index.ts", "")}`
|
|
4827
|
+
])
|
|
4828
|
+
),
|
|
4742
4829
|
"@akanjs/config": `${akanjsPrefix}@akanjs/config`,
|
|
4743
4830
|
"next/font/local": `${akanjsPrefix}@akanjs/client/src/createFont`,
|
|
4744
4831
|
"next/font/google": `${akanjsPrefix}@akanjs/client/src/createFont`,
|
|
@@ -4778,82 +4865,41 @@ var ApplicationRunner = class {
|
|
|
4778
4865
|
return config;
|
|
4779
4866
|
}
|
|
4780
4867
|
async buildCsr(app) {
|
|
4781
|
-
const config = await this.#getViteConfig(app);
|
|
4868
|
+
const config = await this.#getViteConfig(app, "build");
|
|
4782
4869
|
await vite.build(config);
|
|
4783
4870
|
}
|
|
4784
4871
|
async startCsr(app, { open: open2 = false } = {}) {
|
|
4785
|
-
const config = await this.#getViteConfig(app);
|
|
4872
|
+
const config = await this.#getViteConfig(app, "start");
|
|
4786
4873
|
const server = await vite.createServer(config);
|
|
4787
4874
|
await server.listen(4201);
|
|
4788
4875
|
app.log(`CSR server is running on http://localhost:4201`);
|
|
4789
4876
|
if (open2)
|
|
4790
4877
|
setTimeout(() => (0, import_open.default)("http://localhost:4201"), 3e3);
|
|
4791
4878
|
}
|
|
4792
|
-
async #prepareIos(app) {
|
|
4793
|
-
const isAdded = import_fs9.default.existsSync(`${app.cwdPath}/ios/App/Podfile`);
|
|
4794
|
-
if (!isAdded) {
|
|
4795
|
-
await app.spawn("npx", ["cap", "add", "ios"]);
|
|
4796
|
-
await app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
4797
|
-
} else
|
|
4798
|
-
app.verbose(`iOS already added, skip adding process`);
|
|
4799
|
-
await app.spawn("npx", ["cap", "sync", "ios"]);
|
|
4800
|
-
}
|
|
4801
4879
|
async buildIos(app) {
|
|
4802
|
-
await
|
|
4803
|
-
await
|
|
4880
|
+
const capacitorApp = await new CapacitorApp(app).init();
|
|
4881
|
+
await capacitorApp.buildIos();
|
|
4804
4882
|
}
|
|
4805
4883
|
async startIos(app, { open: open2 = false, operation = "local" } = {}) {
|
|
4806
|
-
await
|
|
4884
|
+
const akanConfig = await app.getConfig();
|
|
4885
|
+
const capacitorApp = await new CapacitorApp(app).init();
|
|
4886
|
+
await capacitorApp.runIos({ ...akanConfig.mobile, operation });
|
|
4807
4887
|
if (open2)
|
|
4808
|
-
await
|
|
4809
|
-
await app.spawn("npx", ["trapeze", "run", "config.yaml"]);
|
|
4810
|
-
await app.spawn("npx", [
|
|
4811
|
-
"cross-env",
|
|
4812
|
-
`APP_OPERATION_MODE=${operation}`,
|
|
4813
|
-
"npx",
|
|
4814
|
-
"cap",
|
|
4815
|
-
"run",
|
|
4816
|
-
"ios",
|
|
4817
|
-
"--live-reload",
|
|
4818
|
-
"--port",
|
|
4819
|
-
"4201"
|
|
4820
|
-
]);
|
|
4888
|
+
await capacitorApp.openIos();
|
|
4821
4889
|
}
|
|
4822
4890
|
async releaseIos(app) {
|
|
4823
4891
|
const capacitorApp = new CapacitorApp(app);
|
|
4824
4892
|
await capacitorApp.init();
|
|
4825
4893
|
await capacitorApp.releaseIos();
|
|
4826
4894
|
}
|
|
4827
|
-
async #prepareAndroid(app) {
|
|
4828
|
-
const isAdded = import_fs9.default.existsSync(`${app.cwdPath}/android/app/build.gradle`);
|
|
4829
|
-
if (!isAdded) {
|
|
4830
|
-
await app.spawn("npx", ["cap", "add", "android"]);
|
|
4831
|
-
await app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
4832
|
-
} else
|
|
4833
|
-
app.verbose(`Android already added, skip adding process`);
|
|
4834
|
-
await app.spawn("npx", ["cap", "sync", "android"]);
|
|
4835
|
-
}
|
|
4836
4895
|
async buildAndroid(app) {
|
|
4837
|
-
await
|
|
4838
|
-
await
|
|
4896
|
+
const capacitorApp = await new CapacitorApp(app).init();
|
|
4897
|
+
await capacitorApp.buildAndroid();
|
|
4839
4898
|
}
|
|
4840
4899
|
async startAndroid(app, { open: open2 = false, operation = "local" } = {}) {
|
|
4841
|
-
await
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
await app.spawn("npx", ["cap", "build", "android"]);
|
|
4845
|
-
await app.spawn("npx", ["trapeze", "run", "config.yaml"]);
|
|
4846
|
-
await app.spawn("npx", [
|
|
4847
|
-
"cross-env",
|
|
4848
|
-
`APP_OPERATION_MODE=${operation}`,
|
|
4849
|
-
"npx",
|
|
4850
|
-
"cap",
|
|
4851
|
-
"run",
|
|
4852
|
-
"android",
|
|
4853
|
-
"--live-reload",
|
|
4854
|
-
"--port",
|
|
4855
|
-
"4201"
|
|
4856
|
-
]);
|
|
4900
|
+
const akanConfig = await app.getConfig();
|
|
4901
|
+
const capacitorApp = await new CapacitorApp(app).init();
|
|
4902
|
+
await capacitorApp.runAndroid({ ...akanConfig.mobile, operation });
|
|
4857
4903
|
}
|
|
4858
4904
|
async releaseAndroid(app) {
|
|
4859
4905
|
const capacitorApp = new CapacitorApp(app);
|
|
@@ -5109,12 +5155,10 @@ var ApplicationScript = class {
|
|
|
5109
5155
|
app.logger.rawLog(JSON.stringify(scanResult, null, 2));
|
|
5110
5156
|
return scanResult;
|
|
5111
5157
|
}
|
|
5112
|
-
async syncApplication(app
|
|
5158
|
+
async syncApplication(app) {
|
|
5113
5159
|
const akanConfig = await this.#runner.getConfig(app);
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
await this.libraryScript.syncLibrary(LibExecutor.from(app, libName), { recursive: false });
|
|
5117
|
-
return await this.#runner.scanSync(app, akanConfig);
|
|
5160
|
+
const scanResult = await this.#runner.scanSync(app, akanConfig);
|
|
5161
|
+
return scanResult;
|
|
5118
5162
|
}
|
|
5119
5163
|
async build(app) {
|
|
5120
5164
|
await this.syncApplication(app);
|
package/esm/index.js
CHANGED
|
@@ -666,6 +666,12 @@ CMD ["npm", "start"]`,
|
|
|
666
666
|
config.frontend?.routes
|
|
667
667
|
),
|
|
668
668
|
explicitDependencies: config.frontend?.explicitDependencies ?? []
|
|
669
|
+
},
|
|
670
|
+
mobile: {
|
|
671
|
+
appName: config.mobile?.appName ?? name,
|
|
672
|
+
bundleId: config.mobile?.bundleId ?? `com.${repoName}.${name}`,
|
|
673
|
+
version: config.mobile?.version,
|
|
674
|
+
buildNum: config.mobile?.buildNum
|
|
669
675
|
}
|
|
670
676
|
};
|
|
671
677
|
};
|
|
@@ -892,9 +898,11 @@ var TypeScriptDependencyScanner = class {
|
|
|
892
898
|
|
|
893
899
|
// pkgs/@akanjs/devkit/src/executors.ts
|
|
894
900
|
var Executor = class {
|
|
901
|
+
name;
|
|
895
902
|
logger;
|
|
896
903
|
cwdPath;
|
|
897
904
|
constructor(name, cwdPath) {
|
|
905
|
+
this.name = name;
|
|
898
906
|
this.logger = new Logger(name);
|
|
899
907
|
this.cwdPath = cwdPath;
|
|
900
908
|
if (!fs6.existsSync(cwdPath))
|
|
@@ -1019,7 +1027,7 @@ var Executor = class {
|
|
|
1019
1027
|
this.logger.verbose(msg);
|
|
1020
1028
|
return this;
|
|
1021
1029
|
}
|
|
1022
|
-
getTsConfig(pathname) {
|
|
1030
|
+
getTsConfig(pathname = "tsconfig.json") {
|
|
1023
1031
|
const tsconfig = this.readJson(pathname);
|
|
1024
1032
|
if (tsconfig.extends) {
|
|
1025
1033
|
const extendsTsconfig = this.getTsConfig(tsconfig.extends);
|
|
@@ -1627,18 +1635,90 @@ var CapacitorApp = class {
|
|
|
1627
1635
|
ios: { path: "ios/App" }
|
|
1628
1636
|
});
|
|
1629
1637
|
await project.load();
|
|
1630
|
-
if (!project.android)
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1638
|
+
if (!project.android) {
|
|
1639
|
+
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
1640
|
+
await project.load();
|
|
1641
|
+
}
|
|
1642
|
+
if (!project.ios) {
|
|
1643
|
+
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
1644
|
+
await project.load();
|
|
1645
|
+
}
|
|
1636
1646
|
this.project = project;
|
|
1637
1647
|
return this;
|
|
1638
1648
|
}
|
|
1639
1649
|
async save() {
|
|
1640
1650
|
await this.project.commit();
|
|
1641
1651
|
}
|
|
1652
|
+
async #prepareIos() {
|
|
1653
|
+
const isAdded = fs8.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
1654
|
+
if (!isAdded) {
|
|
1655
|
+
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
1656
|
+
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
1657
|
+
} else
|
|
1658
|
+
this.app.verbose(`iOS already added, skip adding process`);
|
|
1659
|
+
await this.app.spawn("npx", ["cap", "sync", "ios"]);
|
|
1660
|
+
}
|
|
1661
|
+
async buildIos() {
|
|
1662
|
+
await this.#prepareIos();
|
|
1663
|
+
await this.app.spawn("npx", ["cap", "run", "ios"]);
|
|
1664
|
+
}
|
|
1665
|
+
async openIos() {
|
|
1666
|
+
await this.app.spawn("npx", ["cap", "open", "ios"]);
|
|
1667
|
+
}
|
|
1668
|
+
async runIos({ operation, bundleId, version = "0.0.1", buildNum = 1 }) {
|
|
1669
|
+
await this.#prepareIos();
|
|
1670
|
+
this.project.ios.setBundleId("App", "Debug", bundleId);
|
|
1671
|
+
this.project.ios.setBundleId("App", "Release", bundleId);
|
|
1672
|
+
await this.project.ios.setVersion("App", "Debug", version);
|
|
1673
|
+
await this.project.ios.setVersion("App", "Release", version);
|
|
1674
|
+
await this.project.ios.setBuild("App", "Debug", buildNum);
|
|
1675
|
+
await this.project.ios.setBuild("App", "Release", buildNum);
|
|
1676
|
+
await this.project.commit();
|
|
1677
|
+
await this.app.spawn("npx", [
|
|
1678
|
+
"cross-env",
|
|
1679
|
+
`APP_OPERATION_MODE=${operation}`,
|
|
1680
|
+
"npx",
|
|
1681
|
+
"cap",
|
|
1682
|
+
"run",
|
|
1683
|
+
"ios",
|
|
1684
|
+
"--live-reload",
|
|
1685
|
+
"--port",
|
|
1686
|
+
"4201"
|
|
1687
|
+
]);
|
|
1688
|
+
}
|
|
1689
|
+
async #prepareAndroid() {
|
|
1690
|
+
const isAdded = fs8.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
1691
|
+
if (!isAdded) {
|
|
1692
|
+
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
1693
|
+
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
1694
|
+
} else
|
|
1695
|
+
this.app.verbose(`Android already added, skip adding process`);
|
|
1696
|
+
await this.app.spawn("npx", ["cap", "sync", "android"]);
|
|
1697
|
+
}
|
|
1698
|
+
async buildAndroid() {
|
|
1699
|
+
await this.#prepareAndroid();
|
|
1700
|
+
await this.app.spawn("npx", ["cap", "build", "android"]);
|
|
1701
|
+
}
|
|
1702
|
+
async openAndroid() {
|
|
1703
|
+
await this.app.spawn("npx", ["cap", "open", "android"]);
|
|
1704
|
+
}
|
|
1705
|
+
async runAndroid({ operation, appName, bundleId, version = "0.0.1", buildNum = 1 }) {
|
|
1706
|
+
await this.project.android.setVersionName(version);
|
|
1707
|
+
await this.project.android.setVersionCode(buildNum);
|
|
1708
|
+
await this.project.android.setPackageName(bundleId);
|
|
1709
|
+
await this.project.android.setAppName(appName);
|
|
1710
|
+
await this.app.spawn("npx", [
|
|
1711
|
+
"cross-env",
|
|
1712
|
+
`APP_OPERATION_MODE=${operation}`,
|
|
1713
|
+
"npx",
|
|
1714
|
+
"cap",
|
|
1715
|
+
"run",
|
|
1716
|
+
"android",
|
|
1717
|
+
"--live-reload",
|
|
1718
|
+
"--port",
|
|
1719
|
+
"4201"
|
|
1720
|
+
]);
|
|
1721
|
+
}
|
|
1642
1722
|
async releaseIos() {
|
|
1643
1723
|
const isAdded = fs8.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
1644
1724
|
if (!isAdded) {
|
|
@@ -2046,6 +2126,8 @@ var runCommands = async (...commands) => {
|
|
|
2046
2126
|
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
2047
2127
|
else
|
|
2048
2128
|
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
2129
|
+
if (commandArgs[argMeta.idx] instanceof AppExecutor)
|
|
2130
|
+
process.env.NEXT_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
|
|
2049
2131
|
}
|
|
2050
2132
|
const cmd = new command();
|
|
2051
2133
|
try {
|
|
@@ -2367,11 +2449,8 @@ var LibraryScript = class {
|
|
|
2367
2449
|
lib.logger.rawLog(JSON.stringify(scanResult, null, 2));
|
|
2368
2450
|
return scanResult;
|
|
2369
2451
|
}
|
|
2370
|
-
async syncLibrary(lib
|
|
2452
|
+
async syncLibrary(lib) {
|
|
2371
2453
|
const akanConfig = await lib.getConfig();
|
|
2372
|
-
if (recursive)
|
|
2373
|
-
for (const libName of akanConfig.libs)
|
|
2374
|
-
await this.syncLibrary(LibExecutor.from(lib.workspace, libName), { recursive: false });
|
|
2375
2454
|
return await lib.scan({ akanConfig });
|
|
2376
2455
|
}
|
|
2377
2456
|
async createLibrary(libName, workspace) {
|
|
@@ -4604,7 +4683,8 @@ var ApplicationRunner = class {
|
|
|
4604
4683
|
};
|
|
4605
4684
|
}
|
|
4606
4685
|
async #prepareCommand(app, type, target) {
|
|
4607
|
-
|
|
4686
|
+
if (type === "build")
|
|
4687
|
+
await app.dist.exec(`rm -rf ${target}`);
|
|
4608
4688
|
if (target === "frontend") {
|
|
4609
4689
|
await app.exec("rm -rf .next");
|
|
4610
4690
|
app.writeFile("next.config.ts", defaultNextConfigFile);
|
|
@@ -4698,10 +4778,11 @@ var ApplicationRunner = class {
|
|
|
4698
4778
|
setTimeout(() => openBrowser("http://localhost:4200"), 3e3);
|
|
4699
4779
|
await app.spawn("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], { env });
|
|
4700
4780
|
}
|
|
4701
|
-
async #getViteConfig(app) {
|
|
4702
|
-
const { env } = await this.#prepareCommand(app,
|
|
4781
|
+
async #getViteConfig(app, command) {
|
|
4782
|
+
const { env } = await this.#prepareCommand(app, command, "csr");
|
|
4783
|
+
const tsconfig = app.workspace.getTsConfig();
|
|
4703
4784
|
const processEnv = env;
|
|
4704
|
-
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? `${app.workspace.workspaceRoot}/pkgs/` :
|
|
4785
|
+
const akanjsPrefix = process.env.USE_AKANJS_PKGS === "true" ? `${app.workspace.workspaceRoot}/pkgs/` : `${app.workspace.workspaceRoot}/pkgs/`;
|
|
4705
4786
|
const config = vite.defineConfig({
|
|
4706
4787
|
root: `${app.cwdPath}/app`,
|
|
4707
4788
|
base: "/",
|
|
@@ -4709,7 +4790,7 @@ var ApplicationRunner = class {
|
|
|
4709
4790
|
outDir: `${app.dist.cwdPath}/csr`,
|
|
4710
4791
|
sourcemap: false,
|
|
4711
4792
|
emptyOutDir: true,
|
|
4712
|
-
rollupOptions: {
|
|
4793
|
+
rollupOptions: { input: `${app.cwdPath}/app/index.html` }
|
|
4713
4794
|
},
|
|
4714
4795
|
css: { postcss: `${app.cwdPath}/postcss.config.js` },
|
|
4715
4796
|
publicDir: `${app.cwdPath}/public`,
|
|
@@ -4726,6 +4807,12 @@ var ApplicationRunner = class {
|
|
|
4726
4807
|
],
|
|
4727
4808
|
resolve: {
|
|
4728
4809
|
alias: {
|
|
4810
|
+
...Object.fromEntries(
|
|
4811
|
+
Object.entries(tsconfig.compilerOptions.paths).map(([key, value]) => [
|
|
4812
|
+
key.replace("/*", ""),
|
|
4813
|
+
`${app.workspace.workspaceRoot}/${value[0].replace("/*", "").replace("/index.ts", "")}`
|
|
4814
|
+
])
|
|
4815
|
+
),
|
|
4729
4816
|
"@akanjs/config": `${akanjsPrefix}@akanjs/config`,
|
|
4730
4817
|
"next/font/local": `${akanjsPrefix}@akanjs/client/src/createFont`,
|
|
4731
4818
|
"next/font/google": `${akanjsPrefix}@akanjs/client/src/createFont`,
|
|
@@ -4765,82 +4852,41 @@ var ApplicationRunner = class {
|
|
|
4765
4852
|
return config;
|
|
4766
4853
|
}
|
|
4767
4854
|
async buildCsr(app) {
|
|
4768
|
-
const config = await this.#getViteConfig(app);
|
|
4855
|
+
const config = await this.#getViteConfig(app, "build");
|
|
4769
4856
|
await vite.build(config);
|
|
4770
4857
|
}
|
|
4771
4858
|
async startCsr(app, { open: open2 = false } = {}) {
|
|
4772
|
-
const config = await this.#getViteConfig(app);
|
|
4859
|
+
const config = await this.#getViteConfig(app, "start");
|
|
4773
4860
|
const server = await vite.createServer(config);
|
|
4774
4861
|
await server.listen(4201);
|
|
4775
4862
|
app.log(`CSR server is running on http://localhost:4201`);
|
|
4776
4863
|
if (open2)
|
|
4777
4864
|
setTimeout(() => openBrowser("http://localhost:4201"), 3e3);
|
|
4778
4865
|
}
|
|
4779
|
-
async #prepareIos(app) {
|
|
4780
|
-
const isAdded = fs11.existsSync(`${app.cwdPath}/ios/App/Podfile`);
|
|
4781
|
-
if (!isAdded) {
|
|
4782
|
-
await app.spawn("npx", ["cap", "add", "ios"]);
|
|
4783
|
-
await app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
4784
|
-
} else
|
|
4785
|
-
app.verbose(`iOS already added, skip adding process`);
|
|
4786
|
-
await app.spawn("npx", ["cap", "sync", "ios"]);
|
|
4787
|
-
}
|
|
4788
4866
|
async buildIos(app) {
|
|
4789
|
-
await
|
|
4790
|
-
await
|
|
4867
|
+
const capacitorApp = await new CapacitorApp(app).init();
|
|
4868
|
+
await capacitorApp.buildIos();
|
|
4791
4869
|
}
|
|
4792
4870
|
async startIos(app, { open: open2 = false, operation = "local" } = {}) {
|
|
4793
|
-
await
|
|
4871
|
+
const akanConfig = await app.getConfig();
|
|
4872
|
+
const capacitorApp = await new CapacitorApp(app).init();
|
|
4873
|
+
await capacitorApp.runIos({ ...akanConfig.mobile, operation });
|
|
4794
4874
|
if (open2)
|
|
4795
|
-
await
|
|
4796
|
-
await app.spawn("npx", ["trapeze", "run", "config.yaml"]);
|
|
4797
|
-
await app.spawn("npx", [
|
|
4798
|
-
"cross-env",
|
|
4799
|
-
`APP_OPERATION_MODE=${operation}`,
|
|
4800
|
-
"npx",
|
|
4801
|
-
"cap",
|
|
4802
|
-
"run",
|
|
4803
|
-
"ios",
|
|
4804
|
-
"--live-reload",
|
|
4805
|
-
"--port",
|
|
4806
|
-
"4201"
|
|
4807
|
-
]);
|
|
4875
|
+
await capacitorApp.openIos();
|
|
4808
4876
|
}
|
|
4809
4877
|
async releaseIos(app) {
|
|
4810
4878
|
const capacitorApp = new CapacitorApp(app);
|
|
4811
4879
|
await capacitorApp.init();
|
|
4812
4880
|
await capacitorApp.releaseIos();
|
|
4813
4881
|
}
|
|
4814
|
-
async #prepareAndroid(app) {
|
|
4815
|
-
const isAdded = fs11.existsSync(`${app.cwdPath}/android/app/build.gradle`);
|
|
4816
|
-
if (!isAdded) {
|
|
4817
|
-
await app.spawn("npx", ["cap", "add", "android"]);
|
|
4818
|
-
await app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
4819
|
-
} else
|
|
4820
|
-
app.verbose(`Android already added, skip adding process`);
|
|
4821
|
-
await app.spawn("npx", ["cap", "sync", "android"]);
|
|
4822
|
-
}
|
|
4823
4882
|
async buildAndroid(app) {
|
|
4824
|
-
await
|
|
4825
|
-
await
|
|
4883
|
+
const capacitorApp = await new CapacitorApp(app).init();
|
|
4884
|
+
await capacitorApp.buildAndroid();
|
|
4826
4885
|
}
|
|
4827
4886
|
async startAndroid(app, { open: open2 = false, operation = "local" } = {}) {
|
|
4828
|
-
await
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
await app.spawn("npx", ["cap", "build", "android"]);
|
|
4832
|
-
await app.spawn("npx", ["trapeze", "run", "config.yaml"]);
|
|
4833
|
-
await app.spawn("npx", [
|
|
4834
|
-
"cross-env",
|
|
4835
|
-
`APP_OPERATION_MODE=${operation}`,
|
|
4836
|
-
"npx",
|
|
4837
|
-
"cap",
|
|
4838
|
-
"run",
|
|
4839
|
-
"android",
|
|
4840
|
-
"--live-reload",
|
|
4841
|
-
"--port",
|
|
4842
|
-
"4201"
|
|
4843
|
-
]);
|
|
4887
|
+
const akanConfig = await app.getConfig();
|
|
4888
|
+
const capacitorApp = await new CapacitorApp(app).init();
|
|
4889
|
+
await capacitorApp.runAndroid({ ...akanConfig.mobile, operation });
|
|
4844
4890
|
}
|
|
4845
4891
|
async releaseAndroid(app) {
|
|
4846
4892
|
const capacitorApp = new CapacitorApp(app);
|
|
@@ -5096,12 +5142,10 @@ var ApplicationScript = class {
|
|
|
5096
5142
|
app.logger.rawLog(JSON.stringify(scanResult, null, 2));
|
|
5097
5143
|
return scanResult;
|
|
5098
5144
|
}
|
|
5099
|
-
async syncApplication(app
|
|
5145
|
+
async syncApplication(app) {
|
|
5100
5146
|
const akanConfig = await this.#runner.getConfig(app);
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
await this.libraryScript.syncLibrary(LibExecutor.from(app, libName), { recursive: false });
|
|
5104
|
-
return await this.#runner.scanSync(app, akanConfig);
|
|
5147
|
+
const scanResult = await this.#runner.scanSync(app, akanConfig);
|
|
5148
|
+
return scanResult;
|
|
5105
5149
|
}
|
|
5106
5150
|
async build(app) {
|
|
5107
5151
|
await this.syncApplication(app);
|
package/package.json
CHANGED
|
@@ -9,9 +9,7 @@ export declare class ApplicationScript {
|
|
|
9
9
|
}): Promise<void>;
|
|
10
10
|
removeApplication(app: App): Promise<void>;
|
|
11
11
|
scanApplication(app: App, verbose?: boolean): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
12
|
-
syncApplication(app: App
|
|
13
|
-
recursive?: boolean;
|
|
14
|
-
}): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
12
|
+
syncApplication(app: App): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
15
13
|
build(app: App): Promise<void>;
|
|
16
14
|
start(app: App, { open }?: {
|
|
17
15
|
open?: boolean;
|
|
@@ -2,9 +2,7 @@ import type { Lib, Workspace } from "@akanjs/devkit";
|
|
|
2
2
|
export declare class LibraryScript {
|
|
3
3
|
#private;
|
|
4
4
|
scanLibrary(lib: Lib, verbose?: boolean): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
5
|
-
syncLibrary(lib: Lib
|
|
6
|
-
recursive?: boolean;
|
|
7
|
-
}): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
5
|
+
syncLibrary(lib: Lib): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
8
6
|
createLibrary(libName: string, workspace: Workspace): Promise<void>;
|
|
9
7
|
removeLibrary(lib: Lib): Promise<void>;
|
|
10
8
|
installLibrary(workspace: Workspace, libName: string): Promise<void>;
|