x-fidelity 3.9.1 → 3.10.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.
- package/CHANGELOG.md +7 -0
- package/canary-install-example.sh +44 -0
- package/flagCheck.js +26 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.10.0](https://github.com/zotoio/x-fidelity/compare/v3.9.1...v3.10.0) (2025-03-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **canary:** add example canary rollout script using launchdarkly ([73fbcfb](https://github.com/zotoio/x-fidelity/commit/73fbcfb4eca11be8af7eb9fca20f7ed132898a83))
|
|
7
|
+
|
|
1
8
|
## [3.9.1](https://github.com/zotoio/x-fidelity/compare/v3.9.0...v3.9.1) (2025-03-02)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# This script uses the LaunchDarkly Node SDK to evaluate a feature flag
|
|
4
|
+
# and conditionally run a command based on the flag’s value.
|
|
5
|
+
#
|
|
6
|
+
# Requirements:
|
|
7
|
+
# - Node.js installed.
|
|
8
|
+
# - LaunchDarkly Node SDK installed:
|
|
9
|
+
# yarn global add launchdarkly-node-client-sdk
|
|
10
|
+
#
|
|
11
|
+
# Set your LaunchDarkly clientid and feature flag key here.
|
|
12
|
+
# note that the clientid is not a secret, as it is public in the client-side SDKs
|
|
13
|
+
#
|
|
14
|
+
# export XFI_LD_CLIENT_ID="YOUR_LAUNCHDARKLY_CLIENT_ID"
|
|
15
|
+
# export XFI_VERSION_FLAG_KEY="your-feature-flag-key"
|
|
16
|
+
|
|
17
|
+
# get the first commit on this repo to use as the context key
|
|
18
|
+
XFI_CONTEXT_KEY=$(git rev-list --max-parents=0 HEAD | head -n 1)
|
|
19
|
+
|
|
20
|
+
# print config
|
|
21
|
+
echo "XFI_CONTEXT_KEY: $XFI_CONTEXT_KEY"
|
|
22
|
+
echo "XFI_LD_CLIENT_ID: $XFI_LD_CLIENT_ID"
|
|
23
|
+
echo "XFI_VERSION_FLAG_KEY: $XFI_VERSION_FLAG_KEY"
|
|
24
|
+
|
|
25
|
+
# Run a Node.js script to evaluate the flag.
|
|
26
|
+
FLAG_VALUE=$(node ./flagCheck.js $XFI_CONTEXT_KEY)
|
|
27
|
+
echo "FLAG_VALUE: $FLAG_VALUE"
|
|
28
|
+
|
|
29
|
+
# Check if the Node.js command succeeded.
|
|
30
|
+
if [ $? -ne 0 ]; then
|
|
31
|
+
echo 'Error: Failed to evaluate the feature flag.'
|
|
32
|
+
exit 0
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# Decide which command to run based on the flag value.
|
|
36
|
+
if [ "$FLAG_VALUE" == "true" ]; then
|
|
37
|
+
echo "Installing the NEW version of xfi"
|
|
38
|
+
# add your canary CI install command here
|
|
39
|
+
# eg. yarn global add x-fidelity@3.9.1 --ignore-engines
|
|
40
|
+
else
|
|
41
|
+
echo "Installing the current version of xfi"
|
|
42
|
+
# add your current CI install command here
|
|
43
|
+
# eg. yarn global add x-fidelity@2.17.2 --ignore-engines
|
|
44
|
+
fi
|
package/flagCheck.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const ldclient = require('launchdarkly-node-client-sdk');
|
|
2
|
+
|
|
3
|
+
(async function main(contextKey) {
|
|
4
|
+
try {
|
|
5
|
+
const context = { kind: 'user', key: contextKey };
|
|
6
|
+
const options = {
|
|
7
|
+
logger: ldclient.basicLogger({
|
|
8
|
+
level: 'error',
|
|
9
|
+
}),
|
|
10
|
+
};
|
|
11
|
+
const client = ldclient.initialize(process.env.XFI_LD_CLIENT_ID, context, options);
|
|
12
|
+
|
|
13
|
+
await client.waitForInitialization(10);
|
|
14
|
+
|
|
15
|
+
const flagValue = await client.variation(process.env.XFI_VERSION_FLAG_KEY, "false");
|
|
16
|
+
console.log(flagValue);
|
|
17
|
+
process.exit(0);
|
|
18
|
+
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.log(`*** SDK failed to initialize: ${error}`);
|
|
21
|
+
process.exit(0); // exit with 0 to avoid failing the build
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
})(process.argv[2]);
|
|
26
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-fidelity",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "cli for opinionated framework adherence checks",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"json-rules-engine": "^7.3.1",
|
|
90
90
|
"jsonpath-plus": "^10.3.0",
|
|
91
91
|
"kill-port": "^2.0.1",
|
|
92
|
+
"launchdarkly-node-client-sdk": "^3.3.0",
|
|
92
93
|
"lodash": "^4.17.21",
|
|
93
94
|
"nodemon": "^3.1.9",
|
|
94
95
|
"openai": "^4.86.1",
|
|
@@ -96,9 +97,9 @@
|
|
|
96
97
|
"pino": "^9.6.0",
|
|
97
98
|
"pino-pretty": "^13.0.0",
|
|
98
99
|
"prettyjson": "^1.2.5",
|
|
100
|
+
"sanitize-filename": "^1.6.3",
|
|
99
101
|
"semver": "^7.7.1",
|
|
100
|
-
"yarn": "^1.22.22"
|
|
101
|
-
"sanitize-filename": "^1.6.3"
|
|
102
|
+
"yarn": "^1.22.22"
|
|
102
103
|
},
|
|
103
104
|
"peerDependencies": {
|
|
104
105
|
"artillery": "^2.0.22"
|