morphkit-cli 0.1.0
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/LICENSE +21 -0
- package/README.md +449 -0
- package/dist/index.js +30940 -0
- package/package.json +60 -0
- package/templates/swift/app-entry.swift.ts +46 -0
- package/templates/swift/model.swift.ts +72 -0
- package/templates/swiftui/navigation.swift.ts +118 -0
- package/templates/swiftui/networking.swift.ts +145 -0
- package/templates/swiftui/view.swift.ts +230 -0
- package/templates/xcode-project/assets.ts +112 -0
- package/templates/xcode-project/info-plist.ts +115 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Template for generating Assets.xcassets structure
|
|
2
|
+
|
|
3
|
+
export function generateAssetsCatalog(): string {
|
|
4
|
+
return JSON.stringify({
|
|
5
|
+
info: {
|
|
6
|
+
author: 'xcode',
|
|
7
|
+
version: 1,
|
|
8
|
+
},
|
|
9
|
+
}, null, 2);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function generateAccentColorSet(hexColor: string): {
|
|
13
|
+
contents: string;
|
|
14
|
+
} {
|
|
15
|
+
const rgb = hexToRgb(hexColor);
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
contents: JSON.stringify({
|
|
19
|
+
colors: [
|
|
20
|
+
{
|
|
21
|
+
color: {
|
|
22
|
+
'color-space': 'srgb',
|
|
23
|
+
components: {
|
|
24
|
+
alpha: '1.000',
|
|
25
|
+
blue: `${(rgb.b / 255).toFixed(3)}`,
|
|
26
|
+
green: `${(rgb.g / 255).toFixed(3)}`,
|
|
27
|
+
red: `${(rgb.r / 255).toFixed(3)}`,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
idiom: 'universal',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
info: {
|
|
34
|
+
author: 'xcode',
|
|
35
|
+
version: 1,
|
|
36
|
+
},
|
|
37
|
+
}, null, 2),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function generateAppIconSet(): string {
|
|
42
|
+
return JSON.stringify({
|
|
43
|
+
images: [
|
|
44
|
+
{
|
|
45
|
+
idiom: 'universal',
|
|
46
|
+
platform: 'ios',
|
|
47
|
+
size: '1024x1024',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
info: {
|
|
51
|
+
author: 'xcode',
|
|
52
|
+
version: 1,
|
|
53
|
+
},
|
|
54
|
+
}, null, 2);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function generateColorSet(name: string, lightHex: string, darkHex?: string): string {
|
|
58
|
+
const lightRgb = hexToRgb(lightHex);
|
|
59
|
+
const colors: any[] = [
|
|
60
|
+
{
|
|
61
|
+
color: {
|
|
62
|
+
'color-space': 'srgb',
|
|
63
|
+
components: {
|
|
64
|
+
alpha: '1.000',
|
|
65
|
+
blue: `${(lightRgb.b / 255).toFixed(3)}`,
|
|
66
|
+
green: `${(lightRgb.g / 255).toFixed(3)}`,
|
|
67
|
+
red: `${(lightRgb.r / 255).toFixed(3)}`,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
idiom: 'universal',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
if (darkHex) {
|
|
75
|
+
const darkRgb = hexToRgb(darkHex);
|
|
76
|
+
colors.push({
|
|
77
|
+
appearances: [
|
|
78
|
+
{
|
|
79
|
+
appearance: 'luminosity',
|
|
80
|
+
value: 'dark',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
color: {
|
|
84
|
+
'color-space': 'srgb',
|
|
85
|
+
components: {
|
|
86
|
+
alpha: '1.000',
|
|
87
|
+
blue: `${(darkRgb.b / 255).toFixed(3)}`,
|
|
88
|
+
green: `${(darkRgb.g / 255).toFixed(3)}`,
|
|
89
|
+
red: `${(darkRgb.r / 255).toFixed(3)}`,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
idiom: 'universal',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return JSON.stringify({
|
|
97
|
+
colors,
|
|
98
|
+
info: {
|
|
99
|
+
author: 'xcode',
|
|
100
|
+
version: 1,
|
|
101
|
+
},
|
|
102
|
+
}, null, 2);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function hexToRgb(hex: string): { r: number; g: number; b: number } {
|
|
106
|
+
const clean = hex.replace('#', '');
|
|
107
|
+
return {
|
|
108
|
+
r: parseInt(clean.substring(0, 2), 16),
|
|
109
|
+
g: parseInt(clean.substring(2, 4), 16),
|
|
110
|
+
b: parseInt(clean.substring(4, 6), 16),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Template for generating Info.plist
|
|
2
|
+
|
|
3
|
+
export interface InfoPlistConfig {
|
|
4
|
+
appName: string;
|
|
5
|
+
bundleId: string;
|
|
6
|
+
version: string;
|
|
7
|
+
buildNumber: string;
|
|
8
|
+
minimumOSVersion: string;
|
|
9
|
+
supportedOrientations: string[];
|
|
10
|
+
requiresFullScreen: boolean;
|
|
11
|
+
urlSchemes?: string[];
|
|
12
|
+
associatedDomains?: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function generateInfoPlist(config: InfoPlistConfig): string {
|
|
16
|
+
const orientations = config.supportedOrientations
|
|
17
|
+
.map(o => `\t\t<string>${o}</string>`)
|
|
18
|
+
.join('\n');
|
|
19
|
+
|
|
20
|
+
const urlSchemes = config.urlSchemes && config.urlSchemes.length > 0
|
|
21
|
+
? `\t<key>CFBundleURLTypes</key>
|
|
22
|
+
\t<array>
|
|
23
|
+
\t\t<dict>
|
|
24
|
+
\t\t\t<key>CFBundleURLSchemes</key>
|
|
25
|
+
\t\t\t<array>
|
|
26
|
+
${config.urlSchemes.map(s => `\t\t\t\t<string>${s}</string>`).join('\n')}
|
|
27
|
+
\t\t\t</array>
|
|
28
|
+
\t\t</dict>
|
|
29
|
+
\t</array>`
|
|
30
|
+
: '';
|
|
31
|
+
|
|
32
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
33
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
34
|
+
<plist version="1.0">
|
|
35
|
+
<dict>
|
|
36
|
+
\t<key>CFBundleDevelopmentRegion</key>
|
|
37
|
+
\t<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
38
|
+
\t<key>CFBundleDisplayName</key>
|
|
39
|
+
\t<string>${config.appName}</string>
|
|
40
|
+
\t<key>CFBundleExecutable</key>
|
|
41
|
+
\t<string>$(EXECUTABLE_NAME)</string>
|
|
42
|
+
\t<key>CFBundleIdentifier</key>
|
|
43
|
+
\t<string>${config.bundleId}</string>
|
|
44
|
+
\t<key>CFBundleInfoDictionaryVersion</key>
|
|
45
|
+
\t<string>6.0</string>
|
|
46
|
+
\t<key>CFBundleName</key>
|
|
47
|
+
\t<string>$(PRODUCT_NAME)</string>
|
|
48
|
+
\t<key>CFBundlePackageType</key>
|
|
49
|
+
\t<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
|
50
|
+
\t<key>CFBundleShortVersionString</key>
|
|
51
|
+
\t<string>${config.version}</string>
|
|
52
|
+
\t<key>CFBundleVersion</key>
|
|
53
|
+
\t<string>${config.buildNumber}</string>
|
|
54
|
+
\t<key>LSRequiresIPhoneOS</key>
|
|
55
|
+
\t<true/>
|
|
56
|
+
\t<key>MinimumOSVersion</key>
|
|
57
|
+
\t<string>${config.minimumOSVersion}</string>
|
|
58
|
+
\t<key>UIRequiresFullScreen</key>
|
|
59
|
+
\t<${config.requiresFullScreen}/>
|
|
60
|
+
\t<key>UISupportedInterfaceOrientations</key>
|
|
61
|
+
\t<array>
|
|
62
|
+
${orientations}
|
|
63
|
+
\t</array>
|
|
64
|
+
\t<key>UILaunchScreen</key>
|
|
65
|
+
\t<dict/>
|
|
66
|
+
${urlSchemes}
|
|
67
|
+
</dict>
|
|
68
|
+
</plist>
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function generatePrivacyManifest(): string {
|
|
73
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
74
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
75
|
+
<plist version="1.0">
|
|
76
|
+
<dict>
|
|
77
|
+
\t<key>NSPrivacyTracking</key>
|
|
78
|
+
\t<false/>
|
|
79
|
+
\t<key>NSPrivacyTrackingDomains</key>
|
|
80
|
+
\t<array/>
|
|
81
|
+
\t<key>NSPrivacyCollectedDataTypes</key>
|
|
82
|
+
\t<array/>
|
|
83
|
+
\t<key>NSPrivacyAccessedAPITypes</key>
|
|
84
|
+
\t<array>
|
|
85
|
+
\t\t<dict>
|
|
86
|
+
\t\t\t<key>NSPrivacyAccessedAPIType</key>
|
|
87
|
+
\t\t\t<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
|
88
|
+
\t\t\t<key>NSPrivacyAccessedAPITypeReasons</key>
|
|
89
|
+
\t\t\t<array>
|
|
90
|
+
\t\t\t\t<string>CA92.1</string>
|
|
91
|
+
\t\t\t</array>
|
|
92
|
+
\t\t</dict>
|
|
93
|
+
\t</array>
|
|
94
|
+
</dict>
|
|
95
|
+
</plist>
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function generateEntitlements(config: { associatedDomains?: string[] }): string {
|
|
100
|
+
const domains = config.associatedDomains && config.associatedDomains.length > 0
|
|
101
|
+
? `\t<key>com.apple.developer.associated-domains</key>
|
|
102
|
+
\t<array>
|
|
103
|
+
${config.associatedDomains.map(d => `\t\t<string>applinks:${d}</string>`).join('\n')}
|
|
104
|
+
\t</array>`
|
|
105
|
+
: '';
|
|
106
|
+
|
|
107
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
108
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
109
|
+
<plist version="1.0">
|
|
110
|
+
<dict>
|
|
111
|
+
${domains}
|
|
112
|
+
</dict>
|
|
113
|
+
</plist>
|
|
114
|
+
`;
|
|
115
|
+
}
|