runcloud 0.2.210 → 0.2.212

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.
@@ -1,5 +1,5 @@
1
1
  import { createHash, randomUUID } from 'node:crypto';
2
- import { cp, copyFile, lstat, mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises';
2
+ import { cp, copyFile, lstat, mkdir, mkdtemp, readFile, realpath, rm, stat, writeFile } from 'node:fs/promises';
3
3
  import { existsSync } from 'node:fs';
4
4
  import { tmpdir } from 'node:os';
5
5
  import { basename, dirname, join, relative, resolve, sep } from 'node:path';
@@ -150,11 +150,40 @@ function remoteAdditionalPath(value) {
150
150
  }
151
151
  return { home, path };
152
152
  }
153
+ async function checkSourceLink(root, realRoot, link, relativePath) {
154
+ const target = await realpath(link).catch(() => null);
155
+ if (!target)
156
+ throw new Error(`Xcode source symbolic link cannot be resolved: ${relativePath}`);
157
+ if (target !== realRoot && !target.startsWith(`${realRoot}${sep}`)) {
158
+ throw new Error(`Xcode source symbolic link points outside the source directory: ${relativePath}`);
159
+ }
160
+ if (!(await stat(target)).isDirectory())
161
+ return;
162
+ for (let parent = dirname(link);; parent = dirname(parent)) {
163
+ const realParent = await realpath(parent);
164
+ if (realParent === target || realParent.startsWith(`${target}${sep}`)) {
165
+ throw new Error(`Xcode source symbolic link loops back to a directory that contains it: ${relativePath}`);
166
+ }
167
+ if (parent === root)
168
+ return;
169
+ }
170
+ }
171
+ async function realSourcePaths(realRoot, source, isDirectory) {
172
+ const target = await realpath(source).catch(() => null);
173
+ if (!target?.startsWith(`${realRoot}${sep}`))
174
+ return [];
175
+ const parts = relative(realRoot, target).split(sep);
176
+ return parts.map((_, index) => {
177
+ const path = parts.slice(0, index + 1).join('/');
178
+ return index < parts.length - 1 || isDirectory ? `${path}/` : path;
179
+ });
180
+ }
153
181
  export async function packSource(sourcePath, flags) {
154
182
  const root = resolve(sourcePath);
155
183
  const rootStat = await stat(root).catch(() => null);
156
184
  if (!rootStat?.isDirectory())
157
185
  throw new Error(`Xcode source path is not a directory: ${sourcePath}`);
186
+ const realRoot = await realpath(root);
158
187
  const temporary = await mkdtemp(join(tmpdir(), 'runcloud-xcode-'));
159
188
  const workspace = join(temporary, 'workspace');
160
189
  const archivePath = join(temporary, 'source.tar.gz');
@@ -165,21 +194,34 @@ export async function packSource(sourcePath, flags) {
165
194
  gitignore.add(gitignoreText);
166
195
  const ignored = compilePatterns(flags.ignore, '--ignore');
167
196
  const included = compilePatterns(flags.include, '--include');
197
+ const excluded = (candidate) => defaultExcluded(candidate) || gitignore.ignores(candidate) || matches(ignored, candidate);
198
+ const linkedDirectories = [];
168
199
  await cp(root, workspace, {
169
200
  recursive: true,
170
- dereference: false,
201
+ dereference: true,
171
202
  preserveTimestamps: true,
172
203
  filter: async (source) => {
173
204
  if (source === root)
174
205
  return true;
175
206
  const info = await lstat(source);
176
207
  const relativePath = relative(root, source).split(sep).join('/');
177
- const candidate = info.isDirectory() ? `${relativePath}/` : relativePath;
208
+ const isDirectory = info.isSymbolicLink()
209
+ ? Boolean((await stat(source).catch(() => null))?.isDirectory())
210
+ : info.isDirectory();
211
+ const candidate = isDirectory ? `${relativePath}/` : relativePath;
178
212
  const forced = relativePath.endsWith('.xcconfig') || matches(included, candidate);
179
- if (!forced && (defaultExcluded(candidate) || gitignore.ignores(candidate) || matches(ignored, candidate)))
180
- return false;
181
- if (info.isSymbolicLink())
182
- throw new Error(`Xcode source archives do not follow symbolic links: ${relativePath}`);
213
+ const linked = info.isSymbolicLink() || linkedDirectories.some((directory) => source.startsWith(`${directory}${sep}`));
214
+ if (!forced) {
215
+ if (excluded(candidate))
216
+ return false;
217
+ if (linked && (await realSourcePaths(realRoot, source, isDirectory)).some(excluded))
218
+ return false;
219
+ }
220
+ if (info.isSymbolicLink()) {
221
+ await checkSourceLink(root, realRoot, source, relativePath);
222
+ if (isDirectory)
223
+ linkedDirectories.push(source);
224
+ }
183
225
  return true;
184
226
  },
185
227
  });
@@ -329,6 +371,14 @@ export function registerXcode(program) {
329
371
  xcode
330
372
  .command('build')
331
373
  .description('Upload a local source tree, stream xcodebuild logs, and download its artifact')
374
+ .addHelpText('after', `
375
+ Examples:
376
+ Build an iOS app for the simulator:
377
+ $ runcloud xcode build . --scheme App --sdk iphonesimulator
378
+ Build a standalone watchOS app for the watch simulator:
379
+ $ runcloud xcode build . --scheme WatchApp --sdk watchsimulator
380
+ Build an iOS app that embeds a watch app (the watch app is built with it):
381
+ $ runcloud xcode build . --scheme App --sdk iphonesimulator`)
332
382
  .argument('[path]', 'local source directory', '.')
333
383
  .option('--scheme <name>', 'Xcode scheme')
334
384
  .option('--workspace <path>', 'relative .xcworkspace path')
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = '0.2.210';
1
+ export const CLI_VERSION = '0.2.212';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcloud",
3
- "version": "0.2.210",
3
+ "version": "0.2.212",
4
4
  "description": "Create and control run.cloud remote mobile simulators and cloud sandboxes",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
index 7939426..6ea96fb 100644
Binary file