bundo-appgen 0.0.10 → 0.0.12

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.
Files changed (87) hide show
  1. package/lib/bin/bin.mjs +550 -191
  2. package/lib/module/{chunk-dvyy3g4j.js → chunk-mxb4tw3v.js} +0 -1
  3. package/lib/module/{chunk-bhc5nymd.js → chunk-z47xn1nx.js} +1 -2
  4. package/lib/module/config/apple/index.js +1 -1
  5. package/lib/module/config/index.js +2 -2
  6. package/lib/module/index.js +2 -2
  7. package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts +5 -1
  8. package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts.map +1 -1
  9. package/lib/typescript/config/apple/data.d.ts +22 -3
  10. package/lib/typescript/config/apple/data.d.ts.map +1 -1
  11. package/lib/typescript/config/apple/index.d.mts +3 -2
  12. package/lib/typescript/config/apple/index.d.mts.map +1 -1
  13. package/lib/typescript/config/apple/plist-value.d.ts +6 -0
  14. package/lib/typescript/config/apple/plist-value.d.ts.map +1 -0
  15. package/lib/typescript/config/apple/plist.d.ts +4 -0
  16. package/lib/typescript/config/apple/plist.d.ts.map +1 -0
  17. package/lib/typescript/config/apple/podfile/index.d.ts +5 -0
  18. package/lib/typescript/config/apple/podfile/index.d.ts.map +1 -0
  19. package/lib/typescript/config/apple/podfile/pod-dependency-from-cocoapods.d.ts +12 -0
  20. package/lib/typescript/config/apple/podfile/pod-dependency-from-cocoapods.d.ts.map +1 -0
  21. package/lib/typescript/config/apple/podfile/pod-dependency-from-git.d.ts +16 -0
  22. package/lib/typescript/config/apple/podfile/pod-dependency-from-git.d.ts.map +1 -0
  23. package/lib/typescript/config/apple/podfile/pod-dependency-from-local.d.ts +12 -0
  24. package/lib/typescript/config/apple/podfile/pod-dependency-from-local.d.ts.map +1 -0
  25. package/lib/typescript/config/apple/podfile/pod-dependency.d.ts +5 -0
  26. package/lib/typescript/config/apple/podfile/pod-dependency.d.ts.map +1 -0
  27. package/lib/typescript/plugin/apple/context.d.ts +1 -1
  28. package/lib/typescript/plugin/apple/context.d.ts.map +1 -1
  29. package/lib/typescript/plugin/apple/index.d.ts +0 -3
  30. package/lib/typescript/plugin/apple/index.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/src/_bin/_main/_check-config-validity.mts +10 -2
  33. package/src/_bin/_main/_helpers/config/cache-paths/asset-catalogs-tracker-file.mts +9 -0
  34. package/src/_bin/_main/_helpers/config/cache-paths/dir-cache.mts +19 -0
  35. package/src/_bin/_main/_helpers/config/cache-paths/index.mts +3 -0
  36. package/src/_bin/_main/_helpers/config/cache-paths/string-catalogs-tracker-file.mts +9 -0
  37. package/src/_bin/_main/_helpers/config/get-name.mts +1 -3
  38. package/src/_bin/_main/_helpers/config/get-project-name.mts +10 -5
  39. package/src/_bin/_main/_helpers/config/index.mts +1 -0
  40. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_get-xcassets-path.mts +29 -0
  41. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts +25 -12
  42. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-imagesets.mts +32 -13
  43. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts +214 -9
  44. package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts +159 -81
  45. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_app-delegate-swift.mts +3 -6
  46. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/_pod-dependencies.mts +78 -0
  47. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/index.mts +1 -0
  48. package/src/_bin/_main/_init-template/_init-apple/_mod-files/{_podfile.mts → _podfile/podfile.mts} +16 -4
  49. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_privacy-manifest.mts +119 -0
  50. package/src/_bin/_main/_init-template/_init-apple/_mod-files/mod-files.mts +8 -2
  51. package/src/_bin/_main/_init-template/_init-apple/init-apple.mts +13 -8
  52. package/src/_bin/_main/_init-template/init-template.mts +2 -0
  53. package/src/_bin/_main/_xcodegen/_create-project-spec/_init-resources.mts +21 -9
  54. package/src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts +51 -32
  55. package/src/_bin/_main/_xcodegen/_mod-known-regions/mod-known-regions.mts +2 -2
  56. package/src/_bin/_main/_xcodegen/xcodegen.mts +1 -1
  57. package/src/_bin/_main/main.mts +1 -1
  58. package/src/_bin/plugin-sandbox-runner/plugin-runner-context-result.ts +0 -27
  59. package/src/config/apple/asset-catalogs-namespaced.ts +1 -1
  60. package/src/config/apple/data.ts +27 -4
  61. package/src/config/apple/index.mts +3 -2
  62. package/src/config/apple/{info-plist-value.ts → plist-value.ts} +5 -4
  63. package/src/config/apple/plist.ts +6 -0
  64. package/src/config/apple/podfile/index.ts +4 -0
  65. package/src/config/apple/podfile/pod-dependency-from-cocoapods.ts +15 -0
  66. package/src/config/apple/podfile/pod-dependency-from-git.ts +23 -0
  67. package/src/config/apple/podfile/pod-dependency-from-local.ts +15 -0
  68. package/src/config/apple/podfile/pod-dependency.ts +16 -0
  69. package/src/plugin/apple/context.ts +1 -35
  70. package/src/plugin/apple/index.ts +0 -3
  71. package/template/macos/Podfile +4 -0
  72. package/template/macos/PrivacyInfo.xcprivacy +5 -0
  73. package/template/macos/pod_dependencies.rb +2 -0
  74. package/lib/typescript/config/apple/info-plist-value.d.ts +0 -8
  75. package/lib/typescript/config/apple/info-plist-value.d.ts.map +0 -1
  76. package/lib/typescript/config/apple/info-plist.d.ts +0 -4
  77. package/lib/typescript/config/apple/info-plist.d.ts.map +0 -1
  78. package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts +0 -5
  79. package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts.map +0 -1
  80. package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts +0 -11
  81. package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts.map +0 -1
  82. package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts +0 -7
  83. package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts.map +0 -1
  84. package/src/config/apple/info-plist.ts +0 -6
  85. package/src/plugin/apple/pod-spec-source-from-cocoapods.ts +0 -9
  86. package/src/plugin/apple/pod-spec-source-from-git.ts +0 -13
  87. package/src/plugin/apple/pod-spec-source-from-local.ts +0 -6
@@ -1,7 +1,22 @@
1
+ import * as node_fs from "node:fs"
2
+ import * as node_path from "node:path"
3
+
1
4
  import type {
2
5
  Config,
3
6
  } from "../../../../../index.mts"
4
7
 
8
+ import {
9
+ GlobalVars,
10
+ } from "../../../../_global-vars/index.mts"
11
+
12
+ import {
13
+ ConfigHelpers,
14
+ } from "../../../_helpers/index.mts"
15
+
16
+ import {
17
+ getXcassetsPath,
18
+ } from "./_get-xcassets-path.mts"
19
+
5
20
  import {
6
21
  initAppiconsets,
7
22
  } from "./_init-appiconsets.mts"
@@ -15,40 +30,230 @@ export function createAssetCatalogs(
15
30
  metadata: {
16
31
  bundleIdentifier: string,
17
32
  namespace?: string,
18
- platform: "macos" | "ios",
19
- projectName: string,
33
+ platform: "macos",
20
34
  },
21
35
  ) {
36
+
37
+ const
38
+ xcassetsPath =
39
+ getXcassetsPath(metadata.platform),
40
+
41
+ assetCatalogsTrackerFilePath =
42
+ ConfigHelpers.CachePaths.assetCatalogsTrackerFile()
43
+
44
+ let catalogsTracker: CatalogsTrackerSchema = {
45
+ appiconsets: undefined,
46
+ imagesets: undefined,
47
+ }
48
+
49
+ function removeAllCatalogs() {
50
+ // remove the Assets.xcassets directory including its files if any.
51
+ if(node_fs.existsSync(xcassetsPath)) {
52
+ node_fs.rmSync(
53
+ xcassetsPath,
54
+ {
55
+ recursive: true,
56
+ force: true,
57
+ },
58
+ )
59
+
60
+ // restore the Contents.json inside of the Assets.xcassets
61
+ node_fs.cpSync(
62
+ node_path.join(
63
+ GlobalVars.appgenRoot.get(),
64
+ "template",
65
+ metadata.platform,
66
+ "HelloWorld",
67
+ "Assets.xcassets",
68
+ ),
69
+ xcassetsPath,
70
+ {
71
+ recursive: true,
72
+ force: true,
73
+ },
74
+ )
75
+ }
76
+
77
+ if(node_fs.existsSync(assetCatalogsTrackerFilePath)) {
78
+ node_fs.rmSync(assetCatalogsTrackerFilePath)
79
+ }
80
+ }
81
+
22
82
  if(!assetCatalogs) {
83
+ removeAllCatalogs()
23
84
  return
24
85
  }
25
86
 
87
+ try {
88
+ if(node_fs.existsSync(assetCatalogsTrackerFilePath)) {
89
+ catalogsTracker = JSON.parse(
90
+ node_fs.readFileSync(assetCatalogsTrackerFilePath, "utf8"),
91
+ ) as CatalogsTrackerSchema
92
+ }
93
+ } catch {
94
+ // the tracker file is not a valid JSON file
95
+ // remove the Assets.xcassets directory including its files if any.
96
+ removeAllCatalogs()
97
+ }
98
+
99
+ // +++++ Create Catalog Files +++++
100
+ const newCatalogsTracker = createCatalogs(
101
+ assetCatalogs,
102
+ {
103
+ bundleIdentifier: metadata.bundleIdentifier,
104
+ platform: metadata.platform,
105
+ namespace: metadata.namespace,
106
+ },
107
+ )
108
+ // ----- Create Catalog Files -----
109
+
110
+ catalogsTracker.appiconsets?.forEach(existingCatalog => {
111
+ if(newCatalogsTracker.appiconsets?.indexOf(existingCatalog) === -1) {
112
+ const existingPath = node_path.join(xcassetsPath, existingCatalog + ".appiconset")
113
+
114
+ if(node_fs.existsSync(existingPath)) {
115
+ node_fs.rmSync(
116
+ existingPath,
117
+ {
118
+ recursive: true,
119
+ force: true,
120
+ },
121
+ )
122
+ }
123
+ }
124
+ })
125
+
126
+ catalogsTracker.imagesets?.forEach(existingCatalog => {
127
+ if(newCatalogsTracker.imagesets?.indexOf(existingCatalog) === -1) {
128
+ /**
129
+ * "Long/Ass/Namespace/Image" -> "Long"
130
+ */
131
+ const existingCatalogBasename = existingCatalog.split("/")[0]
132
+
133
+ if(!existingCatalogBasename) {
134
+ return
135
+ }
136
+
137
+ const existingPath = node_path.join(
138
+ xcassetsPath,
139
+ existingCatalogBasename,
140
+ )
141
+
142
+ if(node_fs.existsSync(existingPath)) {
143
+ // remove namespace directory
144
+ node_fs.rmSync(
145
+ existingPath,
146
+ {
147
+ recursive: true,
148
+ force: true,
149
+ },
150
+ )
151
+ } else {
152
+ const imagesetDir = node_path.join(existingCatalogBasename, ".imageset")
153
+ if(node_fs.existsSync(imagesetDir)) {
154
+ node_fs.rmSync(
155
+ imagesetDir,
156
+ {
157
+ recursive: true,
158
+ force: true,
159
+ },
160
+ )
161
+ }
162
+ }
163
+ }
164
+ })
165
+
166
+ node_fs.writeFileSync(
167
+ assetCatalogsTrackerFilePath,
168
+ JSON.stringify(newCatalogsTracker, null, 2),
169
+ "utf8",
170
+ )
171
+ }
172
+
173
+ function createCatalogs(
174
+ assetCatalogs: NonNullable<Config.Apple.Data["assetCatalogs"]>,
175
+ metadata: {
176
+ bundleIdentifier: string,
177
+ namespace?: string,
178
+ platform: "macos",
179
+ },
180
+ nextTracker?: CatalogsTrackerSchema,
181
+ ): CatalogsTrackerSchema {
182
+
183
+ const tracker: CatalogsTrackerSchema = nextTracker ?? {
184
+ appiconsets: undefined,
185
+ imagesets: undefined,
186
+ }
187
+
188
+ if(!assetCatalogs) {
189
+ return tracker
190
+ }
191
+
192
+ let isRecursived = false
193
+
26
194
  for(const _key of Object.keys(assetCatalogs)) {
27
195
  const key = _key as keyof typeof assetCatalogs
28
196
 
29
197
  if(key == "imagesets") {
30
- initImagesets(
198
+ const trackedCatalogs = initImagesets(
31
199
  assetCatalogs.imagesets,
32
200
  metadata,
33
201
  )
202
+
203
+ if(trackedCatalogs?.length) {
204
+ if(!tracker.imagesets?.length) {
205
+ tracker.imagesets = trackedCatalogs
206
+ } else {
207
+ tracker.imagesets = [
208
+ ...tracker.imagesets,
209
+ ...trackedCatalogs,
210
+ ]
211
+ }
212
+ }
34
213
  } else if(key == "appiconsets") {
35
- initAppiconsets(
36
- assetCatalogs.appiconsets,
37
- metadata,
38
- )
214
+ if(!isRecursived) {
215
+ // appiconset cannot be created under a namespace
216
+
217
+ const trackedCatalogs = initAppiconsets(
218
+ assetCatalogs.appiconsets,
219
+ metadata,
220
+ )
221
+
222
+ if(trackedCatalogs?.length) {
223
+ if(!tracker.appiconsets?.length) {
224
+ tracker.appiconsets = trackedCatalogs
225
+ } else {
226
+ tracker.appiconsets = [
227
+ ...tracker.appiconsets,
228
+ ...trackedCatalogs,
229
+ ]
230
+ }
231
+ }
232
+ }
39
233
  } else {
40
234
  // key is namespace
41
235
  const namespacedCatalogs = assetCatalogs[key] as unknown as Config.Apple.AssetCatalogs
42
236
 
43
237
  if(namespacedCatalogs && Object.keys(namespacedCatalogs).length) {
44
- createAssetCatalogs(
238
+ isRecursived = true
239
+
240
+ createCatalogs(
45
241
  namespacedCatalogs,
46
242
  {
47
243
  ...metadata,
48
- namespace: key,
244
+ namespace: metadata.namespace ? `${metadata.namespace}/${key as string}` : key,
49
245
  },
246
+ tracker,
50
247
  )
51
248
  }
52
249
  }
53
250
  }
251
+
252
+ return tracker
253
+
254
+ }
255
+
256
+ interface CatalogsTrackerSchema {
257
+ appiconsets: string[] | undefined,
258
+ imagesets: string[] | undefined,
54
259
  }
@@ -15,7 +15,7 @@ export function createStringCatalogs(
15
15
  stringCatalogs: Config.Apple.Data["stringCatalogs"],
16
16
  locales: string[] | undefined = ["en"],
17
17
  metadata: {
18
- platform: "macos" | "ios",
18
+ platform: "macos",
19
19
  },
20
20
  ) {
21
21
 
@@ -23,7 +23,7 @@ export function createStringCatalogs(
23
23
  config =
24
24
  GlobalVars.appConfig.get(),
25
25
 
26
- nativeProjectDir =
26
+ targetProjectDir =
27
27
  node_path.join(
28
28
  node_path.dirname(
29
29
  GlobalVars.configFilePath.get(),
@@ -35,100 +35,178 @@ export function createStringCatalogs(
35
35
  catalogs =
36
36
  stringCatalogs
37
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
- }
38
+ : null,
39
+
40
+ stringCatalogsTrackerFilePath =
41
+ ConfigHelpers.CachePaths.stringCatalogsTrackerFile()
42
+
43
+ let catalogsTracker: CatalogsTrackerSchema = {
44
+ catalogs: undefined,
45
+ }
46
+
47
+ if(!catalogs?.length) {
48
+ if(node_fs.existsSync(stringCatalogsTrackerFilePath)) {
49
+ node_fs.rmSync(stringCatalogsTrackerFilePath)
50
+ }
51
+
52
+ return
53
+ }
54
+
55
+ try {
56
+ catalogsTracker =
57
+ node_fs.existsSync(stringCatalogsTrackerFilePath)
58
+ ? JSON.parse(
59
+ node_fs.readFileSync(stringCatalogsTrackerFilePath, "utf8"),
60
+ ) as CatalogsTrackerSchema
61
+ : { catalogs: undefined } satisfies CatalogsTrackerSchema
62
+ } catch {
63
+ // do nothing
64
+ }
65
+
66
+ if(catalogsTracker.catalogs?.length) {
67
+ catalogsTracker.catalogs.slice().forEach((existingCatalog, index) => {
68
+ if(!stringCatalogs?.[existingCatalog]) {
69
+ const existingPath = getCatalogFilePath({
70
+ targetProjectDirectory: targetProjectDir,
71
+ catalogName: existingCatalog,
72
+ })
73
+ if(node_fs.existsSync(existingPath)) {
74
+ node_fs.rmSync(
75
+ existingPath,
76
+ {
77
+ force: true,
78
+ },
79
+ )
80
+ }
81
+
82
+ catalogsTracker.catalogs?.splice(index, 1)
83
+ }
84
+ })
85
+ }
86
+
87
+ for(const [catalogName, data] of catalogs) {
88
+ const
89
+ json: {
90
+ sourceLanguage: string,
91
+ strings: {
92
+ [Key in string]: {
93
+ extractionState: "manual",
94
+ localizations: {
95
+ [Locale in string]: {
96
+ stringUnit: {
97
+ state: "translated",
98
+ value: string,
54
99
  }
55
100
  }
56
101
  }
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
- }
102
+ }
103
+ },
104
+ version: string,
105
+ } =
106
+ {
107
+ sourceLanguage: locales[0]!,
108
+ strings: {},
109
+ version: "1.2",
110
+ },
111
+ /**
112
+ * The string key
113
+ */
114
+ keys =
115
+ Object.keys(data)
116
+
117
+ for(const key of keys) {
118
+ const localizedValue = data[key]
119
+
120
+ if(!localizedValue) {
121
+ throw new Error(`String catalog of ${catalogName} has invalid configuration.`)
122
+ }
77
123
 
78
- const localesOfValue = Object.keys(localizedValue)
124
+ const localesOfValue = Object.keys(localizedValue)
79
125
 
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
- }
126
+ {
127
+ // check language from locale
128
+ for(const localeOfValue of localesOfValue) {
129
+ if(locales.indexOf(localeOfValue) == -1) {
130
+ throw new Error(`"${localeOfValue}" was not found from your \`locales\` config. Add "${localeOfValue}" to the \`locales\` array.`)
86
131
  }
87
132
  }
133
+ }
88
134
 
89
- localesOfValue.forEach(locale => {
90
- const value = localizedValue[locale]
135
+ localesOfValue.forEach(locale => {
136
+ const value = localizedValue[locale]
91
137
 
92
- if(!value) {
93
- throw new Error(`\`stringCatalogs.${key}.${locale}\` is empty.`)
94
- }
138
+ if(!value) {
139
+ throw new Error(`\`stringCatalogs.${key}.${locale}\` is empty.`)
140
+ }
95
141
 
96
- if(!json.strings[key]) {
97
- json.strings[key] = {
98
- extractionState: "manual",
99
- localizations: {
100
- [locale]: {
101
- stringUnit: {
102
- state: "translated",
103
- value,
104
- },
142
+ if(!json.strings[key]) {
143
+ json.strings[key] = {
144
+ extractionState: "manual",
145
+ localizations: {
146
+ [locale]: {
147
+ stringUnit: {
148
+ state: "translated",
149
+ value,
105
150
  },
106
151
  },
107
- }
108
- } else {
109
- json.strings[key].localizations[locale] = {
110
- stringUnit: {
111
- state: "translated",
112
- value,
113
- },
114
- }
152
+ },
115
153
  }
116
- })
117
- }
154
+ } else {
155
+ json.strings[key].localizations[locale] = {
156
+ stringUnit: {
157
+ state: "translated",
158
+ value,
159
+ },
160
+ }
161
+ }
162
+ })
163
+ }
118
164
 
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
- )
165
+ node_fs.writeFileSync(
166
+ getCatalogFilePath({
167
+ targetProjectDirectory: targetProjectDir,
168
+ catalogName,
169
+ }),
170
+ JSON.stringify(
171
+ json,
172
+ null,
173
+ 2,
174
+ ),
175
+ "utf8",
176
+ )
177
+
178
+ if(!catalogsTracker.catalogs?.length) {
179
+ catalogsTracker.catalogs = []
180
+ }
181
+
182
+ if(catalogsTracker.catalogs.indexOf(catalogName) == -1) {
183
+ catalogsTracker.catalogs.push(catalogName)
131
184
  }
132
185
  }
133
186
 
187
+ node_fs.writeFileSync(
188
+ stringCatalogsTrackerFilePath,
189
+ JSON.stringify(catalogsTracker, null, 2),
190
+ "utf8",
191
+ )
192
+
193
+ }
194
+
195
+ interface CatalogsTrackerSchema {
196
+ /**
197
+ * The catalog / file name
198
+ */
199
+ catalogs: string[] | undefined,
200
+ }
201
+
202
+ function getCatalogFilePath(
203
+ data: {
204
+ targetProjectDirectory: string,
205
+ catalogName: string,
206
+ },
207
+ ) {
208
+ return node_path.join(
209
+ data.targetProjectDirectory,
210
+ `${data.catalogName}.xcstrings`,
211
+ )
134
212
  }
@@ -10,7 +10,7 @@ import {
10
10
  } from "../../../_helpers/index.mts"
11
11
 
12
12
  export function appDelegateSwift(
13
- platform: "macos" | "ios",
13
+ platform: "macos",
14
14
  ) {
15
15
 
16
16
  const
@@ -18,7 +18,7 @@ export function appDelegateSwift(
18
18
  GlobalVars.appConfig.get(),
19
19
 
20
20
  projectName =
21
- ConfigHelpers.getProjectName(appConfig, platform),
21
+ ConfigHelpers.getProjectName(appConfig, platform)!, // already validated
22
22
 
23
23
  appName =
24
24
  ConfigHelpers.getName(
@@ -30,10 +30,7 @@ export function appDelegateSwift(
30
30
  node_path.join(
31
31
  node_path.dirname(GlobalVars.configFilePath.get()),
32
32
  platform,
33
- ConfigHelpers.getProjectName(
34
- GlobalVars.appConfig.get(),
35
- platform,
36
- )!,
33
+ projectName,
37
34
  "AppDelegate.swift",
38
35
  )
39
36
 
@@ -0,0 +1,78 @@
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
+ export function podDependencies(
9
+ platform: "macos",
10
+ ) {
11
+
12
+ const
13
+ dependencies =
14
+ GlobalVars.appConfig.get()[platform as "macos"]?.Podfile?.dependencies,
15
+
16
+ nativeProjectDir =
17
+ node_path.join(
18
+ node_path.dirname(GlobalVars.configFilePath.get()),
19
+ platform,
20
+ )
21
+
22
+ const podDependenciesFilePath = node_path.join(nativeProjectDir, "pod_dependencies.rb")
23
+
24
+ let podDependenciesFile = "def pod_dependencies"
25
+
26
+ dependencies?.forEach(dependency => {
27
+ // start with a line break and 2 spaces
28
+ let tx = `\n pod '${dependency.name}'`
29
+
30
+ if(dependency.type == "cocoapods") {
31
+ if(dependency.version) {
32
+ tx += `, '${dependency.version}'`
33
+ }
34
+ } else if(dependency.type == "git") {
35
+ if(!dependency.url || typeof dependency.url != "string") {
36
+ throw new Error("\"gitUrl\" is empty or not a valid string for a pod spec source.")
37
+ }
38
+
39
+ tx += `, :git => '${dependency.url}'`
40
+
41
+ if(dependency.revision) {
42
+ if(
43
+ dependency.revision.type !== "branch" &&
44
+ dependency.revision.type !== "commit" &&
45
+ dependency.revision.type !== "tag"
46
+ ) {
47
+ throw new Error("Expected \"branch\", or \"commit\", or \"tag\" for the revision type.")
48
+ }
49
+
50
+ if(
51
+ typeof dependency.revision.ref != "string" ||
52
+ !dependency.revision.ref
53
+ ) {
54
+ throw new Error("Revision ref is empty or not a valid string.")
55
+ }
56
+
57
+ tx += `, :${dependency.revision.type} => '${dependency.revision.ref}'`
58
+ }
59
+ } else if(dependency.type == "local") {
60
+ if(!dependency.path || typeof dependency.path != "string") {
61
+ throw new Error("\"path\" is empty or not a valid string for a local pod.")
62
+ }
63
+
64
+ tx += `, :path => '${dependency.path}'`
65
+ }
66
+
67
+ podDependenciesFile += tx
68
+ })
69
+
70
+ podDependenciesFile += "\nend\n"
71
+
72
+ node_fs.writeFileSync(
73
+ podDependenciesFilePath,
74
+ podDependenciesFile,
75
+ "utf8",
76
+ )
77
+
78
+ }
@@ -0,0 +1 @@
1
+ export * from "./podfile.mts"
@@ -3,22 +3,32 @@ import * as node_path from "node:path"
3
3
 
4
4
  import {
5
5
  GlobalVars,
6
- } from "../../../../_global-vars/index.mts"
6
+ } from "../../../../../_global-vars/index.mts"
7
7
 
8
8
  import {
9
9
  ConfigHelpers,
10
- } from "../../../_helpers/index.mts"
10
+ } from "../../../../_helpers/index.mts"
11
+
12
+ import {
13
+ podDependencies,
14
+ } from "./_pod-dependencies.mts"
11
15
 
12
16
  export function podfile(
13
- platform: "macos" | "ios",
17
+ platform: "macos",
14
18
  ) {
15
19
 
16
20
  const
17
21
  projectName =
18
22
  ConfigHelpers.getProjectName(GlobalVars.appConfig.get(), platform)!, // already validated
19
23
 
24
+ nativeProjectDir =
25
+ node_path.join(
26
+ node_path.dirname(GlobalVars.configFilePath.get()),
27
+ platform,
28
+ ),
29
+
20
30
  podfilePath =
21
- node_path.join(node_path.dirname(GlobalVars.configFilePath.get()), platform, "Podfile")
31
+ node_path.join(nativeProjectDir, "Podfile")
22
32
 
23
33
  let
24
34
  podfileText =
@@ -28,4 +38,6 @@ export function podfile(
28
38
 
29
39
  node_fs.writeFileSync(podfilePath, podfileText, "utf8")
30
40
 
41
+ podDependencies(platform)
42
+
31
43
  }