Skip to content

Commit b52aa61

Browse files
committed
Add VSCode extension package to monorepo
1 parent 9b77d71 commit b52aa61

File tree

4 files changed

+109
-6
lines changed

4 files changed

+109
-6
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ node_modules/
33
.DS_Store
44
.turbo
55
packages/cli/LICENSE.md
6-
7-
# Allow GitHub Action dist (required for actions)
8-
!packages/action/dist/
6+
*.vsix
7+
# Allow VSCode extension dist (required for extension)
8+
!packages/vsx/dist/

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
"build:core": "pnpm turbo run build --filter=@flow-scanner/lightning-flow-scanner-core",
99
"build:cli": "pnpm turbo run build --filter=lightning-flow-scanner",
1010
"build:action": "pnpm turbo run build --filter=lightning-flow-scanner-action",
11+
"build:vsx": "pnpm --filter=lightning-flow-scanner-vsx run build",
12+
"build:vsx:package": "pnpm --filter=lightning-flow-scanner-vsx run build:vsx",
1113
"build:docs": "node scripts/update-package-readmes.js",
1214
"test": "turbo run test",
1315
"test:core": "turbo run test --filter=@flow-scanner/lightning-flow-scanner-core",
1416
"test:cli": "turbo run test --filter=lightning-flow-scanner",
1517
"clean": "turbo run clean",
1618
"dev": "turbo run build --watch",
19+
"watch:vsx": "pnpm --filter=lightning-flow-scanner-vsx run watch",
1720
"dist": "turbo run vite:dist --filter=@flow-scanner/lightning-flow-scanner-core",
1821
"dist:core": "turbo run vite:dist --filter=@flow-scanner/lightning-flow-scanner-core",
1922
"lfs:link": "turbo run buildng-flow-scanner && cd packages/ --filter=lightnicli && pnpm lfs:link"
@@ -31,4 +34,4 @@
3134
"pnpm": "9.0.0"
3235
},
3336
"repository": "https://github.com/Flow-Scanner/lightning-flow-scanner.git"
34-
}
37+
}

packages/vsx/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"license": "MIT",
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/Flow-Scanner/lightning-flow-scanner-vsx"
8+
"url": "git+https://github.com/Flow-Scanner/lightning-flow-scanner.git",
9+
"directory": "packages/vsx"
910
},
1011
"icon": "media/lightningflow.png",
1112
"description": "A VS Code Extension for analysis and optimization of Salesforce Flows. Scans metadata for 20+ issues such as hardcoded IDs, unsafe contexts, inefficient SOQL/DML operations, recursion risks, and missing fault handling. Supports auto-fixes, rule configurations, and tests integration.",
@@ -133,7 +134,7 @@
133134
"webpack-cli": "^5.1.4"
134135
},
135136
"dependencies": {
136-
"@flow-scanner/lightning-flow-scanner-core": "6.6.0",
137+
"@flow-scanner/lightning-flow-scanner-core": "workspace:*",
137138
"convert-array-to-csv": "^2.0.0",
138139
"cosmiconfig": "^9.0.0",
139140
"glob": "^13.0.0",

scripts/add-vsx-to-monorepo.js

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// add-vsx-to-monorepo.js
2+
// Run this in your existing monorepo to add the VSCode extension package
3+
const { execSync } = require('child_process');
4+
const fs = require('fs');
5+
6+
function run(cmd, options = {}) {
7+
console.log(`$ ${cmd}`);
8+
try {
9+
return execSync(cmd, {
10+
stdio: options.silent ? 'pipe' : 'inherit',
11+
encoding: 'utf-8',
12+
...options
13+
});
14+
} catch (error) {
15+
if (!options.allowFail) {
16+
throw error;
17+
}
18+
}
19+
}
20+
21+
function writeJSON(file, data) {
22+
fs.writeFileSync(file, JSON.stringify(data, null, 2) + '\n');
23+
}
24+
25+
console.log('='.repeat(70));
26+
console.log('ADDING VSCODE EXTENSION TO MONOREPO');
27+
console.log('='.repeat(70));
28+
29+
// Step 1: Import vsx repo with history
30+
console.log('\n[1/5] Adding VSX repository as remote...');
31+
run('git remote add vsx-origin ../lightning-flow-scanner-vsx');
32+
run('git fetch vsx-origin');
33+
34+
console.log('\n[2/5] Merging VSX repository with full history...');
35+
run('git merge -s ours --no-commit --allow-unrelated-histories vsx-origin/main');
36+
run('git read-tree --prefix=packages/vsx/ -u vsx-origin/main');
37+
run('git commit -m "Import VSX repository with full history into packages/vsx"');
38+
run('git remote remove vsx-origin');
39+
40+
// Step 2: Update vsx package.json
41+
console.log('\n[3/5] Updating VSX package.json...');
42+
const vsxPkgPath = 'packages/vsx/package.json';
43+
if (fs.existsSync(vsxPkgPath)) {
44+
const vsxPkg = JSON.parse(fs.readFileSync(vsxPkgPath, 'utf-8'));
45+
46+
// Update to use workspace dependency
47+
if (vsxPkg.dependencies && vsxPkg.dependencies['@flow-scanner/lightning-flow-scanner-core']) {
48+
vsxPkg.dependencies['@flow-scanner/lightning-flow-scanner-core'] = 'workspace:*';
49+
}
50+
51+
// Update repository
52+
vsxPkg.repository = {
53+
type: "git",
54+
url: "git+https://github.com/Flow-Scanner/lightning-flow-scanner.git",
55+
directory: "packages/vsx"
56+
};
57+
58+
writeJSON(vsxPkgPath, vsxPkg);
59+
console.log('✓ Updated VSX package.json');
60+
}
61+
62+
// Step 3: Update .gitignore to allow vsx dist/
63+
console.log('\n[4/5] Updating .gitignore...');
64+
let gitignore = '';
65+
if (fs.existsSync('.gitignore')) {
66+
gitignore = fs.readFileSync('.gitignore', 'utf8');
67+
}
68+
69+
if (!gitignore.includes('!packages/vsx/dist/')) {
70+
gitignore += '\n# Allow VSCode extension dist (required for extension)\n!packages/vsx/dist/\n';
71+
fs.writeFileSync('.gitignore', gitignore);
72+
console.log('✓ Updated .gitignore to allow vsx dist/');
73+
}
74+
75+
// Step 4: Update root package.json scripts
76+
console.log('\n[5/5] Updating root package.json scripts...');
77+
const rootPkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
78+
rootPkg.scripts = {
79+
...rootPkg.scripts,
80+
'build:vsx': 'pnpm --filter=lightning-flow-scanner-vsx run build',
81+
'build:vsx:package': 'pnpm --filter=lightning-flow-scanner-vsx run build:vsx',
82+
'watch:vsx': 'pnpm --filter=lightning-flow-scanner-vsx run watch'
83+
};
84+
writeJSON('package.json', rootPkg);
85+
86+
run('git add .');
87+
run('git commit -m "Add VSCode extension package to monorepo"');
88+
89+
console.log('\n' + '='.repeat(70));
90+
console.log('✅ VSCODE EXTENSION ADDED TO MONOREPO!');
91+
console.log('='.repeat(70));
92+
console.log('\nNext steps:');
93+
console.log(' 1. Build core: pnpm build:core');
94+
console.log(' 2. Build VSX: pnpm build:vsx');
95+
console.log(' 3. Commit dist/: git add packages/vsx/dist && git commit -m "build: vsx dist"');
96+
console.log(' 4. Package extension: pnpm build:vsx:package');
97+
console.log('\nThe .vsix file will be in packages/vsx/');
98+
console.log('Users can install it from VS Code Marketplace or manually.');
99+
console.log('');

0 commit comments

Comments
 (0)