@str-public/installer 0.4.0 → 0.4.1
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/dist/cli.js +39 -31
- package/package.json +2 -2
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: '
|
|
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
|
|
77
|
-
if (
|
|
78
|
-
throw new Error('VSIX
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
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
|
|
104
|
-
execSync(`unzip -q "${vsixPath}" "extension
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
for (const
|
|
110
|
-
|
|
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