Skip to content

Commit d319e41

Browse files
committed
update scripts
1 parent 81527c7 commit d319e41

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
"clean": "rm -rf dist",
5858
"clean:win": "(if exist dist rd /s/q dist)",
5959
"lint": "tsc --noEmit && eslint 'lib/**/*.js' 'lib/**/*.ts'",
60-
"validate-platform-isolation": "node scripts/validate-platform-isolation.js",
61-
"test-isolation-rules": "node scripts/test-validator.js",
62-
"add-platform-exports": "node scripts/add-platform-exports.js",
60+
"validate-platform-isolation": "./scripts/platform-validator.js --validate",
61+
"fix-platform-isolation": "./scripts/platform-validator.js --fix",
62+
"test-isolation-rules": "./scripts/test-validator.js",
6363
"test-vitest": "vitest run",
6464
"test-mocha": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register -r tsconfig-paths/register -r lib/tests/exit_on_unhandled_rejection.js 'lib/**/*.tests.ts' 'lib/**/*.tests.js'",
6565
"test": "npm run test-mocha && npm run test-vitest",

scripts/platform-validator.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Copyright 2025, Optimizely
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* Platform validator CLI
21+
*
22+
* Provides a unified interface for validating and fixing platform isolation issues.
23+
*
24+
* Usage:
25+
* node platform-validator.js --validate # Validate platform isolation (default)
26+
* node platform-validator.js --fix # Fix platform isolation issues
27+
*/
28+
29+
/* eslint-disable @typescript-eslint/no-var-requires */
30+
const { execSync } = require('child_process');
31+
32+
function main() {
33+
const args = process.argv.slice(2);
34+
35+
const hasValidate = args.includes('--validate');
36+
const hasFix = args.includes('--fix');
37+
38+
// Check if both options are provided
39+
if (hasValidate && hasFix) {
40+
console.error('❌ Error: Cannot specify both --validate and --fix options');
41+
process.exit(1);
42+
}
43+
44+
// Determine which script to run (default to validate)
45+
const shouldFix = hasFix;
46+
47+
try {
48+
if (shouldFix) {
49+
console.log('🔧 Running platform isolation fix...\n');
50+
execSync('node scripts/add-platform-exports.js', { stdio: 'inherit' });
51+
} else {
52+
console.log('🔍 Running platform isolation validation...\n');
53+
execSync('node scripts/validate-platform-isolation.js', { stdio: 'inherit' });
54+
}
55+
} catch (error) {
56+
process.exit(error.status || 1);
57+
}
58+
}
59+
60+
if (require.main === module) {
61+
main();
62+
}
63+
64+
module.exports = { main };

0 commit comments

Comments
 (0)