@expo/steps 18.2.0 → 18.5.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.
@@ -59,16 +59,21 @@ class BuildConfigParser extends AbstractConfigParser_1.AbstractConfigParser {
59
59
  createBuildStepFromBuildStepCommandRun({ run }) {
60
60
  const { id: maybeId, inputs: inputsConfig, outputs: outputsConfig, name, workingDirectory, shell, command, env, if: ifCondition, timeout_minutes, __metrics_id, } = run;
61
61
  const id = BuildStep_1.BuildStep.getNewId(maybeId);
62
- const displayName = BuildStep_1.BuildStep.getDisplayName({ id, name, command });
62
+ const displayName = name ??
63
+ maybeId ??
64
+ command
65
+ .split('\n')
66
+ .find(line => line.trim())
67
+ ?.trim() ??
68
+ command;
63
69
  const inputs = inputsConfig && this.createBuildStepInputsFromDefinition(inputsConfig, displayName);
64
70
  const outputs = outputsConfig && this.createBuildStepOutputsFromDefinition(outputsConfig, displayName);
65
71
  const timeoutMs = timeout_minutes !== undefined ? timeout_minutes * 60 * 1000 : undefined;
66
72
  return new BuildStep_1.BuildStep(this.ctx, {
67
73
  id,
74
+ displayName,
68
75
  inputs,
69
76
  outputs,
70
- name,
71
- displayName,
72
77
  workingDirectory,
73
78
  shell,
74
79
  command,
@@ -80,7 +85,10 @@ class BuildConfigParser extends AbstractConfigParser_1.AbstractConfigParser {
80
85
  }
81
86
  createBuildStepFromBuildStepBareCommandRun({ run: command, }) {
82
87
  const id = BuildStep_1.BuildStep.getNewId();
83
- const displayName = BuildStep_1.BuildStep.getDisplayName({ id, command });
88
+ const displayName = command
89
+ .split('\n')
90
+ .find(line => line.trim())
91
+ ?.trim() ?? command;
84
92
  return new BuildStep_1.BuildStep(this.ctx, {
85
93
  id,
86
94
  displayName,
@@ -42,11 +42,7 @@ class BuildFunction {
42
42
  createBuildStepFromFunctionCall(ctx, { id, name, callInputs = {}, workingDirectory, shell, env, ifCondition, timeoutMs, } = {}) {
43
43
  const buildStepId = BuildStep_1.BuildStep.getNewId(id);
44
44
  const buildStepName = name ?? this.name;
45
- const buildStepDisplayName = BuildStep_1.BuildStep.getDisplayName({
46
- id: buildStepId,
47
- command: this.command,
48
- name: buildStepName,
49
- });
45
+ const buildStepDisplayName = buildStepName ?? id ?? this.getFullId();
50
46
  const inputs = this.inputProviders?.map(inputProvider => {
51
47
  const input = inputProvider(ctx, buildStepId);
52
48
  if (input.id in callInputs) {
@@ -57,7 +53,6 @@ class BuildFunction {
57
53
  const outputs = this.outputProviders?.map(outputProvider => outputProvider(ctx, buildStepId));
58
54
  return new BuildStep_1.BuildStep(ctx, {
59
55
  id: buildStepId,
60
- name: buildStepName,
61
56
  displayName: buildStepDisplayName,
62
57
  command: this.command,
63
58
  fn: this.fn ??
@@ -44,8 +44,8 @@ export declare class BuildStepOutputAccessor {
44
44
  static deserialize(serialized: SerializedBuildStepOutputAccessor): BuildStepOutputAccessor;
45
45
  }
46
46
  export declare class BuildStep extends BuildStepOutputAccessor {
47
+ private static nextGeneratedId;
47
48
  readonly id: string;
48
- readonly name?: string;
49
49
  readonly displayName: string;
50
50
  readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];
51
51
  readonly inputs?: BuildStepInput[];
@@ -61,18 +61,11 @@ export declare class BuildStep extends BuildStepOutputAccessor {
61
61
  status: BuildStepStatus;
62
62
  private readonly outputsDir;
63
63
  private readonly envsDir;
64
- private readonly internalId;
65
64
  private readonly inputById;
66
65
  protected executed: boolean;
67
66
  static getNewId(userDefinedId?: string): string;
68
- static getDisplayName({ id, name, command, }: {
67
+ constructor(ctx: BuildStepGlobalContext, { id, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, __metricsId, }: {
69
68
  id: string;
70
- name?: string;
71
- command?: string;
72
- }): string;
73
- constructor(ctx: BuildStepGlobalContext, { id, name, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, __metricsId, }: {
74
- id: string;
75
- name?: string;
76
69
  displayName: string;
77
70
  inputs?: BuildStepInput[];
78
71
  outputs?: BuildStepOutput[];
package/dist/BuildStep.js CHANGED
@@ -8,7 +8,6 @@ const assert_1 = __importDefault(require("assert"));
8
8
  const buffer_1 = require("buffer");
9
9
  const promises_1 = __importDefault(require("fs/promises"));
10
10
  const path_1 = __importDefault(require("path"));
11
- const uuid_1 = require("uuid");
12
11
  const BuildStepInput_1 = require("./BuildStepInput");
13
12
  const BuildStepOutput_1 = require("./BuildStepOutput");
14
13
  const BuildTemporaryFiles_1 = require("./BuildTemporaryFiles");
@@ -33,8 +32,6 @@ var BuildStepLogMarker;
33
32
  BuildStepLogMarker["START_STEP"] = "start-step";
34
33
  BuildStepLogMarker["END_STEP"] = "end-step";
35
34
  })(BuildStepLogMarker || (exports.BuildStepLogMarker = BuildStepLogMarker = {}));
36
- // TODO: move to a place common with tests
37
- const UUID_REGEX = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;
38
35
  class BuildStepOutputAccessor {
39
36
  id;
40
37
  displayName;
@@ -79,8 +76,8 @@ class BuildStepOutputAccessor {
79
76
  }
80
77
  exports.BuildStepOutputAccessor = BuildStepOutputAccessor;
81
78
  class BuildStep extends BuildStepOutputAccessor {
79
+ static nextGeneratedId = 1;
82
80
  id;
83
- name;
84
81
  displayName;
85
82
  supportedRuntimePlatforms;
86
83
  inputs;
@@ -96,37 +93,17 @@ class BuildStep extends BuildStepOutputAccessor {
96
93
  status;
97
94
  outputsDir;
98
95
  envsDir;
99
- internalId;
100
96
  inputById;
101
97
  executed = false;
102
98
  static getNewId(userDefinedId) {
103
- return userDefinedId ?? (0, uuid_1.v4)();
99
+ return userDefinedId ?? `step-${String(BuildStep.nextGeneratedId++).padStart(3, '0')}`;
104
100
  }
105
- static getDisplayName({ id, name, command, }) {
106
- if (name) {
107
- return name;
108
- }
109
- if (!id.match(UUID_REGEX)) {
110
- return id;
111
- }
112
- if (command) {
113
- const splits = command.trim().split('\n');
114
- for (const split of splits) {
115
- const trimmed = split.trim();
116
- if (trimmed && !trimmed.startsWith('#')) {
117
- return trimmed;
118
- }
119
- }
120
- }
121
- return id;
122
- }
123
- constructor(ctx, { id, name, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, __metricsId, }) {
101
+ constructor(ctx, { id, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, __metricsId, }) {
124
102
  (0, assert_1.default)(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');
125
103
  (0, assert_1.default)(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');
126
104
  const outputById = (0, BuildStepOutput_1.makeBuildStepOutputByIdMap)(outputs);
127
105
  super(id, displayName, false, outputById);
128
106
  this.id = id;
129
- this.name = name;
130
107
  this.displayName = displayName;
131
108
  this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;
132
109
  this.inputs = inputs;
@@ -139,9 +116,7 @@ class BuildStep extends BuildStepOutputAccessor {
139
116
  this.timeoutMs = timeoutMs;
140
117
  this.__metricsId = __metricsId;
141
118
  this.status = BuildStepStatus.NEW;
142
- this.internalId = (0, uuid_1.v4)();
143
119
  const logger = ctx.baseLogger.child({
144
- buildStepInternalId: this.internalId,
145
120
  buildStepId: this.id,
146
121
  buildStepDisplayName: this.displayName,
147
122
  });
@@ -3,7 +3,7 @@ import { bunyan } from '@expo/logger';
3
3
  import { BuildRuntimePlatform } from './BuildRuntimePlatform';
4
4
  import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep';
5
5
  import { BuildStepEnv } from './BuildStepEnv';
6
- import { StepMetricInput, StepMetricsCollection } from './StepMetrics';
6
+ import { StepMetric, StepMetricInput } from './StepMetrics';
7
7
  interface SerializedExternalBuildContextProvider {
8
8
  projectSourceDirectory: string;
9
9
  projectTargetDirectory: string;
@@ -23,6 +23,7 @@ export interface ExternalBuildContextProvider {
23
23
  readonly staticContext: () => Omit<StaticJobInterpolationContext, 'steps'>;
24
24
  readonly env: BuildStepEnv;
25
25
  updateEnv(env: BuildStepEnv): void;
26
+ reportStepMetric?(metric: StepMetric): void;
26
27
  }
27
28
  export interface SerializedBuildStepGlobalContext {
28
29
  stepsInternalBuildDirectory: string;
@@ -39,7 +40,6 @@ export declare class BuildStepGlobalContext {
39
40
  private didCheckOut;
40
41
  private _hasAnyPreviousStepFailed;
41
42
  private stepById;
42
- private readonly _stepMetrics;
43
43
  constructor(provider: ExternalBuildContextProvider, skipCleanup: boolean);
44
44
  get projectSourceDirectory(): string;
45
45
  get projectTargetDirectory(): string;
@@ -59,7 +59,6 @@ export declare class BuildStepGlobalContext {
59
59
  markAsCheckedOut(logger: bunyan): void;
60
60
  get hasAnyPreviousStepFailed(): boolean;
61
61
  markAsFailed(): void;
62
- get stepMetrics(): StepMetricsCollection;
63
62
  addStepMetric(metric: StepMetricInput): void;
64
63
  wasCheckedOut(): boolean;
65
64
  hashFiles(...patterns: string[]): string;
@@ -21,7 +21,6 @@ class BuildStepGlobalContext {
21
21
  didCheckOut = false;
22
22
  _hasAnyPreviousStepFailed = false;
23
23
  stepById = {};
24
- _stepMetrics = [];
25
24
  constructor(provider, skipCleanup) {
26
25
  this.provider = provider;
27
26
  this.skipCleanup = skipCleanup;
@@ -119,11 +118,9 @@ class BuildStepGlobalContext {
119
118
  markAsFailed() {
120
119
  this._hasAnyPreviousStepFailed = true;
121
120
  }
122
- get stepMetrics() {
123
- return this._stepMetrics;
124
- }
125
121
  addStepMetric(metric) {
126
- this._stepMetrics.push({ ...metric, platform: this.runtimePlatform });
122
+ const stepMetric = { ...metric, platform: this.runtimePlatform };
123
+ this.provider.reportStepMetric?.(stepMetric);
127
124
  }
128
125
  wasCheckedOut() {
129
126
  return this.didCheckOut;
@@ -7,4 +7,3 @@ export type StepMetricInput = {
7
7
  export type StepMetric = StepMetricInput & {
8
8
  platform: 'darwin' | 'linux';
9
9
  };
10
- export type StepMetricsCollection = StepMetric[];
@@ -67,13 +67,18 @@ class StepsConfigParser extends AbstractConfigParser_1.AbstractConfigParser {
67
67
  }
68
68
  createBuildStepFromShellStepConfig(step) {
69
69
  const id = BuildStep_1.BuildStep.getNewId(step.id);
70
- const displayName = BuildStep_1.BuildStep.getDisplayName({ id, name: step.name, command: step.run });
70
+ const displayName = step.name ??
71
+ step.id ??
72
+ step.run
73
+ .split('\n')
74
+ .find(line => line.trim())
75
+ ?.trim() ??
76
+ step.run;
71
77
  const outputs = step.outputs && this.createBuildStepOutputsFromDefinition(step.outputs, displayName);
72
78
  return new BuildStep_1.BuildStep(this.ctx, {
73
79
  id,
74
- outputs,
75
- name: step.name,
76
80
  displayName,
81
+ outputs,
77
82
  workingDirectory: step.working_directory,
78
83
  shell: step.shell,
79
84
  command: step.run,
package/dist/index.d.ts CHANGED
@@ -16,4 +16,4 @@ export * from './interpolation';
16
16
  export * from './utils/shell/spawn';
17
17
  export * from './utils/jsepEval';
18
18
  export * from './utils/hashFiles';
19
- export { StepMetric, StepMetricResult, StepMetricsCollection } from './StepMetrics';
19
+ export { StepMetric, StepMetricResult } from './StepMetrics';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/steps",
3
- "version": "18.2.0",
3
+ "version": "18.5.0",
4
4
  "bugs": "https://github.com/expo/eas-cli/issues",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Expo <support@expo.io>",
@@ -19,16 +19,16 @@
19
19
  "start": "yarn watch",
20
20
  "build": "tsc --project tsconfig.build.json",
21
21
  "typecheck": "tsc",
22
- "prepack": "rm -rf dist *.tsbuildinfo && tsc --project tsconfig.build.json",
22
+ "prepack": "rimraf dist \"*.tsbuildinfo\" && tsc --project tsconfig.build.json",
23
23
  "watch": "tsc --watch --preserveWatchOutput",
24
24
  "test": "jest --config jest.config.ts",
25
25
  "test:coverage": "jest --config jest.config.ts --coverage",
26
26
  "test:watch": "yarn test --watch",
27
- "clean": "rm -rf node_modules dist coverage *.tsbuildinfo"
27
+ "clean": "rimraf node_modules dist coverage \"*.tsbuildinfo\""
28
28
  },
29
29
  "dependencies": {
30
- "@expo/eas-build-job": "18.2.0",
31
- "@expo/logger": "18.0.1",
30
+ "@expo/eas-build-job": "18.5.0",
31
+ "@expo/logger": "18.5.0",
32
32
  "@expo/spawn-async": "^1.7.2",
33
33
  "arg": "^5.0.2",
34
34
  "fs-extra": "^11.2.0",
@@ -47,6 +47,7 @@
47
47
  "@types/node": "20.14.2",
48
48
  "eslint-plugin-async-protect": "^3.1.0",
49
49
  "jest": "^29.7.0",
50
+ "rimraf": "3.0.2",
50
51
  "ts-jest": "^29.1.4",
51
52
  "ts-mockito": "^2.6.1",
52
53
  "ts-node": "^10.9.2",
@@ -55,5 +56,5 @@
55
56
  "engines": {
56
57
  "node": ">=18"
57
58
  },
58
- "gitHead": "5f400d77660990422c6976a65dfb41f99374c5cc"
59
+ "gitHead": "2e2dddb59ae9df5ad2395c74f77701341103b62e"
59
60
  }