@expo/steps
Advanced tools
Comparing version 1.0.137 to 1.0.138
@@ -35,2 +35,3 @@ import { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js'; | ||
constructor(id: string, displayName: string, executed: boolean, outputById: BuildStepOutputById); | ||
get outputs(): BuildStepOutput[]; | ||
getOutputValueByName(name: string): string | undefined; | ||
@@ -82,4 +83,5 @@ hasOutputParameter(name: string): boolean; | ||
canBeRunOnRuntimePlatform(): boolean; | ||
shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean; | ||
shouldExecuteStep(): boolean; | ||
skip(): void; | ||
private getInterpolationContext; | ||
private executeCommandAsync; | ||
@@ -86,0 +88,0 @@ private executeFnAsync; |
@@ -1,2 +0,2 @@ | ||
import { BuildStaticContext } from '@expo/eas-build-job'; | ||
import { StaticJobInterpolationContext } from '@expo/eas-build-job'; | ||
import { bunyan } from '@expo/logger'; | ||
@@ -12,3 +12,3 @@ import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep.js'; | ||
runtimePlatform: BuildRuntimePlatform; | ||
staticContext: BuildStaticContext; | ||
staticContext: Omit<StaticJobInterpolationContext, 'steps'>; | ||
env: BuildStepEnv; | ||
@@ -23,3 +23,3 @@ } | ||
readonly logger: bunyan; | ||
readonly staticContext: () => BuildStaticContext; | ||
readonly staticContext: () => Omit<StaticJobInterpolationContext, 'steps'>; | ||
readonly env: BuildStepEnv; | ||
@@ -41,2 +41,3 @@ updateEnv(env: BuildStepEnv): void; | ||
private didCheckOut; | ||
private _hasAnyPreviousStepFailed; | ||
private stepById; | ||
@@ -49,3 +50,3 @@ constructor(provider: ExternalBuildContextProvider, skipCleanup: boolean); | ||
get env(): BuildStepEnv; | ||
get staticContext(): BuildStaticContext; | ||
get staticContext(): StaticJobInterpolationContext; | ||
updateEnv(updatedEnv: BuildStepEnv): void; | ||
@@ -60,2 +61,4 @@ registerStep(step: BuildStep): void; | ||
markAsCheckedOut(logger: bunyan): void; | ||
get hasAnyPreviousStepFailed(): boolean; | ||
markAsFailed(): void; | ||
wasCheckedOut(): boolean; | ||
@@ -62,0 +65,0 @@ serialize(): SerializedBuildStepGlobalContext; |
@@ -1,2 +0,2 @@ | ||
import { BuildStaticContext } from '@expo/eas-build-job'; | ||
import { StaticJobInterpolationContext } from '@expo/eas-build-job'; | ||
import { bunyan } from '@expo/logger'; | ||
@@ -16,4 +16,4 @@ import { ExternalBuildContextProvider } from '../BuildStepContext.js'; | ||
get env(): BuildStepEnv; | ||
staticContext(): BuildStaticContext; | ||
staticContext(): Omit<StaticJobInterpolationContext, 'steps'>; | ||
updateEnv(env: BuildStepEnv): void; | ||
} |
@@ -15,3 +15,4 @@ export { BuildStepContext } from './BuildStepContext.js'; | ||
export * as errors from './errors.js'; | ||
export * from './interpolation.js'; | ||
export * from './utils/shell/spawn.js'; | ||
export * from './utils/jsepEval.js'; |
@@ -35,2 +35,3 @@ import { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js'; | ||
constructor(id: string, displayName: string, executed: boolean, outputById: BuildStepOutputById); | ||
get outputs(): BuildStepOutput[]; | ||
getOutputValueByName(name: string): string | undefined; | ||
@@ -82,4 +83,5 @@ hasOutputParameter(name: string): boolean; | ||
canBeRunOnRuntimePlatform(): boolean; | ||
shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean; | ||
shouldExecuteStep(): boolean; | ||
skip(): void; | ||
private getInterpolationContext; | ||
private executeCommandAsync; | ||
@@ -86,0 +88,0 @@ private executeFnAsync; |
@@ -14,2 +14,3 @@ import assert from 'assert'; | ||
import { jsepEval } from './utils/jsepEval.js'; | ||
import { interpolateJobContext } from './interpolation.js'; | ||
export var BuildStepStatus; | ||
@@ -38,2 +39,5 @@ (function (BuildStepStatus) { | ||
} | ||
get outputs() { | ||
return Object.values(this.outputById); | ||
} | ||
getOutputValueByName(name) { | ||
@@ -163,6 +167,7 @@ if (!this.executed) { | ||
} | ||
shouldExecuteStep(hasAnyPreviousStepsFailed) { | ||
shouldExecuteStep() { | ||
var _a, _b; | ||
const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed; | ||
if (!this.ifCondition) { | ||
return !hasAnyPreviousStepsFailed; | ||
return !hasAnyPreviousStepFailed; | ||
} | ||
@@ -174,4 +179,4 @@ let ifCondition = this.ifCondition; | ||
return Boolean(jsepEval(ifCondition, { | ||
success: () => !hasAnyPreviousStepsFailed, | ||
failure: () => hasAnyPreviousStepsFailed, | ||
success: () => !hasAnyPreviousStepFailed, | ||
failure: () => hasAnyPreviousStepFailed, | ||
always: () => true, | ||
@@ -196,5 +201,22 @@ never: () => false, | ||
} | ||
getInterpolationContext() { | ||
const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed; | ||
return { | ||
...this.ctx.global.staticContext, | ||
always: () => true, | ||
never: () => false, | ||
success: () => !hasAnyPreviousStepFailed, | ||
failure: () => hasAnyPreviousStepFailed, | ||
env: this.getScriptEnv(), | ||
fromJSON: (json) => JSON.parse(json), | ||
toJSON: (value) => JSON.stringify(value), | ||
}; | ||
} | ||
async executeCommandAsync() { | ||
assert(this.command, 'Command must be defined.'); | ||
const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(this.command, this.inputs); | ||
const interpolatedCommand = interpolateJobContext({ | ||
target: this.command, | ||
context: this.getInterpolationContext(), | ||
}); | ||
const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(`${interpolatedCommand}`, this.inputs); | ||
this.ctx.logger.debug(`Interpolated inputs in the command template`); | ||
@@ -201,0 +223,0 @@ const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command); |
@@ -1,2 +0,2 @@ | ||
import { BuildStaticContext } from '@expo/eas-build-job'; | ||
import { StaticJobInterpolationContext } from '@expo/eas-build-job'; | ||
import { bunyan } from '@expo/logger'; | ||
@@ -12,3 +12,3 @@ import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep.js'; | ||
runtimePlatform: BuildRuntimePlatform; | ||
staticContext: BuildStaticContext; | ||
staticContext: Omit<StaticJobInterpolationContext, 'steps'>; | ||
env: BuildStepEnv; | ||
@@ -23,3 +23,3 @@ } | ||
readonly logger: bunyan; | ||
readonly staticContext: () => BuildStaticContext; | ||
readonly staticContext: () => Omit<StaticJobInterpolationContext, 'steps'>; | ||
readonly env: BuildStepEnv; | ||
@@ -41,2 +41,3 @@ updateEnv(env: BuildStepEnv): void; | ||
private didCheckOut; | ||
private _hasAnyPreviousStepFailed; | ||
private stepById; | ||
@@ -49,3 +50,3 @@ constructor(provider: ExternalBuildContextProvider, skipCleanup: boolean); | ||
get env(): BuildStepEnv; | ||
get staticContext(): BuildStaticContext; | ||
get staticContext(): StaticJobInterpolationContext; | ||
updateEnv(updatedEnv: BuildStepEnv): void; | ||
@@ -60,2 +61,4 @@ registerStep(step: BuildStep): void; | ||
markAsCheckedOut(logger: bunyan): void; | ||
get hasAnyPreviousStepFailed(): boolean; | ||
markAsFailed(): void; | ||
wasCheckedOut(): boolean; | ||
@@ -62,0 +65,0 @@ serialize(): SerializedBuildStepGlobalContext; |
@@ -12,2 +12,3 @@ import os from 'os'; | ||
this.didCheckOut = false; | ||
this._hasAnyPreviousStepFailed = false; | ||
this.stepById = {}; | ||
@@ -17,2 +18,3 @@ this.stepsInternalBuildDirectory = path.join(os.tmpdir(), 'eas-build', uuidv4()); | ||
this.baseLogger = provider.logger; | ||
this._hasAnyPreviousStepFailed = false; | ||
} | ||
@@ -35,3 +37,13 @@ get projectSourceDirectory() { | ||
get staticContext() { | ||
return this.provider.staticContext(); | ||
return { | ||
...this.provider.staticContext(), | ||
steps: Object.fromEntries(Object.values(this.stepById).map((step) => [ | ||
step.id, | ||
{ | ||
outputs: Object.fromEntries(step.outputs.map((output) => { | ||
return [output.id, output.rawValue]; | ||
})), | ||
}, | ||
])), | ||
}; | ||
} | ||
@@ -69,2 +81,8 @@ updateEnv(updatedEnv) { | ||
} | ||
get hasAnyPreviousStepFailed() { | ||
return this._hasAnyPreviousStepFailed; | ||
} | ||
markAsFailed() { | ||
this._hasAnyPreviousStepFailed = true; | ||
} | ||
wasCheckedOut() { | ||
@@ -71,0 +89,0 @@ return this.didCheckOut; |
export class BuildWorkflow { | ||
constructor( | ||
// @ts-expect-error ctx is not used in this class but let's keep it here for consistency | ||
ctx, { buildSteps, buildFunctions }) { | ||
constructor(ctx, { buildSteps, buildFunctions }) { | ||
this.ctx = ctx; | ||
@@ -11,7 +9,6 @@ this.buildSteps = buildSteps; | ||
let maybeError = null; | ||
let hasAnyPreviousStepFailed = false; | ||
for (const step of this.buildSteps) { | ||
let shouldExecuteStep = false; | ||
try { | ||
shouldExecuteStep = step.shouldExecuteStep(hasAnyPreviousStepFailed); | ||
shouldExecuteStep = step.shouldExecuteStep(); | ||
} | ||
@@ -22,3 +19,3 @@ catch (err) { | ||
maybeError = maybeError !== null && maybeError !== void 0 ? maybeError : err; | ||
hasAnyPreviousStepFailed = true; | ||
this.ctx.markAsFailed(); | ||
} | ||
@@ -31,3 +28,3 @@ if (shouldExecuteStep) { | ||
maybeError = maybeError !== null && maybeError !== void 0 ? maybeError : err; | ||
hasAnyPreviousStepFailed = true; | ||
this.ctx.markAsFailed(); | ||
} | ||
@@ -34,0 +31,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { BuildStaticContext } from '@expo/eas-build-job'; | ||
import { StaticJobInterpolationContext } from '@expo/eas-build-job'; | ||
import { bunyan } from '@expo/logger'; | ||
@@ -16,4 +16,4 @@ import { ExternalBuildContextProvider } from '../BuildStepContext.js'; | ||
get env(): BuildStepEnv; | ||
staticContext(): BuildStaticContext; | ||
staticContext(): Omit<StaticJobInterpolationContext, 'steps'>; | ||
updateEnv(env: BuildStepEnv): void; | ||
} |
@@ -15,3 +15,4 @@ export { BuildStepContext } from './BuildStepContext.js'; | ||
export * as errors from './errors.js'; | ||
export * from './interpolation.js'; | ||
export * from './utils/shell/spawn.js'; | ||
export * from './utils/jsepEval.js'; |
@@ -14,4 +14,5 @@ export { BuildStepContext } from './BuildStepContext.js'; | ||
export * as errors from './errors.js'; | ||
export * from './interpolation.js'; | ||
export * from './utils/shell/spawn.js'; | ||
export * from './utils/jsepEval.js'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@expo/steps", | ||
"type": "module", | ||
"version": "1.0.137", | ||
"version": "1.0.138", | ||
"main": "./dist_commonjs/index.cjs", | ||
@@ -51,3 +51,3 @@ "types": "./dist_esm/index.d.ts", | ||
"dependencies": { | ||
"@expo/eas-build-job": "1.0.137", | ||
"@expo/eas-build-job": "1.0.138", | ||
"@expo/logger": "1.0.117", | ||
@@ -69,3 +69,3 @@ "@expo/spawn-async": "^1.7.2", | ||
}, | ||
"gitHead": "8f804d35f40bf8fbfc3be65fbe06f4ec22a5431f" | ||
"gitHead": "26d84bf5986167f7e24524a98db0ec222b5e8b6c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
710220
180
6101
+ Added@expo/eas-build-job@1.0.138(transitive)
- Removed@expo/eas-build-job@1.0.137(transitive)
Updated@expo/eas-build-job@1.0.138