eas-cli-local-build-plugin 0.0.141 → 0.0.142

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/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "eas-cli-local-build-plugin",
3
- "version": "0.0.141",
3
+ "version": "0.0.142",
4
4
  "description": "Tool for running EAS compatible builds on a local machine.",
5
5
  "main": "dist/main.js",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "bin": {
7
10
  "eas-cli-local-build-plugin": "./bin/run"
8
11
  },
@@ -20,7 +23,7 @@
20
23
  "bugs": "https://github.com/expo/eas-build/issues",
21
24
  "license": "BUSL-1.1",
22
25
  "dependencies": {
23
- "@expo/build-tools": "0.1.184",
26
+ "@expo/build-tools": "0.1.185",
24
27
  "@expo/bunyan": "^4.0.0",
25
28
  "@expo/eas-build-job": "0.2.106",
26
29
  "@expo/spawn-async": "^1.7.0",
package/src/android.ts DELETED
@@ -1,45 +0,0 @@
1
- import { bunyan } from '@expo/logger';
2
- import { Android, BuildPhase, Env } from '@expo/eas-build-job';
3
- import { Builders, BuildContext, ArtifactType, Artifacts } from '@expo/build-tools';
4
- import omit from 'lodash/omit';
5
-
6
- import logger, { logBuffer } from './logger';
7
- import { BuildParams } from './types';
8
- import { prepareArtifacts } from './artifacts';
9
- import config from './config';
10
- import { runGlobalExpoCliCommandAsync } from './expoCli';
11
-
12
- export async function buildAndroidAsync(
13
- job: Android.Job,
14
- { workingdir, env: baseEnv, metadata }: BuildParams
15
- ): Promise<Artifacts> {
16
- const versionName = job.version?.versionName;
17
- const versionCode = job.version?.versionCode;
18
- const env: Env = {
19
- ...baseEnv,
20
- ...(versionCode && { EAS_BUILD_ANDROID_VERSION_CODE: versionCode }),
21
- ...(versionName && { EAS_BUILD_ANDROID_VERSION_NAME: versionName }),
22
- };
23
- const ctx = new BuildContext<Android.Job>(job, {
24
- workingdir,
25
- logger,
26
- logBuffer,
27
- runGlobalExpoCliCommand: runGlobalExpoCliCommandAsync,
28
- uploadArtifacts: async (type: ArtifactType, paths: string[], logger?: bunyan) => {
29
- if (type !== ArtifactType.APPLICATION_ARCHIVE) {
30
- return null;
31
- } else {
32
- return await prepareArtifacts(paths, logger);
33
- }
34
- },
35
- env,
36
- metadata,
37
- skipNativeBuild: config.skipNativeBuild,
38
- });
39
-
40
- await ctx.runBuildPhase(BuildPhase.START_BUILD, async () => {
41
- ctx.logger.info({ job: omit(ctx.job, 'secrets') }, 'Starting build');
42
- });
43
-
44
- return await Builders.androidBuilder(ctx);
45
- }
package/src/artifacts.ts DELETED
@@ -1,56 +0,0 @@
1
- import path from 'path';
2
-
3
- import { bunyan } from '@expo/logger';
4
- import fs from 'fs-extra';
5
- import tar from 'tar';
6
-
7
- import config from './config';
8
-
9
- export async function prepareArtifacts(artifactPaths: string[], logger?: bunyan): Promise<string> {
10
- const l = logger?.child({ phase: 'PREPARE_ARTIFACTS' });
11
- l?.info('Preparing artifacts');
12
- let suffix;
13
- let localPath;
14
- if (artifactPaths.length === 1 && !(await fs.lstat(artifactPaths[0])).isDirectory()) {
15
- [localPath] = artifactPaths;
16
- suffix = path.extname(artifactPaths[0]);
17
- } else {
18
- const parentDir = artifactPaths.reduce(
19
- (acc, item) => getCommonParentDir(acc, item),
20
- artifactPaths[0]
21
- );
22
- const relativePathsToArchive = artifactPaths.map((absolute) =>
23
- path.relative(parentDir, absolute)
24
- );
25
-
26
- const archivePath = path.join(config.workingdir, 'artifacts.tar.gz');
27
- await tar.c(
28
- {
29
- gzip: true,
30
- file: archivePath,
31
- cwd: parentDir,
32
- },
33
- relativePathsToArchive
34
- );
35
- suffix = '.tar.gz';
36
- localPath = archivePath;
37
- }
38
- const artifactName = `build-${Date.now()}${suffix}`;
39
- const destPath = config.artifactPath ?? path.join(config.artifactsDir, artifactName);
40
- await fs.copy(localPath, destPath);
41
- l?.info({ phase: 'PREPARE_ARTIFACTS' }, `Writing artifacts to ${destPath}`);
42
- return destPath;
43
- }
44
-
45
- function getCommonParentDir(path1: string, path2: string): string {
46
- const normalizedPath1 = path.normalize(path1);
47
- const normalizedPath2 = path.normalize(path2);
48
- let current = path.dirname(normalizedPath1);
49
- while (current !== '/') {
50
- if (normalizedPath2.startsWith(current)) {
51
- return current;
52
- }
53
- current = path.dirname(current);
54
- }
55
- return '/';
56
- }
package/src/build.ts DELETED
@@ -1,88 +0,0 @@
1
- import path from 'path';
2
-
3
- import { Job, Platform, ArchiveSourceType, Metadata, Workflow } from '@expo/eas-build-job';
4
- import pickBy from 'lodash/pickBy';
5
- import fs from 'fs-extra';
6
- import chalk from 'chalk';
7
- import { Artifacts, SkipNativeBuildError } from '@expo/build-tools';
8
- import nullthrows from 'nullthrows';
9
-
10
- import { buildAndroidAsync } from './android';
11
- import config from './config';
12
- import { buildIosAsync } from './ios';
13
- import { prepareWorkingdirAsync } from './workingdir';
14
-
15
- export async function buildAsync(job: Job, metadata: Metadata): Promise<void> {
16
- const workingdir = await prepareWorkingdirAsync();
17
-
18
- try {
19
- let username = metadata.username;
20
- if (!username && job.type === Workflow.MANAGED) {
21
- username = job.username;
22
- }
23
-
24
- // keep in sync with worker env vars
25
- // https://github.com/expo/turtle-v2/blob/main/src/services/worker/src/env.ts
26
- const unfilteredEnv: Record<string, string | undefined> = {
27
- ...process.env,
28
- ...job.builderEnvironment?.env,
29
- EAS_BUILD: '1',
30
- EAS_BUILD_RUNNER: 'local-build-plugin',
31
- EAS_BUILD_PLATFORM: job.platform,
32
- EAS_BUILD_WORKINGDIR: path.join(workingdir, 'build'),
33
- EAS_BUILD_PROFILE: metadata.buildProfile,
34
- EAS_BUILD_GIT_COMMIT_HASH: metadata.gitCommitHash,
35
- EAS_BUILD_USERNAME: username,
36
- ...(job.platform === Platform.ANDROID && {
37
- EAS_BUILD_ANDROID_VERSION_CODE: job.version?.versionCode,
38
- EAS_BUILD_ANDROID_VERSION_NAME: job.version?.versionName,
39
- }),
40
- ...(job.platform === Platform.IOS && {
41
- EAS_BUILD_IOS_BUILD_NUMBER: job.version?.buildNumber,
42
- EAS_BUILD_IOS_APP_VERSION: job.version?.appVersion,
43
- }),
44
- };
45
- const env = pickBy(unfilteredEnv, (val?: string): val is string => !!val);
46
-
47
- let artifacts: Artifacts | undefined;
48
- switch (job.platform) {
49
- case Platform.ANDROID: {
50
- artifacts = await buildAndroidAsync(job, { env, workingdir, metadata });
51
- break;
52
- }
53
- case Platform.IOS: {
54
- artifacts = await buildIosAsync(job, { env, workingdir, metadata });
55
- break;
56
- }
57
- }
58
- if (!config.skipNativeBuild) {
59
- console.log();
60
- console.log(chalk.green('Build successful'));
61
- console.log(
62
- chalk.green(
63
- `You can find the build artifacts in ${nullthrows(artifacts.APPLICATION_ARCHIVE)}`
64
- )
65
- );
66
- }
67
- } catch (e: any) {
68
- if (e instanceof SkipNativeBuildError) {
69
- console.log(e.message);
70
- return;
71
- }
72
- console.error();
73
- console.error(chalk.red(`Build failed`));
74
- if (config.logger.level === 'debug') {
75
- console.error(e.innerError);
76
- }
77
- throw e;
78
- } finally {
79
- if (!config.skipCleanup) {
80
- await fs.remove(workingdir);
81
- } else {
82
- console.error(chalk.yellow(`Skipping cleanup, ${workingdir} won't be removed.`));
83
- }
84
- if (job.projectArchive.type === ArchiveSourceType.PATH) {
85
- await fs.remove(job.projectArchive.path);
86
- }
87
- }
88
- }
@@ -1,131 +0,0 @@
1
- import { Job, Platform } from '@expo/eas-build-job';
2
- import chalk from 'chalk';
3
- import spawnAsync from '@expo/spawn-async';
4
- import fs from 'fs-extra';
5
-
6
- interface Validator {
7
- platform?: Platform;
8
- checkAsync: (job: Job) => Promise<void>;
9
- }
10
-
11
- function warn(msg: string): void {
12
- console.log(chalk.yellow(msg));
13
- }
14
-
15
- function error(msg: string): void {
16
- console.error(chalk.red(msg));
17
- }
18
-
19
- const validators: Validator[] = [
20
- {
21
- async checkAsync(job: Job) {
22
- if (job.platform === Platform.IOS && process.platform !== 'darwin') {
23
- throw new Error('iOS builds can only be run on macOS.');
24
- } else if (
25
- job.platform === Platform.ANDROID &&
26
- !['linux', 'darwin'].includes(process.platform)
27
- ) {
28
- throw new Error('Android builds are supported only on Linux and macOS');
29
- }
30
- },
31
- },
32
- {
33
- async checkAsync(job: Job) {
34
- try {
35
- const version = (await spawnAsync('node', ['--version'], { stdio: 'pipe' })).stdout.trim();
36
- const sanitizedVersion = version.startsWith('v') ? version.slice(1) : version;
37
- const versionFromJob = job.builderEnvironment?.node;
38
- if (versionFromJob) {
39
- const sanitizedVersionFromJob = versionFromJob.startsWith('v')
40
- ? versionFromJob.slice(1)
41
- : versionFromJob;
42
- if (sanitizedVersion !== sanitizedVersionFromJob) {
43
- warn(
44
- 'Node.js version in your eas.json does not match the Node.js currently installed in your system'
45
- );
46
- }
47
- }
48
- } catch (err) {
49
- error("Node.js is not available, make sure it's installed and in your PATH");
50
- throw err;
51
- }
52
- },
53
- },
54
- {
55
- async checkAsync(job: Job) {
56
- const versionFromJob = job.builderEnvironment?.yarn;
57
- if (!versionFromJob) {
58
- return;
59
- }
60
- try {
61
- const version = (await spawnAsync('yarn', ['--version'], { stdio: 'pipe' })).stdout.trim();
62
- if (versionFromJob !== version) {
63
- warn(
64
- 'Yarn version in your eas.json does not match the yarn currently installed in your system'
65
- );
66
- }
67
- } catch {
68
- warn("Yarn is not available, make sure it's installed and in your PATH");
69
- }
70
- },
71
- },
72
- {
73
- platform: Platform.ANDROID,
74
- async checkAsync(_) {
75
- if (!process.env.ANDROID_NDK_HOME) {
76
- warn(
77
- 'ANDROID_NDK_HOME environment variable was not specified, continuing build without NDK'
78
- );
79
- return;
80
- }
81
- if (!(await fs.pathExists(process.env.ANDROID_NDK_HOME))) {
82
- throw new Error(`NDK was not found under ${process.env.ANDROID_NDK_HOME}`);
83
- }
84
- },
85
- },
86
- {
87
- platform: Platform.IOS,
88
- async checkAsync() {
89
- try {
90
- await spawnAsync('fastlane', ['--version'], {
91
- stdio: 'pipe',
92
- env: {
93
- ...process.env,
94
- FASTLANE_DISABLE_COLORS: '1',
95
- FASTLANE_SKIP_UPDATE_CHECK: '1',
96
- SKIP_SLOW_FASTLANE_WARNING: 'true',
97
- FASTLANE_HIDE_TIMESTAMP: 'true',
98
- },
99
- });
100
- } catch (err) {
101
- error("Fastlane is not available, make sure it's installed and in your PATH");
102
- throw err;
103
- }
104
- },
105
- },
106
- {
107
- platform: Platform.IOS,
108
- async checkAsync(job: Job) {
109
- try {
110
- const version = (await spawnAsync('pod', ['--version'], { stdio: 'pipe' })).stdout.trim();
111
- const versionFromJob = job.platform === Platform.IOS && job.builderEnvironment?.cocoapods;
112
- if (versionFromJob && versionFromJob !== version) {
113
- warn(
114
- 'Cocoapods version in your eas.json does not match the version currently installed in your system'
115
- );
116
- }
117
- } catch (err) {
118
- error("Cocoapods is not available, make sure it's installed and in your PATH");
119
- throw err;
120
- }
121
- },
122
- },
123
- ];
124
-
125
- export async function checkRuntimeAsync(job: Job): Promise<void> {
126
- for (const validator of validators) {
127
- if (validator.platform === job.platform || !validator.platform) {
128
- await validator.checkAsync(job);
129
- }
130
- }
131
- }
package/src/config.ts DELETED
@@ -1,30 +0,0 @@
1
- import path from 'path';
2
-
3
- import { v4 as uuidv4 } from 'uuid';
4
- import envPaths from 'env-paths';
5
-
6
- const { temp } = envPaths('eas-build-local');
7
-
8
- const envLoggerLevel = process.env.EAS_LOCAL_BUILD_LOGGER_LEVEL;
9
- const envWorkingdir = process.env.EAS_LOCAL_BUILD_WORKINGDIR;
10
- const envSkipCleanup = process.env.EAS_LOCAL_BUILD_SKIP_CLEANUP;
11
- const envSkipNativeBuild = process.env.EAS_LOCAL_BUILD_SKIP_NATIVE_BUILD;
12
- const envArtifactsDir = process.env.EAS_LOCAL_BUILD_ARTIFACTS_DIR;
13
- const envArtifactPath = process.env.EAS_LOCAL_BUILD_ARTIFACT_PATH;
14
-
15
- if (envLoggerLevel && !['debug', 'info', 'warn', 'error'].includes(envLoggerLevel)) {
16
- throw new Error(
17
- 'Invalid value for EAS_LOCAL_BUILD_LOGGER_LEVEL, one of info, warn, or error is expected'
18
- );
19
- }
20
-
21
- export default {
22
- workingdir: envWorkingdir ?? path.join(temp, uuidv4()),
23
- skipCleanup: envSkipCleanup === '1',
24
- skipNativeBuild: envSkipNativeBuild === '1',
25
- artifactsDir: envArtifactsDir ?? process.cwd(),
26
- artifactPath: envArtifactPath,
27
- logger: {
28
- level: (envLoggerLevel ?? 'info') as 'debug' | 'info' | 'warn' | 'error',
29
- },
30
- };
package/src/exit.ts DELETED
@@ -1,39 +0,0 @@
1
- import logger from './logger';
2
-
3
- const handlers: (() => void | Promise<void>)[] = [];
4
- let shouldExitStatus = false;
5
-
6
- export function listenForInterrupts(): void {
7
- let handlerInProgress = false;
8
- const handleExit = async (): Promise<void> => {
9
- try {
10
- // when eas-cli calls childProcess.kill() local build receives
11
- // signal twice in some cases
12
- if (handlerInProgress) {
13
- return;
14
- }
15
- handlerInProgress = true;
16
- logger.error({ phase: 'ABORT' }, 'Received termination signal.');
17
- shouldExitStatus = true;
18
- await Promise.allSettled(
19
- handlers.map((handler) => {
20
- return handler();
21
- })
22
- );
23
- } finally {
24
- handlerInProgress = false;
25
- }
26
- process.exit(1);
27
- };
28
-
29
- process.on('SIGTERM', handleExit);
30
- process.on('SIGINT', handleExit);
31
- }
32
-
33
- export function registerHandler(fn: () => void | Promise<void>): void {
34
- handlers.push(fn);
35
- }
36
-
37
- export function shouldExit(): boolean {
38
- return shouldExitStatus;
39
- }
package/src/expoCli.ts DELETED
@@ -1,24 +0,0 @@
1
- import spawnAsync, { SpawnOptions, SpawnPromise, SpawnResult } from '@expo/turtle-spawn';
2
-
3
- const EXPO_CLI_VERSION = '6.0.5';
4
-
5
- export function runGlobalExpoCliCommandAsync(
6
- expoCliArgs: string[],
7
- options: SpawnOptions,
8
- npmVersionAtLeast7: boolean
9
- ): SpawnPromise<SpawnResult> {
10
- if (process.env.EXPO_CLI_PATH) {
11
- const expoCliBinPath = process.env.EXPO_CLI_PATH;
12
- const expoCliCommandWithArgs = expoCliArgs.join(' ');
13
- options?.logger?.debug(`${expoCliBinPath} ${expoCliCommandWithArgs}`);
14
- return spawnAsync('bash', ['-c', `${expoCliBinPath} ${expoCliCommandWithArgs}`], options);
15
- } else {
16
- const args = [`expo-cli@${EXPO_CLI_VERSION}`, ...expoCliArgs];
17
- if (npmVersionAtLeast7) {
18
- // npx shipped with npm >= 7.0.0 requires the "-y" flag to run commands without
19
- // prompting the user to install a package that is used for the first time
20
- args.unshift('-y');
21
- }
22
- return spawnAsync('npx', args, options);
23
- }
24
- }
package/src/ios.ts DELETED
@@ -1,45 +0,0 @@
1
- import { Ios, BuildPhase, Env } from '@expo/eas-build-job';
2
- import { Builders, BuildContext, ArtifactType, Artifacts } from '@expo/build-tools';
3
- import { bunyan } from '@expo/logger';
4
- import omit from 'lodash/omit';
5
-
6
- import { runGlobalExpoCliCommandAsync } from './expoCli';
7
- import logger, { logBuffer } from './logger';
8
- import { BuildParams } from './types';
9
- import { prepareArtifacts } from './artifacts';
10
- import config from './config';
11
-
12
- export async function buildIosAsync(
13
- job: Ios.Job,
14
- { workingdir, env: baseEnv, metadata }: BuildParams
15
- ): Promise<Artifacts> {
16
- const buildNumber = job.version?.buildNumber;
17
- const appVersion = job.version?.appVersion;
18
- const env: Env = {
19
- ...baseEnv,
20
- ...(buildNumber && { EAS_BUILD_IOS_BUILD_NUMBER: buildNumber }),
21
- ...(appVersion && { EAS_BUILD_IOS_APP_VERSION: appVersion }),
22
- };
23
- const ctx = new BuildContext<Ios.Job>(job, {
24
- workingdir,
25
- logger,
26
- logBuffer,
27
- runGlobalExpoCliCommand: runGlobalExpoCliCommandAsync,
28
- uploadArtifacts: async (type: ArtifactType, paths: string[], logger?: bunyan) => {
29
- if (type !== ArtifactType.APPLICATION_ARCHIVE) {
30
- return null;
31
- } else {
32
- return await prepareArtifacts(paths, logger);
33
- }
34
- },
35
- env,
36
- metadata,
37
- skipNativeBuild: config.skipNativeBuild,
38
- });
39
-
40
- await ctx.runBuildPhase(BuildPhase.START_BUILD, async () => {
41
- ctx.logger.info({ job: omit(ctx.job, 'secrets') }, 'Starting build');
42
- });
43
-
44
- return await Builders.iosBuilder(ctx);
45
- }
package/src/logger.ts DELETED
@@ -1,138 +0,0 @@
1
- import { Writable } from 'stream';
2
-
3
- import bunyan from '@expo/bunyan';
4
- import chalk from 'chalk';
5
- import omit from 'lodash/omit';
6
- import { LogBuffer } from '@expo/build-tools';
7
-
8
- import config from './config';
9
-
10
- interface Log {
11
- msg: string;
12
- level: number;
13
- err?: any;
14
- marker?: string;
15
- phase: string;
16
- source: 'stdout' | 'stderr';
17
- }
18
- const MAX_LINES_IN_BUFFER = 100;
19
-
20
- interface CachedLog {
21
- msg: string;
22
- phase: string;
23
- }
24
-
25
- class BuildCliLogBuffer extends Writable implements LogBuffer {
26
- public writable = true;
27
- public buffer: CachedLog[] = [];
28
-
29
- constructor(private readonly numberOfLines: number) {
30
- super();
31
- }
32
-
33
- public write(rec: any): boolean {
34
- if (
35
- // verify required fields
36
- typeof rec !== 'object' ||
37
- typeof rec?.msg !== 'string' ||
38
- typeof rec?.phase !== 'string' ||
39
- // use only logs from spawn commands
40
- (rec?.source !== 'stdout' && rec?.source !== 'stderr') ||
41
- // skip all short lines (it could potentially be some loader)
42
- (rec?.msg ?? '').length < 3
43
- ) {
44
- return true;
45
- }
46
- if (this.buffer.length >= this.numberOfLines) {
47
- this.buffer.shift();
48
- }
49
- this.buffer.push({ msg: rec.msg, phase: rec.phase });
50
- return true;
51
- }
52
-
53
- public getLogs(): string[] {
54
- return this.buffer.map(({ msg }) => msg);
55
- }
56
-
57
- public getPhaseLogs(buildPhase: string): string[] {
58
- return this.buffer.filter(({ phase }) => phase === buildPhase).map(({ msg }) => msg);
59
- }
60
- }
61
-
62
- class PrettyStream extends Writable {
63
- write(rawLog: string): boolean {
64
- const log = JSON.parse(rawLog) as Log;
65
- if (log.marker) {
66
- return true;
67
- }
68
- const msg = this.formatMessage(log);
69
- if (log.level >= bunyan.ERROR || log.source === 'stderr') {
70
- console.error(msg);
71
- } else {
72
- console.log(msg);
73
- }
74
-
75
- const extraProperties = omit(log, [
76
- 'msg',
77
- 'err',
78
- 'level',
79
- 'phase',
80
- 'marker',
81
- 'source',
82
- 'time',
83
- 'id',
84
- 'v',
85
- 'pid',
86
- 'hostname',
87
- 'name',
88
- ]);
89
- if (Object.keys(extraProperties).length !== 0) {
90
- const str = JSON.stringify(extraProperties, null, 2);
91
- // substring removes `{\n` and `\n}`
92
- console.log(chalk.gray(str.substring(2, str.length - 2)));
93
- }
94
- if (log?.err?.stack) {
95
- console.error(chalk.red(log.err.stack));
96
- }
97
- return true;
98
- }
99
-
100
- private formatMessage(log: Log): string {
101
- const phase = log.phase;
102
- switch (log.level) {
103
- case bunyan.DEBUG:
104
- return `[${phase}] ${chalk.gray(log.msg)}`;
105
- case bunyan.INFO: {
106
- const msg = log.source === 'stderr' ? chalk.red(log.msg) : log.msg;
107
- return `[${phase}] ${msg}`;
108
- }
109
- case bunyan.WARN:
110
- return `[${phase}] ${chalk.yellow(log.msg)}`;
111
- case bunyan.ERROR:
112
- return `[${phase}] ${chalk.red(log.msg)}`;
113
- case bunyan.FATAL:
114
- return `[${phase}] ${chalk.red(log.msg)}`;
115
- default:
116
- return log.msg;
117
- }
118
- }
119
- }
120
-
121
- export const logBuffer = new BuildCliLogBuffer(MAX_LINES_IN_BUFFER);
122
-
123
- const defaultlogger = bunyan.createLogger({
124
- name: 'eas-build-cli',
125
- serializers: bunyan.stdSerializers,
126
- streams: [
127
- {
128
- level: config.logger.level,
129
- stream: new PrettyStream(),
130
- },
131
- {
132
- level: 'info',
133
- stream: logBuffer,
134
- },
135
- ],
136
- });
137
-
138
- export default defaultlogger;
package/src/main.ts DELETED
@@ -1,23 +0,0 @@
1
- import chalk from 'chalk';
2
-
3
- import { parseInputAsync } from './parseInput';
4
- import { buildAsync } from './build';
5
- import { listenForInterrupts, shouldExit } from './exit';
6
- import { checkRuntimeAsync } from './checkRuntime';
7
-
8
- listenForInterrupts();
9
-
10
- async function main(): Promise<void> {
11
- try {
12
- const { job, metadata } = await parseInputAsync();
13
- await checkRuntimeAsync(job);
14
- await buildAsync(job, metadata);
15
- } catch (err: any) {
16
- if (!shouldExit()) {
17
- console.error(chalk.red(err.message));
18
- process.exit(1);
19
- }
20
- }
21
- }
22
-
23
- void main();
package/src/parseInput.ts DELETED
@@ -1,85 +0,0 @@
1
- import {
2
- Job,
3
- sanitizeJob,
4
- ArchiveSourceType,
5
- Metadata,
6
- sanitizeMetadata,
7
- } from '@expo/eas-build-job';
8
- import Joi from 'joi';
9
- import chalk from 'chalk';
10
- import fs from 'fs-extra';
11
-
12
- import { registerHandler } from './exit';
13
-
14
- const packageJson = require('../package.json');
15
-
16
- interface Params {
17
- job: Job;
18
- metadata: Metadata;
19
- }
20
-
21
- const ParamsSchema = Joi.object<Params>({
22
- job: Joi.object().unknown(),
23
- metadata: Joi.object().unknown(),
24
- });
25
-
26
- export async function parseInputAsync(): Promise<Params> {
27
- if (process.argv.findIndex((arg) => arg === '--version' || arg === '-v') !== -1) {
28
- console.log(packageJson.version);
29
- process.exit(0);
30
- }
31
- const rawInput = process.argv[2];
32
-
33
- if (!rawInput) {
34
- displayHelp();
35
- process.exit(1);
36
- }
37
- let parsedParams;
38
- try {
39
- parsedParams = JSON.parse(Buffer.from(rawInput, 'base64').toString('utf8'));
40
- } catch (err) {
41
- console.error(`${chalk.red('The input passed as a argument is not base64 encoded json.')}`);
42
- throw err;
43
- }
44
- const params = validateParams(parsedParams);
45
- registerHandler(async () => {
46
- if (params.job.projectArchive.type === ArchiveSourceType.PATH) {
47
- await fs.remove(params.job.projectArchive.path);
48
- }
49
- });
50
- return params;
51
- }
52
-
53
- function validateParams(params: object): Params {
54
- const { value, error } = ParamsSchema.validate(params, {
55
- stripUnknown: true,
56
- convert: true,
57
- abortEarly: false,
58
- });
59
- if (error) {
60
- throw error;
61
- }
62
- try {
63
- const job = sanitizeJob(value.job);
64
- const metadata = sanitizeMetadata(value.metadata);
65
- return { ...value, job, metadata };
66
- } catch (err) {
67
- console.log(`Currently using ${packageJson.name}@${packageJson.version}.`);
68
- console.error(
69
- chalk.red(
70
- `Job object has incorrect format, update to latest versions of ${chalk.bold(
71
- 'eas-cli'
72
- )} and ${chalk.bold(packageJson.name)} to make sure you are using compatible packages.`
73
- )
74
- );
75
- throw err;
76
- }
77
- }
78
-
79
- function displayHelp(): void {
80
- console.log(
81
- `This tool is not intended for standalone use, it will be used internally by ${chalk.bold(
82
- 'eas-cli'
83
- )} when building with flag ${chalk.bold('--local')}.`
84
- );
85
- }
package/src/types.ts DELETED
@@ -1,7 +0,0 @@
1
- import { Metadata } from '@expo/eas-build-job';
2
-
3
- export interface BuildParams {
4
- workingdir: string;
5
- env: Record<string, string>;
6
- metadata: Metadata;
7
- }
package/src/workingdir.ts DELETED
@@ -1,29 +0,0 @@
1
- import path from 'path';
2
-
3
- import chalk from 'chalk';
4
- import fs from 'fs-extra';
5
-
6
- import config from './config';
7
- import logger from './logger';
8
- import { registerHandler } from './exit';
9
-
10
- export async function prepareWorkingdirAsync(): Promise<string> {
11
- const { workingdir } = config;
12
- logger.info({ phase: 'SETUP_WORKINGDIR' }, `Preparing workingdir ${workingdir}`);
13
-
14
- if ((await fs.pathExists(workingdir)) && (await fs.readdir(workingdir)).length > 0) {
15
- throw new Error('Workingdir is not empty.');
16
- }
17
- await fs.mkdirp(path.join(workingdir, 'artifacts'));
18
- await fs.mkdirp(path.join(workingdir, 'build'));
19
- registerHandler(async () => {
20
- if (!config.skipCleanup) {
21
- await fs.remove(workingdir);
22
- } else {
23
- console.error(
24
- chalk.yellow("EAS_LOCAL_BUILD_SKIP_CLEANUP is set, working dir won't be removed.")
25
- );
26
- }
27
- });
28
- return workingdir;
29
- }
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "exclude": ["src/**/__mocks__/**/*.ts", "src/**/__test__/**/*.ts"]
4
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./dist"
5
- },
6
- "include": [
7
- "src/**/*"
8
- ]
9
- }