bundo-appgen 0.0.9 → 0.0.11

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 (88) hide show
  1. package/README.md +4 -6
  2. package/lib/bin/bin.mjs +546 -191
  3. package/lib/module/{chunk-dvyy3g4j.js → chunk-mxb4tw3v.js} +0 -1
  4. package/lib/module/{chunk-bhc5nymd.js → chunk-z47xn1nx.js} +1 -2
  5. package/lib/module/config/apple/index.js +1 -1
  6. package/lib/module/config/index.js +2 -2
  7. package/lib/module/index.js +2 -2
  8. package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts +5 -1
  9. package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts.map +1 -1
  10. package/lib/typescript/config/apple/data.d.ts +22 -3
  11. package/lib/typescript/config/apple/data.d.ts.map +1 -1
  12. package/lib/typescript/config/apple/index.d.mts +3 -2
  13. package/lib/typescript/config/apple/index.d.mts.map +1 -1
  14. package/lib/typescript/config/apple/plist-value.d.ts +6 -0
  15. package/lib/typescript/config/apple/plist-value.d.ts.map +1 -0
  16. package/lib/typescript/config/apple/plist.d.ts +4 -0
  17. package/lib/typescript/config/apple/plist.d.ts.map +1 -0
  18. package/lib/typescript/config/apple/podfile/index.d.ts +5 -0
  19. package/lib/typescript/config/apple/podfile/index.d.ts.map +1 -0
  20. package/lib/typescript/config/apple/podfile/pod-dependency-from-cocoapods.d.ts +12 -0
  21. package/lib/typescript/config/apple/podfile/pod-dependency-from-cocoapods.d.ts.map +1 -0
  22. package/lib/typescript/config/apple/podfile/pod-dependency-from-git.d.ts +16 -0
  23. package/lib/typescript/config/apple/podfile/pod-dependency-from-git.d.ts.map +1 -0
  24. package/lib/typescript/config/apple/podfile/pod-dependency-from-local.d.ts +12 -0
  25. package/lib/typescript/config/apple/podfile/pod-dependency-from-local.d.ts.map +1 -0
  26. package/lib/typescript/config/apple/podfile/pod-dependency.d.ts +5 -0
  27. package/lib/typescript/config/apple/podfile/pod-dependency.d.ts.map +1 -0
  28. package/lib/typescript/plugin/apple/context.d.ts +1 -1
  29. package/lib/typescript/plugin/apple/context.d.ts.map +1 -1
  30. package/lib/typescript/plugin/apple/index.d.ts +0 -3
  31. package/lib/typescript/plugin/apple/index.d.ts.map +1 -1
  32. package/package.json +1 -1
  33. package/src/_bin/_main/_check-config-validity.mts +10 -2
  34. package/src/_bin/_main/_helpers/config/cache-paths/asset-catalogs-tracker-file.mts +9 -0
  35. package/src/_bin/_main/_helpers/config/cache-paths/dir-cache.mts +19 -0
  36. package/src/_bin/_main/_helpers/config/cache-paths/index.mts +3 -0
  37. package/src/_bin/_main/_helpers/config/cache-paths/string-catalogs-tracker-file.mts +9 -0
  38. package/src/_bin/_main/_helpers/config/get-name.mts +1 -3
  39. package/src/_bin/_main/_helpers/config/get-project-name.mts +10 -5
  40. package/src/_bin/_main/_helpers/config/index.mts +1 -0
  41. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_get-xcassets-path.mts +29 -0
  42. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts +25 -12
  43. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-imagesets.mts +32 -13
  44. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts +194 -9
  45. package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts +159 -81
  46. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_app-delegate-swift.mts +3 -6
  47. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/_pod-dependencies.mts +78 -0
  48. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/index.mts +1 -0
  49. package/src/_bin/_main/_init-template/_init-apple/_mod-files/{_podfile.mts → _podfile/podfile.mts} +16 -4
  50. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_privacy-manifest.mts +119 -0
  51. package/src/_bin/_main/_init-template/_init-apple/_mod-files/mod-files.mts +8 -2
  52. package/src/_bin/_main/_init-template/_init-apple/init-apple.mts +13 -8
  53. package/src/_bin/_main/_init-template/init-template.mts +2 -0
  54. package/src/_bin/_main/_xcodegen/_create-project-spec/_init-resources.mts +21 -9
  55. package/src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts +51 -32
  56. package/src/_bin/_main/_xcodegen/_mod-known-regions/mod-known-regions.mts +2 -2
  57. package/src/_bin/_main/_xcodegen/xcodegen.mts +1 -1
  58. package/src/_bin/_main/main.mts +1 -1
  59. package/src/_bin/plugin-sandbox-runner/plugin-runner-context-result.ts +0 -27
  60. package/src/config/apple/asset-catalogs-namespaced.ts +1 -1
  61. package/src/config/apple/data.ts +27 -4
  62. package/src/config/apple/index.mts +3 -2
  63. package/src/config/apple/{info-plist-value.ts → plist-value.ts} +5 -4
  64. package/src/config/apple/plist.ts +6 -0
  65. package/src/config/apple/podfile/index.ts +4 -0
  66. package/src/config/apple/podfile/pod-dependency-from-cocoapods.ts +15 -0
  67. package/src/config/apple/podfile/pod-dependency-from-git.ts +23 -0
  68. package/src/config/apple/podfile/pod-dependency-from-local.ts +15 -0
  69. package/src/config/apple/podfile/pod-dependency.ts +16 -0
  70. package/src/plugin/apple/context.ts +1 -35
  71. package/src/plugin/apple/index.ts +0 -3
  72. package/template/macos/Podfile +4 -0
  73. package/template/macos/PrivacyInfo.xcprivacy +5 -0
  74. package/template/macos/pod_dependencies.rb +2 -0
  75. package/lib/typescript/config/apple/info-plist-value.d.ts +0 -8
  76. package/lib/typescript/config/apple/info-plist-value.d.ts.map +0 -1
  77. package/lib/typescript/config/apple/info-plist.d.ts +0 -4
  78. package/lib/typescript/config/apple/info-plist.d.ts.map +0 -1
  79. package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts +0 -5
  80. package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts.map +0 -1
  81. package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts +0 -11
  82. package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts.map +0 -1
  83. package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts +0 -7
  84. package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts.map +0 -1
  85. package/src/config/apple/info-plist.ts +0 -6
  86. package/src/plugin/apple/pod-spec-source-from-cocoapods.ts +0 -9
  87. package/src/plugin/apple/pod-spec-source-from-git.ts +0 -13
  88. package/src/plugin/apple/pod-spec-source-from-local.ts +0 -6
@@ -1,7 +1,18 @@
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
+ ConfigHelpers,
10
+ } from "../../../_helpers/index.mts"
11
+
12
+ import {
13
+ getXcassetsPath,
14
+ } from "./_get-xcassets-path.mts"
15
+
5
16
  import {
6
17
  initAppiconsets,
7
18
  } from "./_init-appiconsets.mts"
@@ -15,40 +26,214 @@ export function createAssetCatalogs(
15
26
  metadata: {
16
27
  bundleIdentifier: string,
17
28
  namespace?: string,
18
- platform: "macos" | "ios",
19
- projectName: string,
29
+ platform: "macos",
20
30
  },
21
31
  ) {
32
+
33
+ const
34
+ xcassetsPath =
35
+ getXcassetsPath(metadata.platform),
36
+
37
+ assetCatalogsTrackerFilePath =
38
+ ConfigHelpers.CachePaths.assetCatalogsTrackerFile()
39
+
40
+ let catalogsTracker: CatalogsTrackerSchema = {
41
+ appiconsets: undefined,
42
+ imagesets: undefined,
43
+ }
44
+
45
+ function removeAllCatalogs() {
46
+ // remove the Assets.xcassets directory including its files if any.
47
+ if(node_fs.existsSync(xcassetsPath)) {
48
+ node_fs.rmSync(
49
+ xcassetsPath,
50
+ {
51
+ recursive: true,
52
+ force: true,
53
+ },
54
+ )
55
+ }
56
+
57
+ if(node_fs.existsSync(assetCatalogsTrackerFilePath)) {
58
+ node_fs.rmSync(assetCatalogsTrackerFilePath)
59
+ }
60
+ }
61
+
22
62
  if(!assetCatalogs) {
63
+ removeAllCatalogs()
23
64
  return
24
65
  }
25
66
 
67
+ try {
68
+ if(node_fs.existsSync(assetCatalogsTrackerFilePath)) {
69
+ catalogsTracker = JSON.parse(
70
+ node_fs.readFileSync(assetCatalogsTrackerFilePath, "utf8"),
71
+ ) as CatalogsTrackerSchema
72
+ }
73
+ } catch {
74
+ // the tracker file is not a valid JSON file
75
+ // remove the Assets.xcassets directory including its files if any.
76
+ removeAllCatalogs()
77
+ }
78
+
79
+ // +++++ Create Catalog Files +++++
80
+ const newCatalogsTracker = createCatalogs(
81
+ assetCatalogs,
82
+ {
83
+ bundleIdentifier: metadata.bundleIdentifier,
84
+ platform: metadata.platform,
85
+ namespace: metadata.namespace,
86
+ },
87
+ )
88
+ // ----- Create Catalog Files -----
89
+
90
+ catalogsTracker.appiconsets?.forEach(existingCatalog => {
91
+ if(newCatalogsTracker.appiconsets?.indexOf(existingCatalog) === -1) {
92
+ const existingPath = node_path.join(xcassetsPath, existingCatalog + ".appiconset")
93
+
94
+ if(node_fs.existsSync(existingPath)) {
95
+ node_fs.rmSync(
96
+ existingPath,
97
+ {
98
+ recursive: true,
99
+ force: true,
100
+ },
101
+ )
102
+ }
103
+ }
104
+ })
105
+
106
+ catalogsTracker.imagesets?.forEach(existingCatalog => {
107
+ if(newCatalogsTracker.imagesets?.indexOf(existingCatalog) === -1) {
108
+ /**
109
+ * "Long/Ass/Namespace/Image" -> "Long"
110
+ */
111
+ const existingCatalogBasename = existingCatalog.split("/")[0]
112
+
113
+ if(!existingCatalogBasename) {
114
+ return
115
+ }
116
+
117
+ const existingPath = node_path.join(
118
+ xcassetsPath,
119
+ existingCatalogBasename,
120
+ )
121
+
122
+ if(node_fs.existsSync(existingPath)) {
123
+ // remove namespace directory
124
+ node_fs.rmSync(
125
+ existingPath,
126
+ {
127
+ recursive: true,
128
+ force: true,
129
+ },
130
+ )
131
+ } else {
132
+ const imagesetDir = node_path.join(existingCatalogBasename, ".imageset")
133
+ if(node_fs.existsSync(imagesetDir)) {
134
+ node_fs.rmSync(
135
+ imagesetDir,
136
+ {
137
+ recursive: true,
138
+ force: true,
139
+ },
140
+ )
141
+ }
142
+ }
143
+ }
144
+ })
145
+
146
+ node_fs.writeFileSync(
147
+ assetCatalogsTrackerFilePath,
148
+ JSON.stringify(newCatalogsTracker, null, 2),
149
+ "utf8",
150
+ )
151
+ }
152
+
153
+ function createCatalogs(
154
+ assetCatalogs: NonNullable<Config.Apple.Data["assetCatalogs"]>,
155
+ metadata: {
156
+ bundleIdentifier: string,
157
+ namespace?: string,
158
+ platform: "macos",
159
+ },
160
+ nextTracker?: CatalogsTrackerSchema,
161
+ ): CatalogsTrackerSchema {
162
+
163
+ const tracker: CatalogsTrackerSchema = nextTracker ?? {
164
+ appiconsets: undefined,
165
+ imagesets: undefined,
166
+ }
167
+
168
+ if(!assetCatalogs) {
169
+ return tracker
170
+ }
171
+
172
+ let isRecursived = false
173
+
26
174
  for(const _key of Object.keys(assetCatalogs)) {
27
175
  const key = _key as keyof typeof assetCatalogs
28
176
 
29
177
  if(key == "imagesets") {
30
- initImagesets(
178
+ const trackedCatalogs = initImagesets(
31
179
  assetCatalogs.imagesets,
32
180
  metadata,
33
181
  )
182
+
183
+ if(trackedCatalogs?.length) {
184
+ if(!tracker.imagesets?.length) {
185
+ tracker.imagesets = trackedCatalogs
186
+ } else {
187
+ tracker.imagesets = [
188
+ ...tracker.imagesets,
189
+ ...trackedCatalogs,
190
+ ]
191
+ }
192
+ }
34
193
  } else if(key == "appiconsets") {
35
- initAppiconsets(
36
- assetCatalogs.appiconsets,
37
- metadata,
38
- )
194
+ if(!isRecursived) {
195
+ // appiconset cannot be created under a namespace
196
+
197
+ const trackedCatalogs = initAppiconsets(
198
+ assetCatalogs.appiconsets,
199
+ metadata,
200
+ )
201
+
202
+ if(trackedCatalogs?.length) {
203
+ if(!tracker.appiconsets?.length) {
204
+ tracker.appiconsets = trackedCatalogs
205
+ } else {
206
+ tracker.appiconsets = [
207
+ ...tracker.appiconsets,
208
+ ...trackedCatalogs,
209
+ ]
210
+ }
211
+ }
212
+ }
39
213
  } else {
40
214
  // key is namespace
41
215
  const namespacedCatalogs = assetCatalogs[key] as unknown as Config.Apple.AssetCatalogs
42
216
 
43
217
  if(namespacedCatalogs && Object.keys(namespacedCatalogs).length) {
44
- createAssetCatalogs(
218
+ isRecursived = true
219
+
220
+ createCatalogs(
45
221
  namespacedCatalogs,
46
222
  {
47
223
  ...metadata,
48
- namespace: key,
224
+ namespace: metadata.namespace ? `${metadata.namespace}/${key as string}` : key,
49
225
  },
226
+ tracker,
50
227
  )
51
228
  }
52
229
  }
53
230
  }
231
+
232
+ return tracker
233
+
234
+ }
235
+
236
+ interface CatalogsTrackerSchema {
237
+ appiconsets: string[] | undefined,
238
+ imagesets: string[] | undefined,
54
239
  }
@@ -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
  }