@str-public/installer 0.4.0 → 0.4.2

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.
Files changed (2) hide show
  1. package/dist/cli.js +39 -31
  2. package/package.json +3 -3
package/dist/cli.js CHANGED
@@ -47,7 +47,7 @@ async function main() {
47
47
  const tools = await multiselect({
48
48
  message: 'What would you like to install?',
49
49
  options: [
50
- { value: 'theme-switcher', label: 'Theme Switcher', hint: 'Quiet Light / Monokai Dimmed' },
50
+ { value: 'theme-switcher', label: 'Theme Switcher', hint: 'Stronghold / Stronghold Dusk' },
51
51
  { value: 'basic-cursor-settings', label: 'Basic Cursor Settings', hint: 'Workspace folders and AI agent rules' },
52
52
  { value: 'development-standards', label: 'Development Standards', hint: 'TypeScript & Next.js strict rules (.mdc)' }
53
53
  ],
@@ -63,51 +63,59 @@ async function main() {
63
63
  s.start('Downloading and installing selected tools...');
64
64
  try {
65
65
  if (selectedTools.includes('theme-switcher')) {
66
- s.message('Installing Theme Switcher...');
66
+ s.message('Installing Theme Switcher and Themes...');
67
67
  const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'str-installer-'));
68
68
  try {
69
- // Pack the package to get the vsix
69
+ // Pack the package to get the vsix files
70
70
  execSync(`npm pack @str-public/theme-switcher@${tag} --pack-destination "${tmpDir}"`, { stdio: 'ignore' });
71
71
  const tgzFile = fs.readdirSync(tmpDir).find(f => f.endsWith('.tgz'));
72
72
  if (!tgzFile)
73
73
  throw new Error('Failed to download theme-switcher package.');
74
74
  execSync(`tar -xzf ${tgzFile}`, { cwd: tmpDir, stdio: 'ignore' });
75
75
  const packageDir = path.join(tmpDir, 'package');
76
- const vsixFile = fs.readdirSync(packageDir).find(f => f.endsWith('.vsix'));
77
- if (!vsixFile)
78
- throw new Error('VSIX file not found in the downloaded package.');
79
- const vsixPath = path.join(packageDir, vsixFile);
76
+ const vsixFiles = fs.readdirSync(packageDir).filter(f => f.endsWith('.vsix'));
77
+ if (vsixFiles.length === 0)
78
+ throw new Error('No VSIX files found in the downloaded package.');
80
79
  // Define target directories based on IDE selection
81
80
  const homeDir = os.homedir();
82
81
  const idePaths = {
83
82
  cursor: path.join(homeDir, '.cursor', 'extensions'),
84
83
  code: path.join(homeDir, '.vscode', 'extensions')
85
84
  };
86
- // The exact folder name VS Code/Cursor expects: <publisher>.<name>-<version>
87
- const extFolderName = 'stronghold-systems.str-theme-switcher-1.0.0';
88
- for (const ide of selectedIdes) {
89
- const targetExtDir = idePaths[ide];
90
- // Ensure the base extensions directory exists
91
- if (!fs.existsSync(targetExtDir)) {
92
- fs.mkdirSync(targetExtDir, { recursive: true });
93
- }
94
- const finalPath = path.join(targetExtDir, extFolderName);
95
- // Clean up existing installation if it exists
96
- if (fs.existsSync(finalPath)) {
97
- fs.rmSync(finalPath, { recursive: true, force: true });
98
- }
99
- fs.mkdirSync(finalPath, { recursive: true });
100
- // Unzip the vsix 'extension' folder into a temp dir
101
- const unzipTemp = path.join(tmpDir, `unzip-${ide}`);
85
+ for (const vsixFile of vsixFiles) {
86
+ const vsixPath = path.join(packageDir, vsixFile);
87
+ // Unzip the vsix 'extension' folder into a temp dir to read its package.json
88
+ const unzipTemp = path.join(tmpDir, `unzip-meta-${vsixFile}`);
102
89
  fs.mkdirSync(unzipTemp, { recursive: true });
103
- // Use native unzip to extract just the extension folder
104
- execSync(`unzip -q "${vsixPath}" "extension/*" -d "${unzipTemp}"`, { stdio: 'ignore' });
105
- // Move contents from unzipTemp/extension/* to finalPath
106
- // Using fs operations instead of mv to be completely cross-platform safe
107
- const sourceExtDir = path.join(unzipTemp, 'extension');
108
- const files = fs.readdirSync(sourceExtDir);
109
- for (const file of files) {
110
- fs.renameSync(path.join(sourceExtDir, file), path.join(finalPath, file));
90
+ // Use native unzip to extract just the extension/package.json
91
+ execSync(`unzip -q "${vsixPath}" "extension/package.json" -d "${unzipTemp}"`, { stdio: 'ignore' });
92
+ const extPkgJsonPath = path.join(unzipTemp, 'extension', 'package.json');
93
+ const extPkg = JSON.parse(fs.readFileSync(extPkgJsonPath, 'utf-8'));
94
+ // The exact folder name VS Code/Cursor expects: <publisher>.<name>-<version>
95
+ const extFolderName = `${extPkg.publisher}.${extPkg.name}-${extPkg.version}`;
96
+ for (const ide of selectedIdes) {
97
+ const targetExtDir = idePaths[ide];
98
+ // Ensure the base extensions directory exists
99
+ if (!fs.existsSync(targetExtDir)) {
100
+ fs.mkdirSync(targetExtDir, { recursive: true });
101
+ }
102
+ const finalPath = path.join(targetExtDir, extFolderName);
103
+ // Clean up existing installation if it exists
104
+ if (fs.existsSync(finalPath)) {
105
+ fs.rmSync(finalPath, { recursive: true, force: true });
106
+ }
107
+ fs.mkdirSync(finalPath, { recursive: true });
108
+ // Unzip the vsix 'extension' folder into a temp dir
109
+ const extractTemp = path.join(tmpDir, `extract-${ide}-${vsixFile}`);
110
+ fs.mkdirSync(extractTemp, { recursive: true });
111
+ // Use native unzip to extract just the extension folder
112
+ execSync(`unzip -q "${vsixPath}" "extension/*" -d "${extractTemp}"`, { stdio: 'ignore' });
113
+ // Move contents from extractTemp/extension/* to finalPath
114
+ const sourceExtDir = path.join(extractTemp, 'extension');
115
+ const files = fs.readdirSync(sourceExtDir);
116
+ for (const file of files) {
117
+ fs.renameSync(path.join(sourceExtDir, file), path.join(finalPath, file));
118
+ }
111
119
  }
112
120
  }
113
121
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@str-public/installer",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Stronghold Systems CLI Installer",
5
5
  "type": "module",
6
6
  "bin": {
7
- "str-install": "./dist/cli.js"
7
+ "str-install": "dist/cli.js"
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsc",
@@ -24,4 +24,4 @@
24
24
  "typescript": "^5.7.0",
25
25
  "@types/node": "^22.0.0"
26
26
  }
27
- }
27
+ }