@akanjs/devkit 0.0.126 → 0.0.128
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/src/capacitorApp.js +78 -6
- package/cjs/src/commandDecorators/command.js +2 -0
- package/cjs/src/executors.js +3 -1
- package/esm/src/capacitorApp.js +78 -6
- package/esm/src/commandDecorators/command.js +2 -0
- package/esm/src/executors.js +3 -1
- package/package.json +1 -1
- package/src/capacitorApp.d.ts +14 -0
- package/src/executors.d.ts +3 -2
package/cjs/src/capacitorApp.js
CHANGED
|
@@ -45,18 +45,90 @@ class CapacitorApp {
|
|
|
45
45
|
ios: { path: "ios/App" }
|
|
46
46
|
});
|
|
47
47
|
await project.load();
|
|
48
|
-
if (!project.android)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
if (!project.android) {
|
|
49
|
+
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
50
|
+
await project.load();
|
|
51
|
+
}
|
|
52
|
+
if (!project.ios) {
|
|
53
|
+
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
54
|
+
await project.load();
|
|
55
|
+
}
|
|
54
56
|
this.project = project;
|
|
55
57
|
return this;
|
|
56
58
|
}
|
|
57
59
|
async save() {
|
|
58
60
|
await this.project.commit();
|
|
59
61
|
}
|
|
62
|
+
async #prepareIos() {
|
|
63
|
+
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
64
|
+
if (!isAdded) {
|
|
65
|
+
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
66
|
+
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
67
|
+
} else
|
|
68
|
+
this.app.verbose(`iOS already added, skip adding process`);
|
|
69
|
+
await this.app.spawn("npx", ["cap", "sync", "ios"]);
|
|
70
|
+
}
|
|
71
|
+
async buildIos() {
|
|
72
|
+
await this.#prepareIos();
|
|
73
|
+
await this.app.spawn("npx", ["cap", "run", "ios"]);
|
|
74
|
+
}
|
|
75
|
+
async openIos() {
|
|
76
|
+
await this.app.spawn("npx", ["cap", "open", "ios"]);
|
|
77
|
+
}
|
|
78
|
+
async runIos({ operation, bundleId, version = "0.0.1", buildNum = 1 }) {
|
|
79
|
+
await this.#prepareIos();
|
|
80
|
+
this.project.ios.setBundleId("App", "Debug", bundleId);
|
|
81
|
+
this.project.ios.setBundleId("App", "Release", bundleId);
|
|
82
|
+
await this.project.ios.setVersion("App", "Debug", version);
|
|
83
|
+
await this.project.ios.setVersion("App", "Release", version);
|
|
84
|
+
await this.project.ios.setBuild("App", "Debug", buildNum);
|
|
85
|
+
await this.project.ios.setBuild("App", "Release", buildNum);
|
|
86
|
+
await this.project.commit();
|
|
87
|
+
await this.app.spawn("npx", [
|
|
88
|
+
"cross-env",
|
|
89
|
+
`APP_OPERATION_MODE=${operation}`,
|
|
90
|
+
"npx",
|
|
91
|
+
"cap",
|
|
92
|
+
"run",
|
|
93
|
+
"ios",
|
|
94
|
+
"--live-reload",
|
|
95
|
+
"--port",
|
|
96
|
+
"4201"
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
async #prepareAndroid() {
|
|
100
|
+
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
101
|
+
if (!isAdded) {
|
|
102
|
+
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
103
|
+
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
104
|
+
} else
|
|
105
|
+
this.app.verbose(`Android already added, skip adding process`);
|
|
106
|
+
await this.app.spawn("npx", ["cap", "sync", "android"]);
|
|
107
|
+
}
|
|
108
|
+
async buildAndroid() {
|
|
109
|
+
await this.#prepareAndroid();
|
|
110
|
+
await this.app.spawn("npx", ["cap", "build", "android"]);
|
|
111
|
+
}
|
|
112
|
+
async openAndroid() {
|
|
113
|
+
await this.app.spawn("npx", ["cap", "open", "android"]);
|
|
114
|
+
}
|
|
115
|
+
async runAndroid({ operation, appName, bundleId, version = "0.0.1", buildNum = 1 }) {
|
|
116
|
+
await this.project.android.setVersionName(version);
|
|
117
|
+
await this.project.android.setVersionCode(buildNum);
|
|
118
|
+
await this.project.android.setPackageName(bundleId);
|
|
119
|
+
await this.project.android.setAppName(appName);
|
|
120
|
+
await this.app.spawn("npx", [
|
|
121
|
+
"cross-env",
|
|
122
|
+
`APP_OPERATION_MODE=${operation}`,
|
|
123
|
+
"npx",
|
|
124
|
+
"cap",
|
|
125
|
+
"run",
|
|
126
|
+
"android",
|
|
127
|
+
"--live-reload",
|
|
128
|
+
"--port",
|
|
129
|
+
"4201"
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
60
132
|
async releaseIos() {
|
|
61
133
|
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
62
134
|
if (!isAdded) {
|
|
@@ -191,6 +191,8 @@ const runCommands = async (...commands) => {
|
|
|
191
191
|
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
192
192
|
else
|
|
193
193
|
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
194
|
+
if (commandArgs[argMeta.idx] instanceof import_executors.AppExecutor)
|
|
195
|
+
process.env.NEXT_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
|
|
194
196
|
}
|
|
195
197
|
const cmd = new command();
|
|
196
198
|
try {
|
package/cjs/src/executors.js
CHANGED
|
@@ -45,9 +45,11 @@ var import_promises = __toESM(require("fs/promises"));
|
|
|
45
45
|
var import_path = __toESM(require("path"));
|
|
46
46
|
var import_dependencyScanner = require("./dependencyScanner");
|
|
47
47
|
class Executor {
|
|
48
|
+
name;
|
|
48
49
|
logger;
|
|
49
50
|
cwdPath;
|
|
50
51
|
constructor(name, cwdPath) {
|
|
52
|
+
this.name = name;
|
|
51
53
|
this.logger = new import_common.Logger(name);
|
|
52
54
|
this.cwdPath = cwdPath;
|
|
53
55
|
if (!import_fs.default.existsSync(cwdPath))
|
|
@@ -172,7 +174,7 @@ class Executor {
|
|
|
172
174
|
this.logger.verbose(msg);
|
|
173
175
|
return this;
|
|
174
176
|
}
|
|
175
|
-
getTsConfig(pathname) {
|
|
177
|
+
getTsConfig(pathname = "tsconfig.json") {
|
|
176
178
|
const tsconfig = this.readJson(pathname);
|
|
177
179
|
if (tsconfig.extends) {
|
|
178
180
|
const extendsTsconfig = this.getTsConfig(tsconfig.extends);
|
package/esm/src/capacitorApp.js
CHANGED
|
@@ -13,18 +13,90 @@ class CapacitorApp {
|
|
|
13
13
|
ios: { path: "ios/App" }
|
|
14
14
|
});
|
|
15
15
|
await project.load();
|
|
16
|
-
if (!project.android)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
if (!project.android) {
|
|
17
|
+
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
18
|
+
await project.load();
|
|
19
|
+
}
|
|
20
|
+
if (!project.ios) {
|
|
21
|
+
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
22
|
+
await project.load();
|
|
23
|
+
}
|
|
22
24
|
this.project = project;
|
|
23
25
|
return this;
|
|
24
26
|
}
|
|
25
27
|
async save() {
|
|
26
28
|
await this.project.commit();
|
|
27
29
|
}
|
|
30
|
+
async #prepareIos() {
|
|
31
|
+
const isAdded = fs.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
32
|
+
if (!isAdded) {
|
|
33
|
+
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
34
|
+
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
35
|
+
} else
|
|
36
|
+
this.app.verbose(`iOS already added, skip adding process`);
|
|
37
|
+
await this.app.spawn("npx", ["cap", "sync", "ios"]);
|
|
38
|
+
}
|
|
39
|
+
async buildIos() {
|
|
40
|
+
await this.#prepareIos();
|
|
41
|
+
await this.app.spawn("npx", ["cap", "run", "ios"]);
|
|
42
|
+
}
|
|
43
|
+
async openIos() {
|
|
44
|
+
await this.app.spawn("npx", ["cap", "open", "ios"]);
|
|
45
|
+
}
|
|
46
|
+
async runIos({ operation, bundleId, version = "0.0.1", buildNum = 1 }) {
|
|
47
|
+
await this.#prepareIos();
|
|
48
|
+
this.project.ios.setBundleId("App", "Debug", bundleId);
|
|
49
|
+
this.project.ios.setBundleId("App", "Release", bundleId);
|
|
50
|
+
await this.project.ios.setVersion("App", "Debug", version);
|
|
51
|
+
await this.project.ios.setVersion("App", "Release", version);
|
|
52
|
+
await this.project.ios.setBuild("App", "Debug", buildNum);
|
|
53
|
+
await this.project.ios.setBuild("App", "Release", buildNum);
|
|
54
|
+
await this.project.commit();
|
|
55
|
+
await this.app.spawn("npx", [
|
|
56
|
+
"cross-env",
|
|
57
|
+
`APP_OPERATION_MODE=${operation}`,
|
|
58
|
+
"npx",
|
|
59
|
+
"cap",
|
|
60
|
+
"run",
|
|
61
|
+
"ios",
|
|
62
|
+
"--live-reload",
|
|
63
|
+
"--port",
|
|
64
|
+
"4201"
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
async #prepareAndroid() {
|
|
68
|
+
const isAdded = fs.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
69
|
+
if (!isAdded) {
|
|
70
|
+
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
71
|
+
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
72
|
+
} else
|
|
73
|
+
this.app.verbose(`Android already added, skip adding process`);
|
|
74
|
+
await this.app.spawn("npx", ["cap", "sync", "android"]);
|
|
75
|
+
}
|
|
76
|
+
async buildAndroid() {
|
|
77
|
+
await this.#prepareAndroid();
|
|
78
|
+
await this.app.spawn("npx", ["cap", "build", "android"]);
|
|
79
|
+
}
|
|
80
|
+
async openAndroid() {
|
|
81
|
+
await this.app.spawn("npx", ["cap", "open", "android"]);
|
|
82
|
+
}
|
|
83
|
+
async runAndroid({ operation, appName, bundleId, version = "0.0.1", buildNum = 1 }) {
|
|
84
|
+
await this.project.android.setVersionName(version);
|
|
85
|
+
await this.project.android.setVersionCode(buildNum);
|
|
86
|
+
await this.project.android.setPackageName(bundleId);
|
|
87
|
+
await this.project.android.setAppName(appName);
|
|
88
|
+
await this.app.spawn("npx", [
|
|
89
|
+
"cross-env",
|
|
90
|
+
`APP_OPERATION_MODE=${operation}`,
|
|
91
|
+
"npx",
|
|
92
|
+
"cap",
|
|
93
|
+
"run",
|
|
94
|
+
"android",
|
|
95
|
+
"--live-reload",
|
|
96
|
+
"--port",
|
|
97
|
+
"4201"
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
28
100
|
async releaseIos() {
|
|
29
101
|
const isAdded = fs.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
30
102
|
if (!isAdded) {
|
|
@@ -159,6 +159,8 @@ const runCommands = async (...commands) => {
|
|
|
159
159
|
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt);
|
|
160
160
|
else
|
|
161
161
|
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
162
|
+
if (commandArgs[argMeta.idx] instanceof AppExecutor)
|
|
163
|
+
process.env.NEXT_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
|
|
162
164
|
}
|
|
163
165
|
const cmd = new command();
|
|
164
166
|
try {
|
package/esm/src/executors.js
CHANGED
|
@@ -12,9 +12,11 @@ import fsPromise from "fs/promises";
|
|
|
12
12
|
import path from "path";
|
|
13
13
|
import { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
14
14
|
class Executor {
|
|
15
|
+
name;
|
|
15
16
|
logger;
|
|
16
17
|
cwdPath;
|
|
17
18
|
constructor(name, cwdPath) {
|
|
19
|
+
this.name = name;
|
|
18
20
|
this.logger = new Logger(name);
|
|
19
21
|
this.cwdPath = cwdPath;
|
|
20
22
|
if (!fs.existsSync(cwdPath))
|
|
@@ -139,7 +141,7 @@ class Executor {
|
|
|
139
141
|
this.logger.verbose(msg);
|
|
140
142
|
return this;
|
|
141
143
|
}
|
|
142
|
-
getTsConfig(pathname) {
|
|
144
|
+
getTsConfig(pathname = "tsconfig.json") {
|
|
143
145
|
const tsconfig = this.readJson(pathname);
|
|
144
146
|
if (tsconfig.extends) {
|
|
145
147
|
const extendsTsconfig = this.getTsConfig(tsconfig.extends);
|
package/package.json
CHANGED
package/src/capacitorApp.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ import type { AppExecutor } from "@akanjs/devkit";
|
|
|
2
2
|
import { MobileProject } from "@trapezedev/project";
|
|
3
3
|
import type { AndroidProject } from "@trapezedev/project/dist/android/project";
|
|
4
4
|
import type { IosProject } from "@trapezedev/project/dist/ios/project";
|
|
5
|
+
interface RunConfig {
|
|
6
|
+
operation: "local" | "release";
|
|
7
|
+
appName: string;
|
|
8
|
+
bundleId: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
buildNum?: number;
|
|
11
|
+
}
|
|
5
12
|
export declare class CapacitorApp {
|
|
6
13
|
#private;
|
|
7
14
|
private readonly app;
|
|
@@ -13,9 +20,16 @@ export declare class CapacitorApp {
|
|
|
13
20
|
constructor(app: AppExecutor);
|
|
14
21
|
init(): Promise<this>;
|
|
15
22
|
save(): Promise<void>;
|
|
23
|
+
buildIos(): Promise<void>;
|
|
24
|
+
openIos(): Promise<void>;
|
|
25
|
+
runIos({ operation, bundleId, version, buildNum }: RunConfig): Promise<void>;
|
|
26
|
+
buildAndroid(): Promise<void>;
|
|
27
|
+
openAndroid(): Promise<void>;
|
|
28
|
+
runAndroid({ operation, appName, bundleId, version, buildNum }: RunConfig): Promise<void>;
|
|
16
29
|
releaseIos(): Promise<void>;
|
|
17
30
|
releaseAndroid(): Promise<void>;
|
|
18
31
|
addCamera(): Promise<void>;
|
|
19
32
|
addContact(): Promise<void>;
|
|
20
33
|
addLocation(): Promise<void>;
|
|
21
34
|
}
|
|
35
|
+
export {};
|
package/src/executors.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type ExecOptions, type ForkOptions, type SpawnOptions } from "child_pro
|
|
|
4
4
|
import type { PackageJson, TsConfigJson } from "./types";
|
|
5
5
|
export declare class Executor {
|
|
6
6
|
#private;
|
|
7
|
+
name: string;
|
|
7
8
|
logger: Logger;
|
|
8
9
|
cwdPath: string;
|
|
9
10
|
constructor(name: string, cwdPath: string);
|
|
@@ -28,7 +29,7 @@ export declare class Executor {
|
|
|
28
29
|
cp(srcPath: string, destPath: string): Promise<void>;
|
|
29
30
|
log(msg: string): this;
|
|
30
31
|
verbose(msg: string): this;
|
|
31
|
-
getTsConfig(pathname
|
|
32
|
+
getTsConfig(pathname?: string): TsConfigJson;
|
|
32
33
|
applyTemplate({ basePath, template, scanResult, dict, overwrite, }: {
|
|
33
34
|
basePath: string;
|
|
34
35
|
template: string;
|
|
@@ -52,7 +53,7 @@ export declare class WorkspaceExecutor extends Executor {
|
|
|
52
53
|
getBaseDevEnv(): {
|
|
53
54
|
repoName: string;
|
|
54
55
|
serveDomain: string;
|
|
55
|
-
env: "
|
|
56
|
+
env: "testing" | "local" | "debug" | "develop" | "main";
|
|
56
57
|
name?: string | undefined;
|
|
57
58
|
};
|
|
58
59
|
scan(): Promise<WorkspaceScanResult>;
|