bundo-appgen 0.0.1-beta.7
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.md +253 -0
- package/bin.mjs +21 -0
- package/lib/bin/bin.mjs +1141 -0
- package/lib/bin/plugin-sandbox-runner.mjs +105 -0
- package/lib/commonjs/index.js +125 -0
- package/lib/module/chunk-bhc5nymd.js +12 -0
- package/lib/module/chunk-dvyy3g4j.js +25 -0
- package/lib/module/chunk-ynqw05p0.js +70 -0
- package/lib/module/config/apple/create-osx-appiconset.js +6 -0
- package/lib/module/config/apple/index.js +7 -0
- package/lib/module/config/index.js +8 -0
- package/lib/module/index.js +8 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/index.d.ts +3 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/index.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/set-type.d.ts +42 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/set-type.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/size.d.ts +21 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/size.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/appearances.d.ts +13 -0
- package/lib/typescript/config/apple/asset-catalog-format/appearances.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/idiom.d.ts +5 -0
- package/lib/typescript/config/apple/asset-catalog-format/idiom.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/color-space.d.ts +2 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/color-space.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/compression-type.d.ts +2 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/compression-type.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/display-gamut.d.ts +2 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/display-gamut.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/index.d.ts +6 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/index.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/language-direction.d.ts +2 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/language-direction.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/scale.d.ts +9 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/scale.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/set-type.d.ts +58 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/set-type.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/index.d.ts +5 -0
- package/lib/typescript/config/apple/asset-catalog-format/index.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts +5 -0
- package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalogs.d.ts +73 -0
- package/lib/typescript/config/apple/asset-catalogs.d.ts.map +1 -0
- package/lib/typescript/config/apple/create-osx-appiconset.d.mts +72 -0
- package/lib/typescript/config/apple/create-osx-appiconset.d.mts.map +1 -0
- package/lib/typescript/config/apple/data.d.ts +103 -0
- package/lib/typescript/config/apple/data.d.ts.map +1 -0
- package/lib/typescript/config/apple/index.d.mts +8 -0
- package/lib/typescript/config/apple/index.d.mts.map +1 -0
- package/lib/typescript/config/apple/info-plist-value.d.ts +8 -0
- package/lib/typescript/config/apple/info-plist-value.d.ts.map +1 -0
- package/lib/typescript/config/apple/info-plist.d.ts +4 -0
- package/lib/typescript/config/apple/info-plist.d.ts.map +1 -0
- package/lib/typescript/config/apple/string-catalog.d.ts +2 -0
- package/lib/typescript/config/apple/string-catalog.d.ts.map +1 -0
- package/lib/typescript/config/data.d.ts +50 -0
- package/lib/typescript/config/data.d.ts.map +1 -0
- package/lib/typescript/config/index.d.mts +5 -0
- package/lib/typescript/config/index.d.mts.map +1 -0
- package/lib/typescript/config/plugin-item.d.ts +2 -0
- package/lib/typescript/config/plugin-item.d.ts.map +1 -0
- package/lib/typescript/config/plugin-registry.d.ts +3 -0
- package/lib/typescript/config/plugin-registry.d.ts.map +1 -0
- package/lib/typescript/index.d.mts +3 -0
- package/lib/typescript/index.d.mts.map +1 -0
- package/lib/typescript/plugin/apple/context.d.ts +28 -0
- package/lib/typescript/plugin/apple/context.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/files.d.ts +7 -0
- package/lib/typescript/plugin/apple/files.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/index.d.ts +6 -0
- package/lib/typescript/plugin/apple/index.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts +5 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts +11 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts +7 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts.map +1 -0
- package/lib/typescript/plugin/context.d.ts +9 -0
- package/lib/typescript/plugin/context.d.ts.map +1 -0
- package/lib/typescript/plugin/index.d.ts +3 -0
- package/lib/typescript/plugin/index.d.ts.map +1 -0
- package/package.json +49 -0
- package/src/_bin/_global-vars/_global-vars.mts +47 -0
- package/src/_bin/_global-vars/index.mts +30 -0
- package/src/_bin/_main/_check-config-validity.mts +94 -0
- package/src/_bin/_main/_evaluate-plugin-registry.mts +181 -0
- package/src/_bin/_main/_exec-plugin-runner/_spawn-plugin-sandbox-runner.mts +149 -0
- package/src/_bin/_main/_exec-plugin-runner/exec-plugin-runner.mts +92 -0
- package/src/_bin/_main/_exec-plugin-runner/index.mts +1 -0
- package/src/_bin/_main/_get-config.mts +64 -0
- package/src/_bin/_main/_helpers/config/get-name.mts +24 -0
- package/src/_bin/_main/_helpers/config/get-project-name.mts +27 -0
- package/src/_bin/_main/_helpers/config/index.mts +2 -0
- package/src/_bin/_main/_helpers/index.mts +2 -0
- package/src/_bin/_main/_helpers/platform/compatibility-error.mts +7 -0
- package/src/_bin/_main/_helpers/platform/data.ts +9 -0
- package/src/_bin/_main/_helpers/platform/get-data.mts +48 -0
- package/src/_bin/_main/_helpers/platform/index.mts +4 -0
- package/src/_bin/_main/_helpers/platform/is-compatible.mts +30 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts +223 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-imagesets.mts +241 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/appearances.mts +24 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/idiom.mts +22 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/compression-type.mts +15 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/display-gamut.mts +12 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/index.mts +3 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/language-direction.mts +12 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/index.mts +3 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts +54 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts +134 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/_app-delegate-swift.mts +62 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile.mts +31 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/mod-files.mts +17 -0
- package/src/_bin/_main/_init-template/_init-apple/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/init-apple.mts +81 -0
- package/src/_bin/_main/_init-template/index.mts +1 -0
- package/src/_bin/_main/_init-template/init-template.mts +39 -0
- package/src/_bin/_main/_mod-plugin/index.mts +1 -0
- package/src/_bin/_main/_mod-plugin/mod-plugin.mts +77 -0
- package/src/_bin/_main/_xcodegen/_create-project-spec/_init-resources.mts +86 -0
- package/src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts +216 -0
- package/src/_bin/_main/_xcodegen/_create-project-spec/index.mts +1 -0
- package/src/_bin/_main/_xcodegen/_mod-known-regions/index.ts +1 -0
- package/src/_bin/_main/_xcodegen/_mod-known-regions/mod-known-regions.mts +52 -0
- package/src/_bin/_main/_xcodegen/index.mts +1 -0
- package/src/_bin/_main/_xcodegen/xcodegen.mts +46 -0
- package/src/_bin/_main/index.mts +1 -0
- package/src/_bin/_main/main.mts +160 -0
- package/src/_bin/bin.mts +68 -0
- package/src/_bin/plugin-sandbox-runner/_exec-plugins.mts +135 -0
- package/src/_bin/plugin-sandbox-runner/argv-json.ts +20 -0
- package/src/_bin/plugin-sandbox-runner/evaluated-plugin-registry.ts +12 -0
- package/src/_bin/plugin-sandbox-runner/index.ts +3 -0
- package/src/_bin/plugin-sandbox-runner/plugin-runner-context-result.ts +33 -0
- package/src/_bin/plugin-sandbox-runner/plugin-sandbox-runner.mts +68 -0
- package/src/config/apple/asset-catalog-format/app-icon/index.ts +2 -0
- package/src/config/apple/asset-catalog-format/app-icon/set-type.ts +59 -0
- package/src/config/apple/asset-catalog-format/app-icon/size.ts +37 -0
- package/src/config/apple/asset-catalog-format/appearances.ts +10 -0
- package/src/config/apple/asset-catalog-format/idiom.ts +16 -0
- package/src/config/apple/asset-catalog-format/image/color-space.ts +3 -0
- package/src/config/apple/asset-catalog-format/image/compression-type.ts +6 -0
- package/src/config/apple/asset-catalog-format/image/display-gamut.ts +3 -0
- package/src/config/apple/asset-catalog-format/image/index.ts +6 -0
- package/src/config/apple/asset-catalog-format/image/language-direction.ts +3 -0
- package/src/config/apple/asset-catalog-format/image/scale.ts +11 -0
- package/src/config/apple/asset-catalog-format/image/set-type.ts +85 -0
- package/src/config/apple/asset-catalog-format/index.ts +4 -0
- package/src/config/apple/asset-catalogs-namespaced.ts +13 -0
- package/src/config/apple/asset-catalogs.ts +76 -0
- package/src/config/apple/create-osx-appiconset.mts +135 -0
- package/src/config/apple/data.ts +123 -0
- package/src/config/apple/index.mts +7 -0
- package/src/config/apple/info-plist-value.ts +16 -0
- package/src/config/apple/info-plist.ts +6 -0
- package/src/config/apple/string-catalog.ts +0 -0
- package/src/config/data.ts +59 -0
- package/src/config/index.mts +4 -0
- package/src/config/plugin-item.ts +4 -0
- package/src/config/plugin-registry.ts +5 -0
- package/src/index.mts +2 -0
- package/src/plugin/apple/context.ts +68 -0
- package/src/plugin/apple/files.ts +14 -0
- package/src/plugin/apple/index.ts +5 -0
- package/src/plugin/apple/pod-spec-source-from-cocoapods.ts +9 -0
- package/src/plugin/apple/pod-spec-source-from-git.ts +13 -0
- package/src/plugin/apple/pod-spec-source-from-local.ts +6 -0
- package/src/plugin/context.ts +12 -0
- package/src/plugin/index.ts +2 -0
package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as node_fs from "node:fs"
|
|
2
|
+
import * as node_path from "node:path"
|
|
3
|
+
|
|
4
|
+
import type * as Config from "../../../../../config/index.mts"
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
GlobalVars,
|
|
8
|
+
} from "../../../../_global-vars/index.mts"
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ConfigHelpers,
|
|
12
|
+
} from "../../../_helpers/index.mts"
|
|
13
|
+
|
|
14
|
+
export function createStringCatalogs(
|
|
15
|
+
stringCatalogs: Config.Apple.Data["stringCatalogs"],
|
|
16
|
+
locales: string[] | undefined = ["en"],
|
|
17
|
+
metadata: {
|
|
18
|
+
platform: "macos" | "ios",
|
|
19
|
+
},
|
|
20
|
+
) {
|
|
21
|
+
|
|
22
|
+
const
|
|
23
|
+
config =
|
|
24
|
+
GlobalVars.appConfig.get(),
|
|
25
|
+
|
|
26
|
+
nativeProjectDir =
|
|
27
|
+
node_path.join(
|
|
28
|
+
node_path.dirname(
|
|
29
|
+
GlobalVars.configFilePath.get(),
|
|
30
|
+
),
|
|
31
|
+
metadata.platform,
|
|
32
|
+
ConfigHelpers.getProjectName(config, metadata.platform)!,
|
|
33
|
+
),
|
|
34
|
+
|
|
35
|
+
catalogs =
|
|
36
|
+
stringCatalogs
|
|
37
|
+
? Object.entries(stringCatalogs)
|
|
38
|
+
: null
|
|
39
|
+
|
|
40
|
+
if(catalogs?.length) {
|
|
41
|
+
for(const [catalogName, data] of catalogs) {
|
|
42
|
+
const
|
|
43
|
+
json: {
|
|
44
|
+
sourceLanguage: string,
|
|
45
|
+
strings: {
|
|
46
|
+
[Key in string]: {
|
|
47
|
+
extractionState: "manual",
|
|
48
|
+
localizations: {
|
|
49
|
+
[Locale in string]: {
|
|
50
|
+
stringUnit: {
|
|
51
|
+
state: "translated",
|
|
52
|
+
value: string,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
version: string,
|
|
59
|
+
} =
|
|
60
|
+
{
|
|
61
|
+
sourceLanguage: locales[0]!,
|
|
62
|
+
strings: {},
|
|
63
|
+
version: "1.2",
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* The string key
|
|
67
|
+
*/
|
|
68
|
+
keys =
|
|
69
|
+
Object.keys(data)
|
|
70
|
+
|
|
71
|
+
for(const key of keys) {
|
|
72
|
+
const localizedValue = data[key]
|
|
73
|
+
|
|
74
|
+
if(!localizedValue) {
|
|
75
|
+
throw new Error(`String catalog of ${catalogName} has invalid configuration.`)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const localesOfValue = Object.keys(localizedValue)
|
|
79
|
+
|
|
80
|
+
{
|
|
81
|
+
// check language from locale
|
|
82
|
+
for(const localeOfValue of localesOfValue) {
|
|
83
|
+
if(locales.indexOf(localeOfValue) == -1) {
|
|
84
|
+
throw new Error(`"${localeOfValue}" was not found from your \`locales\` config. Add "${localeOfValue}" to the \`locales\` array.`)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
localesOfValue.forEach(locale => {
|
|
90
|
+
const value = localizedValue[locale]
|
|
91
|
+
|
|
92
|
+
if(!value) {
|
|
93
|
+
throw new Error(`\`stringCatalogs.${key}.${locale}\` is empty.`)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if(!json.strings[key]) {
|
|
97
|
+
json.strings[key] = {
|
|
98
|
+
extractionState: "manual",
|
|
99
|
+
localizations: {
|
|
100
|
+
[locale]: {
|
|
101
|
+
stringUnit: {
|
|
102
|
+
state: "translated",
|
|
103
|
+
value,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
json.strings[key].localizations[locale] = {
|
|
110
|
+
stringUnit: {
|
|
111
|
+
state: "translated",
|
|
112
|
+
value,
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
node_fs.writeFileSync(
|
|
120
|
+
node_path.join(
|
|
121
|
+
nativeProjectDir,
|
|
122
|
+
`${catalogName}.xcstrings`,
|
|
123
|
+
),
|
|
124
|
+
JSON.stringify(
|
|
125
|
+
json,
|
|
126
|
+
null,
|
|
127
|
+
2,
|
|
128
|
+
),
|
|
129
|
+
"utf8",
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./create-string-catalog.mts"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as node_fs from "node:fs"
|
|
2
|
+
import * as node_path from "node:path"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GlobalVars,
|
|
6
|
+
} from "../../../../_global-vars/index.mts"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ConfigHelpers,
|
|
10
|
+
} from "../../../_helpers/index.mts"
|
|
11
|
+
|
|
12
|
+
export function appDelegateSwift(
|
|
13
|
+
platform: "macos" | "ios",
|
|
14
|
+
) {
|
|
15
|
+
|
|
16
|
+
const
|
|
17
|
+
appConfig =
|
|
18
|
+
GlobalVars.appConfig.get(),
|
|
19
|
+
|
|
20
|
+
projectName =
|
|
21
|
+
ConfigHelpers.getProjectName(appConfig, platform),
|
|
22
|
+
|
|
23
|
+
appName =
|
|
24
|
+
ConfigHelpers.getName(
|
|
25
|
+
appConfig,
|
|
26
|
+
platform,
|
|
27
|
+
)!,
|
|
28
|
+
|
|
29
|
+
appDelegateSwiftFilePath =
|
|
30
|
+
node_path.join(
|
|
31
|
+
node_path.dirname(GlobalVars.configFilePath.get()),
|
|
32
|
+
platform,
|
|
33
|
+
ConfigHelpers.getProjectName(
|
|
34
|
+
GlobalVars.appConfig.get(),
|
|
35
|
+
platform,
|
|
36
|
+
)!,
|
|
37
|
+
"AppDelegate.swift",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
let
|
|
41
|
+
appDelegateSwiftText =
|
|
42
|
+
node_fs.readFileSync(
|
|
43
|
+
appDelegateSwiftFilePath,
|
|
44
|
+
"utf8",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
appDelegateSwiftText = appDelegateSwiftText
|
|
48
|
+
.replace(/Window\("HelloWorld"/, `Window("${appName}"`)
|
|
49
|
+
|
|
50
|
+
appDelegateSwiftText = appDelegateSwiftText
|
|
51
|
+
.replace(
|
|
52
|
+
/factory.rootViewFactory.view\(withModuleName: "HelloWorld"/,
|
|
53
|
+
`factory.rootViewFactory.view(withModuleName: "${projectName}"`,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
node_fs.writeFileSync(
|
|
57
|
+
appDelegateSwiftFilePath,
|
|
58
|
+
appDelegateSwiftText,
|
|
59
|
+
"utf8",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as node_fs from "node:fs"
|
|
2
|
+
import * as node_path from "node:path"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GlobalVars,
|
|
6
|
+
} from "../../../../_global-vars/index.mts"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ConfigHelpers,
|
|
10
|
+
} from "../../../_helpers/index.mts"
|
|
11
|
+
|
|
12
|
+
export function podfile(
|
|
13
|
+
platform: "macos" | "ios",
|
|
14
|
+
) {
|
|
15
|
+
|
|
16
|
+
const
|
|
17
|
+
projectName =
|
|
18
|
+
ConfigHelpers.getProjectName(GlobalVars.appConfig.get(), platform)!, // already validated
|
|
19
|
+
|
|
20
|
+
podfilePath =
|
|
21
|
+
node_path.join(node_path.dirname(GlobalVars.configFilePath.get()), platform, "Podfile")
|
|
22
|
+
|
|
23
|
+
let
|
|
24
|
+
podfileText =
|
|
25
|
+
node_fs.readFileSync(podfilePath, "utf8")
|
|
26
|
+
|
|
27
|
+
podfileText = podfileText.replace(/(target) 'HelloWorld' (do)/, `$1 '${projectName}' $2`)
|
|
28
|
+
|
|
29
|
+
node_fs.writeFileSync(podfilePath, podfileText, "utf8")
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./mod-files.mts"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appDelegateSwift,
|
|
3
|
+
} from "./_app-delegate-swift.mts"
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
podfile,
|
|
7
|
+
} from "./_podfile.mts"
|
|
8
|
+
|
|
9
|
+
export function modFiles(
|
|
10
|
+
platform: "macos" | "ios",
|
|
11
|
+
) {
|
|
12
|
+
|
|
13
|
+
appDelegateSwift(platform)
|
|
14
|
+
|
|
15
|
+
podfile(platform)
|
|
16
|
+
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./init-apple.mts"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as node_fs from "node:fs"
|
|
2
|
+
import * as node_path from "node:path"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GlobalVars,
|
|
6
|
+
} from "../../../_global-vars/index.mts"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ConfigHelpers,
|
|
10
|
+
} from "../../_helpers/index.mts"
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
createAssetCatalogs,
|
|
14
|
+
} from "./_create-asset-catalogs/index.mts"
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
createStringCatalogs,
|
|
18
|
+
} from "./_create-string-catalogs/create-string-catalog.mts"
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
modFiles,
|
|
22
|
+
} from "./_mod-files/index.mts"
|
|
23
|
+
|
|
24
|
+
export function initApple(
|
|
25
|
+
platform: "macos" | "ios",
|
|
26
|
+
) {
|
|
27
|
+
const
|
|
28
|
+
// config.macos is already checked at bundo-appgen/src/_bin/_main/main.mts
|
|
29
|
+
config =
|
|
30
|
+
GlobalVars.appConfig.get(),
|
|
31
|
+
|
|
32
|
+
projectDirectory =
|
|
33
|
+
node_path.dirname(GlobalVars.configFilePath.get()),
|
|
34
|
+
|
|
35
|
+
nativeProjectDirectory =
|
|
36
|
+
node_path.join(projectDirectory, platform),
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* - bundo-appgen/template/macos
|
|
40
|
+
* - bundo-appgen/template/windows
|
|
41
|
+
*/
|
|
42
|
+
templateDir =
|
|
43
|
+
node_path.join(GlobalVars.appgenRoot.get(), "template", platform),
|
|
44
|
+
|
|
45
|
+
projectName =
|
|
46
|
+
ConfigHelpers.getProjectName(config, platform)! // config object is already validated
|
|
47
|
+
|
|
48
|
+
if(!node_fs.existsSync(nativeProjectDirectory)) {
|
|
49
|
+
// TODO : cache strategy
|
|
50
|
+
// copy the template directory to the user project directory
|
|
51
|
+
node_fs.cpSync(templateDir, nativeProjectDirectory, { recursive: true })
|
|
52
|
+
|
|
53
|
+
node_fs.renameSync(
|
|
54
|
+
node_path.join(nativeProjectDirectory, "HelloWorld"),
|
|
55
|
+
node_path.join(nativeProjectDirectory, projectName),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
modFiles(platform)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Intentionally asserted as "macos"
|
|
62
|
+
// TODO : "ios"
|
|
63
|
+
const appleData = config[platform as "macos"]!
|
|
64
|
+
|
|
65
|
+
createAssetCatalogs(
|
|
66
|
+
appleData.assetCatalogs,
|
|
67
|
+
{
|
|
68
|
+
bundleIdentifier: appleData.bundleIdentifier,
|
|
69
|
+
platform,
|
|
70
|
+
projectName,
|
|
71
|
+
},
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
createStringCatalogs(
|
|
75
|
+
appleData.stringCatalogs,
|
|
76
|
+
appleData.locales,
|
|
77
|
+
{
|
|
78
|
+
platform,
|
|
79
|
+
},
|
|
80
|
+
)
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./init-template.mts"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as node_fs from "node:fs"
|
|
2
|
+
import * as node_path from "node:path"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GlobalVars,
|
|
6
|
+
} from "../../_global-vars/index.mts"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
initApple,
|
|
10
|
+
} from "./_init-apple/index.mts"
|
|
11
|
+
|
|
12
|
+
export function initTemplate() {
|
|
13
|
+
// config object is already checked at ../main.mts
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
if(process.platform == "darwin") {
|
|
17
|
+
initApple("macos")
|
|
18
|
+
} else if(process.platform == "win32") {
|
|
19
|
+
// TODO windows
|
|
20
|
+
} else {
|
|
21
|
+
// cross platform
|
|
22
|
+
initApple("macos")
|
|
23
|
+
}
|
|
24
|
+
} catch(err) {
|
|
25
|
+
// Delete the project templated directory
|
|
26
|
+
const
|
|
27
|
+
projectDirectory =
|
|
28
|
+
node_path.dirname(GlobalVars.configFilePath.get()),
|
|
29
|
+
|
|
30
|
+
projectMacosDir =
|
|
31
|
+
node_path.join(projectDirectory, "macos")
|
|
32
|
+
|
|
33
|
+
if(node_fs.existsSync(projectMacosDir)) {
|
|
34
|
+
node_fs.rmSync(projectMacosDir, { recursive: true, force: true })
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
throw err
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./mod-plugin.mts"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as node_fs from "node:fs"
|
|
2
|
+
import * as node_path from "node:path"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
GlobalVars,
|
|
6
|
+
} from "../../_global-vars/index.mts"
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
PluginRunnerContextResult,
|
|
10
|
+
} from "../../plugin-sandbox-runner/index.ts"
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
ConfigHelpers,
|
|
14
|
+
} from "../_helpers/index.mts"
|
|
15
|
+
|
|
16
|
+
export function modPlugin(
|
|
17
|
+
contextResult: PluginRunnerContextResult,
|
|
18
|
+
) {
|
|
19
|
+
|
|
20
|
+
const
|
|
21
|
+
config =
|
|
22
|
+
GlobalVars.appConfig.get(),
|
|
23
|
+
|
|
24
|
+
projectDirectory =
|
|
25
|
+
node_path.dirname(
|
|
26
|
+
GlobalVars.configFilePath.get(),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
{
|
|
30
|
+
// TODO : ios
|
|
31
|
+
|
|
32
|
+
const
|
|
33
|
+
projectName =
|
|
34
|
+
ConfigHelpers.getProjectName(config, "macos")!, // already validated
|
|
35
|
+
|
|
36
|
+
nativeProjectDir =
|
|
37
|
+
node_path.join(projectDirectory, "macos")
|
|
38
|
+
|
|
39
|
+
node_fs.writeFileSync(
|
|
40
|
+
node_path.join(
|
|
41
|
+
nativeProjectDir,
|
|
42
|
+
projectName,
|
|
43
|
+
"AppDelegate.swift",
|
|
44
|
+
),
|
|
45
|
+
contextResult.macos.files.Project["AppDelegate.swift"],
|
|
46
|
+
"utf8",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
// if(contextResult.macos.files.Project.pluginFiles.length) {
|
|
50
|
+
// contextResult.macos.files.Project.pluginFiles.forEach(pluginFile => {
|
|
51
|
+
// node_fs.writeFileSync(
|
|
52
|
+
// node_path.join(nativeProjectDir, projectName, pluginFile.filename),
|
|
53
|
+
// pluginFile.source,
|
|
54
|
+
// "utf8",
|
|
55
|
+
// )
|
|
56
|
+
// })
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
node_fs.writeFileSync(
|
|
60
|
+
node_path.join(nativeProjectDir, "Podfile"),
|
|
61
|
+
contextResult.macos.files.Podfile,
|
|
62
|
+
"utf8",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
// if(contextResult.macos.files.pluginFiles.length) {
|
|
66
|
+
// contextResult.macos.files.pluginFiles.forEach(pluginFile => {
|
|
67
|
+
// node_fs.writeFileSync(
|
|
68
|
+
// node_path.join(nativeProjectDir, pluginFile.filename),
|
|
69
|
+
// pluginFile.source,
|
|
70
|
+
// "utf8",
|
|
71
|
+
// )
|
|
72
|
+
// })
|
|
73
|
+
// }
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as node_fs from "node:fs"
|
|
2
|
+
import * as node_path from "node:path"
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
Config,
|
|
6
|
+
} from "../../../../index.mts"
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
GlobalVars,
|
|
10
|
+
} from "../../../_global-vars/index.mts"
|
|
11
|
+
|
|
12
|
+
export function initResources(
|
|
13
|
+
resources: Config.Apple.Data["resources"],
|
|
14
|
+
metadata: {
|
|
15
|
+
platform: "macos" | "ios",
|
|
16
|
+
},
|
|
17
|
+
): {
|
|
18
|
+
basename: string,
|
|
19
|
+
isDirectory: boolean,
|
|
20
|
+
}[] | null {
|
|
21
|
+
|
|
22
|
+
if(!resources?.length) {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const
|
|
27
|
+
projectDirectory =
|
|
28
|
+
node_path.dirname(
|
|
29
|
+
GlobalVars.configFilePath.get(),
|
|
30
|
+
),
|
|
31
|
+
|
|
32
|
+
resourcesDirectory =
|
|
33
|
+
node_path.join(
|
|
34
|
+
projectDirectory,
|
|
35
|
+
metadata.platform,
|
|
36
|
+
"Resources",
|
|
37
|
+
),
|
|
38
|
+
|
|
39
|
+
data: NonNullable<ReturnType<typeof initResources>> =
|
|
40
|
+
[]
|
|
41
|
+
|
|
42
|
+
node_fs.rmSync(resourcesDirectory, { recursive: true, force: true })
|
|
43
|
+
node_fs.mkdirSync(resourcesDirectory)
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
for(const resource of resources) {
|
|
47
|
+
let path = node_path.resolve(projectDirectory, resource)
|
|
48
|
+
|
|
49
|
+
if(!node_fs.existsSync(path)) {
|
|
50
|
+
throw new Error(`The ${path} was not found.`)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const lstat = node_fs.lstatSync(path)
|
|
54
|
+
|
|
55
|
+
if(lstat.isSymbolicLink()) {
|
|
56
|
+
path = node_fs.realpathSync(path)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log(`\x1b[32mCopying resource\x1b[0m \x1b[36m${path}\x1b[0m`)
|
|
60
|
+
|
|
61
|
+
node_fs.cpSync(
|
|
62
|
+
path,
|
|
63
|
+
node_path.join(
|
|
64
|
+
resourcesDirectory,
|
|
65
|
+
node_path.basename(path),
|
|
66
|
+
),
|
|
67
|
+
{
|
|
68
|
+
recursive: true,
|
|
69
|
+
force: true,
|
|
70
|
+
},
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
data.push({
|
|
74
|
+
basename: node_path.basename(path),
|
|
75
|
+
isDirectory: lstat.isDirectory(),
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
} catch(err) {
|
|
79
|
+
// remove the resources directory upon error
|
|
80
|
+
node_fs.rmSync(resourcesDirectory, { force: true, recursive: true })
|
|
81
|
+
throw err
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return data
|
|
85
|
+
|
|
86
|
+
}
|