@akanjs/devkit 1.0.20 → 2.1.0-rc.1
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/README.ko.md +65 -0
- package/README.md +62 -6
- package/aiEditor.ts +304 -0
- package/akanApp/akanApp.host.ts +393 -0
- package/akanApp/index.ts +1 -0
- package/akanConfig/akanConfig.test.ts +236 -0
- package/akanConfig/akanConfig.ts +384 -0
- package/akanConfig/index.ts +2 -0
- package/akanConfig/types.ts +23 -0
- package/applicationBuildReporter.ts +69 -0
- package/applicationBuildRunner.ts +302 -0
- package/applicationReleasePackager.ts +206 -0
- package/artifact/implicitRootLayout.ts +155 -0
- package/artifact/index.ts +1 -0
- package/artifact/routeSeedIndex.test.ts +98 -0
- package/artifact/routeSeedIndex.ts +130 -0
- package/auth.ts +41 -0
- package/builder.ts +164 -0
- package/capacitor.base.config.ts +88 -0
- package/capacitorApp.ts +440 -0
- package/commandDecorators/argMeta.ts +102 -0
- package/commandDecorators/command.ts +351 -0
- package/commandDecorators/commandBuilder.ts +224 -0
- package/commandDecorators/commandDecorators.test.ts +212 -0
- package/commandDecorators/commandMeta.ts +7 -0
- package/commandDecorators/dependencyBuilder.ts +100 -0
- package/{esm/src/commandDecorators/helpFormatter.js → commandDecorators/helpFormatter.ts} +100 -47
- package/{esm/src/commandDecorators/index.js → commandDecorators/index.ts} +4 -2
- package/commandDecorators/targetMeta.ts +31 -0
- package/commandDecorators/types.ts +10 -0
- package/constants.ts +25 -0
- package/createTunnel.ts +36 -0
- package/dependencyScanner.ts +357 -0
- package/devkitUtils.test.ts +259 -0
- package/executors.test.ts +315 -0
- package/executors.ts +1390 -0
- package/{esm/src/extractDeps.js → extractDeps.ts} +26 -20
- package/{esm/src/fileEditor.js → fileEditor.ts} +51 -32
- package/fileSys.ts +39 -0
- package/frontendBuild/allRoutesBuilder.ts +103 -0
- package/frontendBuild/buildRouteClient.test.ts +190 -0
- package/frontendBuild/clientBuildTypes.ts +114 -0
- package/frontendBuild/clientEntriesBundler.ts +303 -0
- package/frontendBuild/clientEntryDiscovery.ts +199 -0
- package/frontendBuild/csrArtifactBuilder.ts +237 -0
- package/frontendBuild/cssCompiler.ts +286 -0
- package/frontendBuild/cssImportResolver.ts +116 -0
- package/frontendBuild/fontOptimizer.ts +427 -0
- package/frontendBuild/frontendBuild.test.ts +204 -0
- package/frontendBuild/hmrChangeClassifier.ts +28 -0
- package/frontendBuild/hmrWatcher.ts +102 -0
- package/frontendBuild/index.ts +18 -0
- package/frontendBuild/pagesBundleBuilder.ts +137 -0
- package/frontendBuild/pagesEntrySourceGenerator.ts +37 -0
- package/frontendBuild/precompressArtifacts.ts +59 -0
- package/frontendBuild/routeClientBuilder.ts +290 -0
- package/frontendBuild/routesManifestArtifactSerializer.ts +62 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +139 -0
- package/frontendBuild/vendorSpecifiers.ts +16 -0
- package/frontendBuild/watchRootResolver.ts +28 -0
- package/getCredentials.ts +19 -0
- package/getDirname.ts +3 -0
- package/getModelFileData.ts +59 -0
- package/getRelatedCnsts.ts +313 -0
- package/guideline.ts +19 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +51 -0
- package/incrementalBuilder/incrementalBuilder.host.ts +152 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +331 -0
- package/incrementalBuilder/index.ts +1 -0
- package/{esm/src/index.js → index.ts} +28 -15
- package/lint/no-deep-internal-import.grit +25 -0
- package/lint/no-import-client-functions.grit +32 -0
- package/lint/no-import-external-library.grit +21 -0
- package/lint/no-js-private-class-method.grit +42 -0
- package/lint/no-use-client-in-server.grit +7 -0
- package/lint/non-scalar-props-restricted.grit +13 -0
- package/linter.ts +271 -0
- package/mobile/index.ts +1 -0
- package/mobile/mobileTarget.test.ts +53 -0
- package/mobile/mobileTarget.ts +88 -0
- package/package.json +48 -31
- package/prompter.ts +72 -0
- package/scanInfo.ts +606 -0
- package/selectModel.ts +11 -0
- package/{esm/src/spinner.js → spinner.ts} +22 -28
- package/{esm/src/capacitorApp.js → src/capacitorApp.ts} +82 -81
- package/sshTunnel.ts +152 -0
- package/{esm/src/streamAi.js → streamAi.ts} +18 -12
- package/transforms/barrelAnalyzer.ts +278 -0
- package/transforms/barrelImportsPlugin.ts +504 -0
- package/transforms/externalizeFrameworkPlugin.ts +185 -0
- package/transforms/index.ts +5 -0
- package/transforms/rscUseClientTransform.ts +59 -0
- package/transforms/transforms.test.ts +208 -0
- package/transforms/useClientBundlePlugin.ts +47 -0
- package/tsconfig.json +37 -0
- package/typeChecker.ts +264 -0
- package/types.ts +44 -0
- package/ui/MultiScrollList.tsx +242 -0
- package/ui/ScrollList.tsx +107 -0
- package/ui/index.ts +2 -0
- package/{esm/src/uploadRelease.js → uploadRelease.ts} +50 -34
- package/{esm/src/useStdoutDimensions.js → useStdoutDimensions.ts} +5 -5
- package/cjs/index.js +0 -21
- package/cjs/src/aiEditor.js +0 -311
- package/cjs/src/auth.js +0 -72
- package/cjs/src/builder.js +0 -114
- package/cjs/src/capacitorApp.js +0 -313
- package/cjs/src/commandDecorators/argMeta.js +0 -88
- package/cjs/src/commandDecorators/command.js +0 -324
- package/cjs/src/commandDecorators/commandMeta.js +0 -30
- package/cjs/src/commandDecorators/helpFormatter.js +0 -211
- package/cjs/src/commandDecorators/index.js +0 -31
- package/cjs/src/commandDecorators/targetMeta.js +0 -57
- package/cjs/src/commandDecorators/types.js +0 -15
- package/cjs/src/constants.js +0 -46
- package/cjs/src/createTunnel.js +0 -49
- package/cjs/src/dependencyScanner.js +0 -220
- package/cjs/src/executors.js +0 -964
- package/cjs/src/extractDeps.js +0 -103
- package/cjs/src/fileEditor.js +0 -120
- package/cjs/src/getCredentials.js +0 -44
- package/cjs/src/getDirname.js +0 -38
- package/cjs/src/getModelFileData.js +0 -66
- package/cjs/src/getRelatedCnsts.js +0 -260
- package/cjs/src/guideline.js +0 -15
- package/cjs/src/index.js +0 -65
- package/cjs/src/linter.js +0 -238
- package/cjs/src/prompter.js +0 -85
- package/cjs/src/scanInfo.js +0 -491
- package/cjs/src/selectModel.js +0 -46
- package/cjs/src/spinner.js +0 -93
- package/cjs/src/streamAi.js +0 -62
- package/cjs/src/typeChecker.js +0 -207
- package/cjs/src/types.js +0 -15
- package/cjs/src/uploadRelease.js +0 -112
- package/cjs/src/useStdoutDimensions.js +0 -43
- package/esm/index.js +0 -1
- package/esm/src/aiEditor.js +0 -282
- package/esm/src/auth.js +0 -42
- package/esm/src/builder.js +0 -81
- package/esm/src/commandDecorators/argMeta.js +0 -54
- package/esm/src/commandDecorators/command.js +0 -290
- package/esm/src/commandDecorators/commandMeta.js +0 -7
- package/esm/src/commandDecorators/targetMeta.js +0 -33
- package/esm/src/commandDecorators/types.js +0 -0
- package/esm/src/constants.js +0 -17
- package/esm/src/createTunnel.js +0 -26
- package/esm/src/dependencyScanner.js +0 -187
- package/esm/src/executors.js +0 -928
- package/esm/src/getCredentials.js +0 -11
- package/esm/src/getDirname.js +0 -5
- package/esm/src/getModelFileData.js +0 -33
- package/esm/src/getRelatedCnsts.js +0 -221
- package/esm/src/guideline.js +0 -0
- package/esm/src/linter.js +0 -205
- package/esm/src/prompter.js +0 -51
- package/esm/src/scanInfo.js +0 -455
- package/esm/src/selectModel.js +0 -13
- package/esm/src/typeChecker.js +0 -174
- package/esm/src/types.js +0 -0
- package/index.d.ts +0 -1
- package/src/aiEditor.d.ts +0 -50
- package/src/auth.d.ts +0 -9
- package/src/builder.d.ts +0 -18
- package/src/capacitorApp.d.ts +0 -39
- package/src/commandDecorators/argMeta.d.ts +0 -67
- package/src/commandDecorators/command.d.ts +0 -2
- package/src/commandDecorators/commandMeta.d.ts +0 -2
- package/src/commandDecorators/helpFormatter.d.ts +0 -3
- package/src/commandDecorators/index.d.ts +0 -6
- package/src/commandDecorators/targetMeta.d.ts +0 -19
- package/src/commandDecorators/types.d.ts +0 -1
- package/src/constants.d.ts +0 -26
- package/src/createTunnel.d.ts +0 -8
- package/src/dependencyScanner.d.ts +0 -23
- package/src/executors.d.ts +0 -296
- package/src/extractDeps.d.ts +0 -7
- package/src/fileEditor.d.ts +0 -16
- package/src/getCredentials.d.ts +0 -12
- package/src/getDirname.d.ts +0 -1
- package/src/getModelFileData.d.ts +0 -16
- package/src/getRelatedCnsts.d.ts +0 -53
- package/src/guideline.d.ts +0 -19
- package/src/index.d.ts +0 -23
- package/src/linter.d.ts +0 -109
- package/src/prompter.d.ts +0 -14
- package/src/scanInfo.d.ts +0 -82
- package/src/selectModel.d.ts +0 -1
- package/src/spinner.d.ts +0 -20
- package/src/streamAi.d.ts +0 -6
- package/src/typeChecker.d.ts +0 -52
- package/src/types.d.ts +0 -31
- package/src/uploadRelease.d.ts +0 -10
- package/src/useStdoutDimensions.d.ts +0 -1
package/cjs/src/capacitorApp.js
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var capacitorApp_exports = {};
|
|
29
|
-
__export(capacitorApp_exports, {
|
|
30
|
-
CapacitorApp: () => CapacitorApp
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(capacitorApp_exports);
|
|
33
|
-
var import_common = require("@akanjs/common");
|
|
34
|
-
var import_project = require("@trapezedev/project");
|
|
35
|
-
var import_fs = __toESM(require("fs"));
|
|
36
|
-
var import_fileEditor = require("./fileEditor");
|
|
37
|
-
class CapacitorApp {
|
|
38
|
-
constructor(app) {
|
|
39
|
-
this.app = app;
|
|
40
|
-
this.project = new import_project.MobileProject(this.app.cwdPath, {
|
|
41
|
-
android: { path: "android" },
|
|
42
|
-
ios: { path: "ios/App" }
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
project;
|
|
46
|
-
iosTargetName = "App";
|
|
47
|
-
async init() {
|
|
48
|
-
const project = this.project;
|
|
49
|
-
await this.project.load();
|
|
50
|
-
if (!project.android) {
|
|
51
|
-
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
52
|
-
await this.project.load();
|
|
53
|
-
}
|
|
54
|
-
if (!project.ios) {
|
|
55
|
-
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
56
|
-
await this.project.load();
|
|
57
|
-
}
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
async save() {
|
|
61
|
-
await this.project.commit();
|
|
62
|
-
}
|
|
63
|
-
async #prepareIos() {
|
|
64
|
-
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
65
|
-
if (!isAdded) {
|
|
66
|
-
await this.app.spawn("npx", ["cap", "add", "ios"]);
|
|
67
|
-
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
68
|
-
} else
|
|
69
|
-
this.app.verbose(`iOS already added, skip adding process`);
|
|
70
|
-
this.app.verbose(`syncing iOS`);
|
|
71
|
-
await this.app.spawn("npx", ["cap", "sync", "ios"]);
|
|
72
|
-
this.app.verbose(`sync completed.`);
|
|
73
|
-
}
|
|
74
|
-
async buildIos() {
|
|
75
|
-
await this.#prepareIos();
|
|
76
|
-
this.app.verbose(`build completed iOS.`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
async syncIos() {
|
|
80
|
-
await this.app.spawn("npx", ["cap", "sync", "ios"]);
|
|
81
|
-
}
|
|
82
|
-
async openIos() {
|
|
83
|
-
await this.app.spawn("npx", ["cap", "open", "ios"]);
|
|
84
|
-
}
|
|
85
|
-
async runIos({ operation, appId, version = "0.0.1", buildNum = 1, host = "local" }) {
|
|
86
|
-
const defaultAppId = `com.${this.app.name}.app`;
|
|
87
|
-
await this.#prepareIos();
|
|
88
|
-
this.project.ios.setBundleId("App", "Debug", appId ?? defaultAppId);
|
|
89
|
-
this.project.ios.setBundleId("App", "Release", appId ?? defaultAppId);
|
|
90
|
-
await this.project.ios.setVersion("App", "Debug", version);
|
|
91
|
-
await this.project.ios.setVersion("App", "Release", version);
|
|
92
|
-
await this.project.ios.setBuild("App", "Debug", buildNum);
|
|
93
|
-
await this.project.ios.setBuild("App", "Release", buildNum);
|
|
94
|
-
await this.project.commit();
|
|
95
|
-
await this.app.spawn(
|
|
96
|
-
"npx",
|
|
97
|
-
[
|
|
98
|
-
"cross-env",
|
|
99
|
-
`APP_OPERATION_MODE=${operation}`,
|
|
100
|
-
`NEXT_PUBLIC_ENV=${host}`,
|
|
101
|
-
"npx",
|
|
102
|
-
"cap",
|
|
103
|
-
"run",
|
|
104
|
-
"ios",
|
|
105
|
-
"--live-reload",
|
|
106
|
-
operation === "release" ? "" : "--live-reload",
|
|
107
|
-
operation === "release" ? "" : "--port",
|
|
108
|
-
operation === "release" ? "" : "4201"
|
|
109
|
-
],
|
|
110
|
-
{
|
|
111
|
-
stdio: "inherit"
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
async #prepareAndroid() {
|
|
116
|
-
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
117
|
-
if (!isAdded) {
|
|
118
|
-
await this.app.spawn("npx", ["cap", "add", "android"]);
|
|
119
|
-
} else
|
|
120
|
-
this.app.verbose(`Android already added, skip adding process`);
|
|
121
|
-
await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
|
|
122
|
-
await this.app.spawn("npx", ["cap", "sync", "android"]);
|
|
123
|
-
}
|
|
124
|
-
#updateAndroidBuildTypes() {
|
|
125
|
-
const appGradle = new import_fileEditor.FileEditor(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
126
|
-
const buildTypesBlock = `
|
|
127
|
-
debug {
|
|
128
|
-
applicationIdSuffix ".debug"
|
|
129
|
-
versionNameSuffix "-DEBUG"
|
|
130
|
-
debuggable true
|
|
131
|
-
minifyEnabled false
|
|
132
|
-
}
|
|
133
|
-
`;
|
|
134
|
-
const singinConfigBlock = `
|
|
135
|
-
signingConfigs {
|
|
136
|
-
debug {
|
|
137
|
-
storeFile file('debug.keystore')
|
|
138
|
-
storePassword 'android'
|
|
139
|
-
keyAlias 'androiddebugkey'
|
|
140
|
-
keyPassword 'android'
|
|
141
|
-
}
|
|
142
|
-
release {
|
|
143
|
-
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
|
|
144
|
-
storeFile file(MYAPP_RELEASE_STORE_FILE)
|
|
145
|
-
storePassword MYAPP_RELEASE_STORE_PASSWORD
|
|
146
|
-
keyAlias MYAPP_RELEASE_KEY_ALIAS
|
|
147
|
-
keyPassword MYAPP_RELEASE_KEY_PASSWORD
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
`;
|
|
152
|
-
if (appGradle.find("signingConfigs {") === -1) {
|
|
153
|
-
appGradle.insertBefore("buildTypes {", singinConfigBlock);
|
|
154
|
-
}
|
|
155
|
-
if (appGradle.find(`applicationIdSuffix ".debug"`) === -1) {
|
|
156
|
-
appGradle.insertAfter("buildTypes {", buildTypesBlock);
|
|
157
|
-
}
|
|
158
|
-
appGradle.save();
|
|
159
|
-
}
|
|
160
|
-
async buildAndroid(assembleType) {
|
|
161
|
-
await this.#prepareAndroid();
|
|
162
|
-
this.#updateAndroidBuildTypes();
|
|
163
|
-
const isWindows = process.platform === "win32";
|
|
164
|
-
const gradleCommand = isWindows ? "gradlew.bat" : "./gradlew";
|
|
165
|
-
await this.app.spawn(gradleCommand, [assembleType === "apk" ? "assembleRelease" : "bundleRelease"], {
|
|
166
|
-
stdio: "inherit",
|
|
167
|
-
cwd: `${this.app.cwdPath}/android`
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
async openAndroid() {
|
|
171
|
-
await this.app.spawn("npx", ["cap", "open", "android"]);
|
|
172
|
-
}
|
|
173
|
-
async syncAndroid() {
|
|
174
|
-
await this.#prepareAndroid();
|
|
175
|
-
this.app.log(`Sync Android Completed.`);
|
|
176
|
-
}
|
|
177
|
-
async runAndroid({ operation, appName, appId, version = "0.0.1", buildNum = 1, host = "local" }) {
|
|
178
|
-
const defaultAppId = `com.${this.app.name}.app`;
|
|
179
|
-
const defaultAppName = this.app.name;
|
|
180
|
-
await this.project.android.setVersionName(version);
|
|
181
|
-
await this.project.android.setPackageName(appId ?? defaultAppId);
|
|
182
|
-
await this.project.android.setVersionCode(buildNum);
|
|
183
|
-
const versionName = await this.project.android.getVersionName();
|
|
184
|
-
const versionCode = await this.project.android.getVersionCode();
|
|
185
|
-
await this.project.android.setAppName(appName ?? defaultAppName);
|
|
186
|
-
await this.project.commit();
|
|
187
|
-
await this.#prepareAndroid();
|
|
188
|
-
this.app.logger.info(`Running Android in ${operation} mode on ${host} host`);
|
|
189
|
-
await this.app.spawn(
|
|
190
|
-
"npx",
|
|
191
|
-
[
|
|
192
|
-
"cross-env",
|
|
193
|
-
`NEXT_PUBLIC_ENV=${host}`,
|
|
194
|
-
`APP_OPERATION_MODE=${operation}`,
|
|
195
|
-
"npx",
|
|
196
|
-
"cap",
|
|
197
|
-
"run",
|
|
198
|
-
"android",
|
|
199
|
-
operation === "release" ? "" : "--live-reload",
|
|
200
|
-
operation === "release" ? "" : "--port",
|
|
201
|
-
operation === "release" ? "" : "4201"
|
|
202
|
-
],
|
|
203
|
-
{
|
|
204
|
-
stdio: "inherit"
|
|
205
|
-
}
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
//? 릴리즈시 buildNum +1 version 파라미터 받아서 업데이트
|
|
209
|
-
async updateAndroidVersion(version, buildNum) {
|
|
210
|
-
await this.project.android.setVersionName(version);
|
|
211
|
-
await this.project.android.setVersionCode(buildNum);
|
|
212
|
-
const versionName = await this.project.android.getVersionName();
|
|
213
|
-
const versionCode = await this.project.android.getVersionCode();
|
|
214
|
-
await this.project.commit();
|
|
215
|
-
}
|
|
216
|
-
async releaseIos() {
|
|
217
|
-
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
|
|
218
|
-
if (!isAdded) {
|
|
219
|
-
await this.app.spawn("npx cap add ios");
|
|
220
|
-
await this.app.spawn("npx @capacitor/assets generate");
|
|
221
|
-
} else
|
|
222
|
-
this.app.log(`iOS already added, skip adding process`);
|
|
223
|
-
await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "ios"]);
|
|
224
|
-
}
|
|
225
|
-
async releaseAndroid() {
|
|
226
|
-
const isAdded = import_fs.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
|
|
227
|
-
if (!isAdded) {
|
|
228
|
-
await this.app.spawn("npx cap add android");
|
|
229
|
-
await this.app.spawn("npx @capacitor/assets generate");
|
|
230
|
-
} else
|
|
231
|
-
this.app.log(`android already added, skip adding process`);
|
|
232
|
-
await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "android"]);
|
|
233
|
-
}
|
|
234
|
-
async addCamera() {
|
|
235
|
-
await this.#setPermissionInIos({
|
|
236
|
-
cameraUsageDescription: "$(PRODUCT_NAME) requires access to the camera to take photos.",
|
|
237
|
-
photoAddUsageDescription: "$(PRODUCT_NAME) requires access to the photo library to take photos.",
|
|
238
|
-
photoUsageDescription: "$(PRODUCT_NAME) requires access to the photo library to take photos."
|
|
239
|
-
});
|
|
240
|
-
this.#setPermissionsInAndroid(["READ_MEDIA_IMAGES", "READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"]);
|
|
241
|
-
}
|
|
242
|
-
async addContact() {
|
|
243
|
-
await this.#setPermissionInIos({
|
|
244
|
-
contactsUsageDescription: "$(PRODUCT_NAME) requires access to the contacts to add new contacts."
|
|
245
|
-
});
|
|
246
|
-
this.#setPermissionsInAndroid(["READ_CONTACTS", "WRITE_CONTACTS"]);
|
|
247
|
-
}
|
|
248
|
-
async addLocation() {
|
|
249
|
-
await this.#setPermissionInIos({
|
|
250
|
-
locationAlwaysUsageDescription: "$(PRODUCT_NAME) requires access to the location to get the user's location.",
|
|
251
|
-
locationWhenInUseUsageDescription: "$(PRODUCT_NAME) requires access to the location to get the user's location."
|
|
252
|
-
});
|
|
253
|
-
this.#setPermissionsInAndroid(["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION"]);
|
|
254
|
-
this.#setFeaturesInAndroid(["android.hardware.location.gps"]);
|
|
255
|
-
}
|
|
256
|
-
async #setPermissionInIos(permissions) {
|
|
257
|
-
const updateNs = Object.fromEntries(
|
|
258
|
-
Object.entries(permissions).map(([key, value]) => [`NS${(0, import_common.capitalize)(key)}`, value])
|
|
259
|
-
);
|
|
260
|
-
await Promise.all([
|
|
261
|
-
this.project.ios.updateInfoPlist(this.iosTargetName, "Debug", updateNs),
|
|
262
|
-
this.project.ios.updateInfoPlist(this.iosTargetName, "Release", updateNs)
|
|
263
|
-
]);
|
|
264
|
-
}
|
|
265
|
-
#setFeaturesInAndroid(features) {
|
|
266
|
-
for (const feature of features) {
|
|
267
|
-
if (this.#hasFeatureInAndroid(feature)) {
|
|
268
|
-
this.app.logger.info(`${feature} already exists in android`);
|
|
269
|
-
return this;
|
|
270
|
-
}
|
|
271
|
-
this.app.logger.info(`Adding ${feature} to android`);
|
|
272
|
-
this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-feature android:name="${feature}" />`);
|
|
273
|
-
}
|
|
274
|
-
return this;
|
|
275
|
-
}
|
|
276
|
-
#getFeaturesInAndroid() {
|
|
277
|
-
const androidManifest = this.project.android.getAndroidManifest();
|
|
278
|
-
const element = androidManifest.getDocumentElement();
|
|
279
|
-
if (!element)
|
|
280
|
-
throw new Error("manifest not found");
|
|
281
|
-
const usesFeature = element.getElementsByTagName("uses-feature");
|
|
282
|
-
return Array.from(usesFeature).map((feature) => feature.getAttribute("android:name"));
|
|
283
|
-
}
|
|
284
|
-
#hasFeatureInAndroid(feature) {
|
|
285
|
-
return this.#getFeaturesInAndroid().includes(feature);
|
|
286
|
-
}
|
|
287
|
-
#setPermissionsInAndroid(permissions) {
|
|
288
|
-
for (const permission of permissions) {
|
|
289
|
-
if (this.#hasPermissionInAndroid(permission)) {
|
|
290
|
-
this.app.logger.info(`${permission} already exists in android`);
|
|
291
|
-
return this;
|
|
292
|
-
}
|
|
293
|
-
this.app.logger.info(`Adding ${permission} to android`);
|
|
294
|
-
this.project.android.getAndroidManifest().injectFragment("manifest", `<uses-permission android:name="android.permission.${permission}" />`);
|
|
295
|
-
}
|
|
296
|
-
return this;
|
|
297
|
-
}
|
|
298
|
-
#getPermissionsInAndroid() {
|
|
299
|
-
const androidManifest = this.project.android.getAndroidManifest();
|
|
300
|
-
const element = androidManifest.getDocumentElement();
|
|
301
|
-
if (!element)
|
|
302
|
-
throw new Error("manifest not found");
|
|
303
|
-
const usesPermission = element.getElementsByTagName("uses-permission");
|
|
304
|
-
return Array.from(usesPermission).map((permission) => permission.getAttribute("android:name"));
|
|
305
|
-
}
|
|
306
|
-
#hasPermissionInAndroid(permission) {
|
|
307
|
-
return this.#getPermissionsInAndroid().includes(permission);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
311
|
-
0 && (module.exports = {
|
|
312
|
-
CapacitorApp
|
|
313
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var argMeta_exports = {};
|
|
19
|
-
__export(argMeta_exports, {
|
|
20
|
-
App: () => App,
|
|
21
|
-
Argument: () => Argument,
|
|
22
|
-
Exec: () => Exec,
|
|
23
|
-
Lib: () => Lib,
|
|
24
|
-
Module: () => Module,
|
|
25
|
-
Option: () => Option,
|
|
26
|
-
Pkg: () => Pkg,
|
|
27
|
-
Sys: () => Sys,
|
|
28
|
-
Workspace: () => Workspace,
|
|
29
|
-
argTypes: () => argTypes,
|
|
30
|
-
getArgMetas: () => getArgMetas,
|
|
31
|
-
internalArgTypes: () => internalArgTypes
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(argMeta_exports);
|
|
34
|
-
var import_reflect_metadata = require("reflect-metadata");
|
|
35
|
-
const argTypes = ["Argument", "Option"];
|
|
36
|
-
const internalArgTypes = ["Workspace", "App", "Lib", "Sys", "Pkg", "Module", "Exec"];
|
|
37
|
-
const getArgMetas = (command, key) => {
|
|
38
|
-
const allArgMetas = getArgMetasOnPrototype(command.prototype, key);
|
|
39
|
-
const argMetas = allArgMetas.filter((argMeta) => argMeta.type === "Option");
|
|
40
|
-
const internalArgMetas = allArgMetas.filter((argMeta) => argMeta.type !== "Option");
|
|
41
|
-
return [allArgMetas, argMetas, internalArgMetas];
|
|
42
|
-
};
|
|
43
|
-
const getArgMetasOnPrototype = (prototype, key) => {
|
|
44
|
-
return Reflect.getMetadata("args", prototype, key) ?? [];
|
|
45
|
-
};
|
|
46
|
-
const setArgMetasOnPrototype = (prototype, key, argMetas) => {
|
|
47
|
-
Reflect.defineMetadata("args", argMetas, prototype, key);
|
|
48
|
-
};
|
|
49
|
-
const getArg = (type) => function(name, argsOption = {}) {
|
|
50
|
-
return function(prototype, key, idx) {
|
|
51
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
52
|
-
argMetas[idx] = { name, argsOption, key, idx, type };
|
|
53
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const Argument = getArg("Argument");
|
|
57
|
-
const Option = getArg("Option");
|
|
58
|
-
const createArgMetaDecorator = (type) => {
|
|
59
|
-
return function(option = {}) {
|
|
60
|
-
return function(prototype, key, idx) {
|
|
61
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
62
|
-
argMetas[idx] = { key, idx, type, option };
|
|
63
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const App = createArgMetaDecorator("App");
|
|
68
|
-
const Lib = createArgMetaDecorator("Lib");
|
|
69
|
-
const Sys = createArgMetaDecorator("Sys");
|
|
70
|
-
const Exec = createArgMetaDecorator("Exec");
|
|
71
|
-
const Pkg = createArgMetaDecorator("Pkg");
|
|
72
|
-
const Module = createArgMetaDecorator("Module");
|
|
73
|
-
const Workspace = createArgMetaDecorator("Workspace");
|
|
74
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
-
0 && (module.exports = {
|
|
76
|
-
App,
|
|
77
|
-
Argument,
|
|
78
|
-
Exec,
|
|
79
|
-
Lib,
|
|
80
|
-
Module,
|
|
81
|
-
Option,
|
|
82
|
-
Pkg,
|
|
83
|
-
Sys,
|
|
84
|
-
Workspace,
|
|
85
|
-
argTypes,
|
|
86
|
-
getArgMetas,
|
|
87
|
-
internalArgTypes
|
|
88
|
-
});
|