@scalebun/cli 2.0.5 → 2.0.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/lib/commands/doctor.d.ts.map +1 -1
- package/lib/commands/doctor.js +18 -0
- package/lib/commands/doctor.js.map +1 -1
- package/lib/commands/ota-bundle.d.ts.map +1 -1
- package/lib/commands/ota-bundle.js +43 -3
- package/lib/commands/ota-bundle.js.map +1 -1
- package/lib/commands/ota-delete-bundle.d.ts +7 -2
- package/lib/commands/ota-delete-bundle.d.ts.map +1 -1
- package/lib/commands/ota-delete-bundle.js +60 -55
- package/lib/commands/ota-delete-bundle.js.map +1 -1
- package/lib/commands/ota-keys.d.ts.map +1 -1
- package/lib/commands/ota-keys.js +56 -6
- package/lib/commands/ota-keys.js.map +1 -1
- package/lib/commands/ota-sign.d.ts +19 -0
- package/lib/commands/ota-sign.d.ts.map +1 -0
- package/lib/commands/ota-sign.js +231 -0
- package/lib/commands/ota-sign.js.map +1 -0
- package/lib/commands/quickstart.d.ts.map +1 -1
- package/lib/commands/quickstart.js +135 -11
- package/lib/commands/quickstart.js.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/bundleStore.d.ts +128 -0
- package/lib/utils/bundleStore.d.ts.map +1 -0
- package/lib/utils/bundleStore.js +250 -0
- package/lib/utils/bundleStore.js.map +1 -0
- package/lib/utils/guide.d.ts.map +1 -1
- package/lib/utils/guide.js +1 -0
- package/lib/utils/guide.js.map +1 -1
- package/lib/utils/trustAnchor.d.ts +69 -11
- package/lib/utils/trustAnchor.d.ts.map +1 -1
- package/lib/utils/trustAnchor.js +90 -4
- package/lib/utils/trustAnchor.js.map +1 -1
- package/package.json +1 -1
package/lib/utils/trustAnchor.js
CHANGED
|
@@ -33,22 +33,28 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ANDROID_ANCHOR_RELATIVE = void 0;
|
|
36
|
+
exports.IOS_ANCHOR_FILENAME = exports.ANDROID_ANCHOR_RELATIVE = void 0;
|
|
37
37
|
exports.writeAndroidTrustAnchor = writeAndroidTrustAnchor;
|
|
38
|
+
exports.findXcodeProject = findXcodeProject;
|
|
39
|
+
exports.iosAppSourceDir = iosAppSourceDir;
|
|
40
|
+
exports.isInXcodeResources = isInXcodeResources;
|
|
41
|
+
exports.writeIosTrustAnchor = writeIosTrustAnchor;
|
|
38
42
|
exports.hasAndroidProject = hasAndroidProject;
|
|
43
|
+
exports.hasIosProject = hasIosProject;
|
|
39
44
|
const fs = __importStar(require("fs"));
|
|
40
45
|
const path = __importStar(require("path"));
|
|
41
46
|
exports.ANDROID_ANCHOR_RELATIVE = path.join('android', 'app', 'src', 'main', 'assets', 'scalebun_ota_keys.json');
|
|
47
|
+
/** `ScaleBunOtaKeyRegistry.defaultResource` + ".json", on the iOS side. */
|
|
48
|
+
exports.IOS_ANCHOR_FILENAME = 'ScaleBunOtaKeys.json';
|
|
42
49
|
/**
|
|
43
|
-
* Add a key to
|
|
50
|
+
* Add a key to an anchor file, creating it if needed.
|
|
44
51
|
*
|
|
45
52
|
* Merges rather than overwrites: during a rotation two keys are valid at once,
|
|
46
53
|
* and clobbering the old one strands every device still running the previous
|
|
47
54
|
* build — they would refuse the next release and have no way back. A key with
|
|
48
55
|
* the same keyId is replaced in place so re-running is idempotent.
|
|
49
56
|
*/
|
|
50
|
-
function
|
|
51
|
-
const anchorPath = path.join(opts.cwd, exports.ANDROID_ANCHOR_RELATIVE);
|
|
57
|
+
function writeAnchorAt(anchorPath, opts) {
|
|
52
58
|
fs.mkdirSync(path.dirname(anchorPath), { recursive: true });
|
|
53
59
|
let keys = [];
|
|
54
60
|
let merged = false;
|
|
@@ -72,6 +78,82 @@ function writeAndroidTrustAnchor(opts) {
|
|
|
72
78
|
fs.writeFileSync(anchorPath, JSON.stringify(anchor, null, 2) + '\n');
|
|
73
79
|
return { path: anchorPath, keyIds: keys.map((k) => k.keyId), merged };
|
|
74
80
|
}
|
|
81
|
+
function writeAndroidTrustAnchor(opts) {
|
|
82
|
+
return writeAnchorAt(path.join(opts.cwd, exports.ANDROID_ANCHOR_RELATIVE), opts);
|
|
83
|
+
}
|
|
84
|
+
/** `ios/<App>.xcodeproj`, or null when there is no iOS project here. */
|
|
85
|
+
function findXcodeProject(cwd) {
|
|
86
|
+
const iosDir = path.join(cwd, 'ios');
|
|
87
|
+
if (!fs.existsSync(iosDir))
|
|
88
|
+
return null;
|
|
89
|
+
const proj = fs.readdirSync(iosDir).find((name) => name.endsWith('.xcodeproj'));
|
|
90
|
+
return proj ? path.join(iosDir, proj) : null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The folder the app's own sources live in — `ios/<App>/`.
|
|
94
|
+
*
|
|
95
|
+
* Xcode groups mirror the filesystem here by React Native convention, so that
|
|
96
|
+
* is where a new resource belongs if it is going to be easy to add to the
|
|
97
|
+
* target. Falls back to whichever folder holds the AppDelegate, for projects
|
|
98
|
+
* renamed away from their directory.
|
|
99
|
+
*/
|
|
100
|
+
function iosAppSourceDir(cwd) {
|
|
101
|
+
const proj = findXcodeProject(cwd);
|
|
102
|
+
if (!proj)
|
|
103
|
+
return null;
|
|
104
|
+
const iosDir = path.join(cwd, 'ios');
|
|
105
|
+
const byName = path.join(iosDir, path.basename(proj, '.xcodeproj'));
|
|
106
|
+
if (fs.existsSync(byName) && fs.statSync(byName).isDirectory())
|
|
107
|
+
return byName;
|
|
108
|
+
for (const entry of fs.readdirSync(iosDir)) {
|
|
109
|
+
const dir = path.join(iosDir, entry);
|
|
110
|
+
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory())
|
|
111
|
+
continue;
|
|
112
|
+
const hasDelegate = fs
|
|
113
|
+
.readdirSync(dir)
|
|
114
|
+
.some((f) => /^AppDelegate\.(swift|mm?|h)$/.test(f));
|
|
115
|
+
if (hasDelegate)
|
|
116
|
+
return dir;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Is the anchor already referenced by the Xcode project?
|
|
122
|
+
*
|
|
123
|
+
* A substring check over project.pbxproj rather than a real parse: the question
|
|
124
|
+
* is only "has anyone added this filename", and erring toward "no" costs one
|
|
125
|
+
* extra printing of the instructions.
|
|
126
|
+
*/
|
|
127
|
+
function isInXcodeResources(cwd) {
|
|
128
|
+
const proj = findXcodeProject(cwd);
|
|
129
|
+
if (!proj)
|
|
130
|
+
return false;
|
|
131
|
+
const pbx = path.join(proj, 'project.pbxproj');
|
|
132
|
+
if (!fs.existsSync(pbx))
|
|
133
|
+
return false;
|
|
134
|
+
try {
|
|
135
|
+
return fs.readFileSync(pbx, 'utf8').includes(exports.IOS_ANCHOR_FILENAME);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Add a key to the iOS trust anchor, creating the file if needed.
|
|
143
|
+
*
|
|
144
|
+
* Writes into `ios/<App>/` and reports whether the project references it yet.
|
|
145
|
+
* Adding it to the target is left to the caller: that means editing
|
|
146
|
+
* project.pbxproj, and a corrupted pbxproj costs far more than the single drag
|
|
147
|
+
* it would save.
|
|
148
|
+
*/
|
|
149
|
+
function writeIosTrustAnchor(opts) {
|
|
150
|
+
const dir = iosAppSourceDir(opts.cwd);
|
|
151
|
+
if (!dir) {
|
|
152
|
+
throw new Error('No ios/<App> source directory found — is this a React Native project with a native iOS app?');
|
|
153
|
+
}
|
|
154
|
+
const res = writeAnchorAt(path.join(dir, exports.IOS_ANCHOR_FILENAME), opts);
|
|
155
|
+
return { ...res, inXcodeResources: isInXcodeResources(opts.cwd) };
|
|
156
|
+
}
|
|
75
157
|
/**
|
|
76
158
|
* Does this look like a native Android project we can write into? Used to skip
|
|
77
159
|
* the anchor with a clear message instead of scattering directories into
|
|
@@ -80,4 +162,8 @@ function writeAndroidTrustAnchor(opts) {
|
|
|
80
162
|
function hasAndroidProject(cwd) {
|
|
81
163
|
return fs.existsSync(path.join(cwd, 'android', 'app'));
|
|
82
164
|
}
|
|
165
|
+
/** The iOS counterpart: an `ios/` folder with an actual Xcode project in it. */
|
|
166
|
+
function hasIosProject(cwd) {
|
|
167
|
+
return iosAppSourceDir(cwd) !== null;
|
|
168
|
+
}
|
|
83
169
|
//# sourceMappingURL=trustAnchor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trustAnchor.js","sourceRoot":"","sources":["../../src/utils/trustAnchor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"trustAnchor.js","sourceRoot":"","sources":["../../src/utils/trustAnchor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,0DAOC;AAGD,4CAKC;AAUD,0CAgBC;AASD,gDAUC;AAUD,kDAcC;AAOD,8CAEC;AAGD,sCAEC;AApND,uCAAyB;AACzB,2CAA6B;AAuChB,QAAA,uBAAuB,GAAG,IAAI,CAAC,IAAI,CAC9C,SAAS,EACT,KAAK,EACL,KAAK,EACL,MAAM,EACN,QAAQ,EACR,wBAAwB,CACzB,CAAC;AAEF,2EAA2E;AAC9D,QAAA,mBAAmB,GAAG,sBAAsB,CAAC;AAuB1D;;;;;;;GAOG;AACH,SAAS,aAAa,CACpB,UAAkB,EAClB,IAAgE;IAEhE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE5D,IAAI,IAAI,GAAwB,EAAE,CAAC;IACnC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,QAAQ,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