Skip to content

Commit a6ba00e

Browse files
Nikola HristovNikola Hristov
authored andcommitted
2 parents e286fea + bde0077 commit a6ba00e

File tree

4 files changed

+6174
-126
lines changed

4 files changed

+6174
-126
lines changed
Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
{
2-
"name": "generator-code-dependencies-versions",
3-
"description": "Helper file to manage the versions of the node modules used by the generators. Named package.json so the VS Code dependencies completions work. Must be in a subfolder due to #325",
4-
"dependencies": {
5-
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
6-
"@types/assert": "^1.5.11",
7-
"@types/node": "22.x",
8-
"assert": "^2.1.0",
9-
"concurrently": "^9.1.2",
10-
"css-loader": "^7.1.2",
11-
"esbuild": "^0.25.1",
12-
"glob": "^11.0.1",
13-
"npm-run-all": "^4.1.5",
14-
"process": "^0.11.10",
15-
"style-loader": "^4.0.0",
16-
"ts-loader": "^9.5.2",
17-
"util": "^0.12.5"
18-
},
19-
"devDependencies": {}
2+
"name": "generator-code-dependencies-versions",
3+
"description": "Helper file to manage the versions of the node modules used by the generators. Named package.json so the VS Code dependencies completions work. Must be in a subfolder due to #325",
4+
"version": "0.0.0",
5+
"private": true,
6+
"dependencies": {
7+
"@types/mocha": "^10.0.10",
8+
"@types/node": "20.x",
9+
"@types/assert": "^1.5.11",
10+
"@typescript-eslint/eslint-plugin": "^8.28.0",
11+
"@typescript-eslint/parser": "^8.28.0",
12+
"eslint": "^9.23.0",
13+
"glob": "^11.0.1",
14+
"mocha": "^11.1.0",
15+
"typescript": "^5.8.2",
16+
"@vscode/test-cli": "^0.0.10",
17+
"@vscode/test-electron": "^2.4.1",
18+
"@vscode/test-web": "^0.0.68",
19+
"@types/webpack-env": "^1.18.8",
20+
"@types/vscode-notebook-renderer": "^1.72.3",
21+
"concurrently": "^9.1.2",
22+
"css-loader": "^7.1.2",
23+
"fork-ts-checker-webpack-plugin": "^9.0.2",
24+
"style-loader": "^4.0.0",
25+
"ts-loader": "^9.5.2",
26+
"vscode-dts": "^0.3.3",
27+
"vscode-notebook-error-overlay": "^1.1.0",
28+
"webpack": "^5.98.0",
29+
"util": "^0.12.5",
30+
"webpack-cli": "^6.0.1",
31+
"webpack-dev-server": "^5.2.0",
32+
"assert": "^2.1.0",
33+
"process": "^0.11.10",
34+
"npm-run-all": "^4.1.5",
35+
"esbuild": "^0.25.1",
36+
"@esbuild-plugins/node-globals-polyfill": "^0.2.3"
37+
}
2038
}

generators/app/index.js

Lines changed: 75 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -106,41 +106,15 @@ export default class extends Generator {
106106
"Open the generated extension in Visual Studio Code Insiders",
107107
});
108108

109-
this.option("extensionType", {
110-
type: String,
111-
alias: "t",
112-
description:
113-
extensionGenerators
114-
.slice(0, 6)
115-
.map((e) => e.aliases[0])
116-
.join(", ") + "...",
117-
});
118-
this.option("extensionDisplayName", {
119-
type: String,
120-
alias: "n",
121-
description: "Display name of the extension",
122-
});
123-
this.option("extensionId", {
124-
type: String,
125-
description: "Id of the extension",
126-
});
127-
this.option("extensionDescription", {
128-
type: String,
129-
description: "Description of the extension",
130-
});
131-
132-
this.option("pkgManager", {
133-
type: String,
134-
description: `'npm', 'yarn' or 'pnpm'`,
135-
});
136-
this.option("bundler", {
137-
type: String,
138-
description: `Bundle the extension: 'webpack', 'esbuild'`,
139-
});
140-
this.option("gitInit", {
141-
type: Boolean,
142-
description: `Initialize a git repo`,
143-
});
109+
this.option('insiders', { type: Boolean, alias: 'i', description: 'Show the insiders options for the generator' });
110+
this.option('quick', { type: Boolean, alias: 'q', description: 'Quick mode, skip all optional prompts and use defaults' });
111+
this.option('open', { type: Boolean, alias: 'o', description: 'Open the generated extension in Visual Studio Code' });
112+
this.option('openInInsiders', { type: Boolean, alias: 'O', description: 'Open the generated extension in Visual Studio Code Insiders' });
113+
this.option('skipOpen', { type: Boolean, alias:'s', description: 'Skip opening the generated extension in Visual Studio Code' });
114+
this.option('extensionType', { type: String, alias: 't', description: extensionGenerators.slice(0, 6).map(e => e.aliases[0]).join(', ') + '...' });
115+
this.option('extensionDisplayName', { type: String, alias: 'n', description: 'Display name of the extension' });
116+
this.option('extensionId', { type: String, description: 'Id of the extension' });
117+
this.option('extensionDescription', { type: String, description: 'Description of the extension' });
144118

145119
this.option("snippetFolder", {
146120
type: String,
@@ -379,58 +353,70 @@ export default class extends Generator {
379353
);
380354
this.log("\r\n");
381355

382-
if (this.options["open"]) {
383-
if (codeStableLocation) {
384-
this.log(
385-
`Opening ${this.destinationPath()} in Visual Studio Code...`,
386-
);
387-
await this.spawn(codeStableLocation, [this.destinationPath()]);
388-
} else {
389-
this.log(`'code' command not found.`);
390-
}
391-
} else if (this.options["openInInsiders"]) {
392-
if (codeInsidersLocation) {
393-
this.log(
394-
`Opening ${this.destinationPath()} with Visual Studio Code Insiders...`,
395-
);
396-
await this.spawn(codeInsidersLocation, [
397-
this.destinationPath(),
398-
]);
399-
} else {
400-
this.log(`'code-insiders' command not found.`);
401-
}
402-
} else if (codeInsidersLocation || codeStableLocation) {
403-
if (this.options["quick"]) {
404-
await this.spawn(codeInsidersLocation || codeStableLocation, [
405-
this.destinationPath(),
406-
]);
407-
} else {
408-
const choices = [];
409-
if (codeInsidersLocation) {
410-
choices.push({
411-
name: "Open with `code-insiders`",
412-
value: codeInsidersLocation,
413-
});
414-
}
415-
if (codeStableLocation) {
416-
choices.push({
417-
name: "Open with `code`",
418-
value: codeStableLocation,
419-
});
420-
}
421-
choices.push({ name: "Skip", value: "skip" });
422-
423-
const answer = await this.prompt({
424-
type: "list",
425-
name: "openWith",
426-
message:
427-
"Do you want to open the new folder with Visual Studio Code?",
428-
choices,
429-
});
430-
if (answer && answer.openWith && answer.openWith !== "skip") {
431-
await this.spawn(answer.openWith, [this.destinationPath()]);
432-
}
433-
}
434-
}
435-
}
356+
if (!this.extensionConfig.insiders && !this.options['open'] && !this.options['openInInsiders'] && !this.options['quick'] && !this.options['skipOpen']) {
357+
const cdLocation = this.options['destination'] || this.extensionConfig.name;
358+
359+
this.log('To start editing with Visual Studio Code, use the following commands:');
360+
this.log('');
361+
if (!this.extensionConfig.insiders) {
362+
this.log(' code ' + cdLocation);
363+
} else {
364+
this.log(' code-insiders ' + cdLocation);
365+
}
366+
this.log('');
367+
}
368+
this.log('Open vsc-extension-quickstart.md inside the new extension for further instructions');
369+
this.log('on how to modify, test and publish your extension.');
370+
this.log('');
371+
372+
if (this.extensionGenerator.endMessage) {
373+
this.extensionGenerator.endMessage(this, this.extensionConfig);
374+
}
375+
376+
this.log('For more information, also visit http://code.visualstudio.com and follow us @code.');
377+
this.log('\r\n');
378+
379+
if (this.options['skipOpen']) {
380+
return;
381+
}
382+
383+
if (this.options["open"]) {
384+
if (codeStableLocation) {
385+
this.log(`Opening ${this.destinationPath()} in Visual Studio Code...`);
386+
await this.spawn(codeStableLocation, [this.destinationPath()]);
387+
} else {
388+
this.log(`'code' command not found.`);
389+
}
390+
} else if (this.options["openInInsiders"]) {
391+
if (codeInsidersLocation) {
392+
this.log(`Opening ${this.destinationPath()} with Visual Studio Code Insiders...`);
393+
await this.spawn(codeInsidersLocation, [this.destinationPath()]);
394+
} else {
395+
this.log(`'code-insiders' command not found.`);
396+
}
397+
} else if (codeInsidersLocation || codeStableLocation) {
398+
if (this.options["quick"]) {
399+
await this.spawn(codeInsidersLocation || codeStableLocation, [this.destinationPath()]);
400+
} else {
401+
const choices = [];
402+
if (codeInsidersLocation) {
403+
choices.push({ name: "Open with `code-insiders`", value: codeInsidersLocation });
404+
}
405+
if (codeStableLocation) {
406+
choices.push({ name: "Open with `code`", value: codeStableLocation });
407+
}
408+
choices.push({ name: "Skip", value: 'skip' });
409+
410+
const answer = await this.prompt({
411+
type: "list",
412+
name: "openWith",
413+
message: "Do you want to open the new folder with Visual Studio Code?",
414+
choices
415+
});
416+
if (answer && answer.openWith && answer.openWith !== 'skip') {
417+
await this.spawn(answer.openWith, [this.destinationPath()]);
418+
}
419+
}
420+
}
421+
}
436422
}

0 commit comments

Comments
 (0)