Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Node16 and target ES2022, adopt latest grep #429

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion generators/app/dependencyVersions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"eslint": "^8.47.0",
"glob": "^10.3.3",
"glob": "^10.3.10",
"mocha": "^10.2.0",
"typescript": "^5.1.6",
"@vscode/test-electron": "^2.3.4",
Expand Down
6 changes: 3 additions & 3 deletions generators/app/templates/ext-command-js/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"module": "Node16",
"target": "ES2022",
"checkJs": <%- JSON.stringify(checkJavaScript) %>, /* Typecheck .js files. */
"lib": [
"ES2020"
"ES2022"
]
},
"exclude": [
Expand Down
43 changes: 17 additions & 26 deletions generators/app/templates/ext-command-js/test/suite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,33 @@ const path = require('path');
const Mocha = require('mocha');
const glob = require('glob');

function run() {
async function run() {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true
});

const testsRoot = path.resolve(__dirname, '..');
const files = await glob('**/**.test.js', { cwd: testsRoot });

return new Promise((c, e) => {
const testFiles = new glob.Glob('**/**.test.js', { cwd: testsRoot });
const testFileStream = testFiles.stream();
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));

testFileStream.on('data', (file) => {
// Add files to the test suite
mocha.addFile(path.resolve(testsRoot, file));
try {
return new Promise((c, e) => {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
});
testFileStream.on('error', (err) => {
e(err);
});
testFileStream.on('end', () => {
try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
});
} catch (err) {
console.error(err);
}
}

module.exports = {
Expand Down
46 changes: 19 additions & 27 deletions generators/app/templates/ext-command-ts/src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
import Mocha from 'mocha';
import { glob } from 'glob';

export function run(): Promise<void> {
export async function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true
});

const testsRoot = path.resolve(__dirname, '..');
const files = await glob('**/**.test.js', { cwd: testsRoot });

return new Promise((c, e) => {
const testFiles = new glob.Glob("**/**.test.js", { cwd: testsRoot });
const testFileStream = testFiles.stream();
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));

testFileStream.on("data", (file) => {
mocha.addFile(path.resolve(testsRoot, file));
try {
return new Promise<void>((c, e) => {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
});
testFileStream.on("error", (err) => {
e(err);
});
testFileStream.on("end", () => {
try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
});
} catch (err) {
console.error(err);
}
}
6 changes: 3 additions & 3 deletions generators/app/templates/ext-command-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"module": "Node16",
"target": "ES2022",
"outDir": "out",
"lib": [
"ES2020"
"ES2022"
],
"sourceMap": true,
"rootDir": "src",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"module": "Node16",
"target": "ES2022",
"lib": [
"ES2020"
"ES2022"
],
"sourceMap": true,
"rootDir": "src",
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/ext-command-web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "Node16",
"target": "ES2020",
"outDir": "dist",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
import Mocha from 'mocha';
import { glob } from 'glob';

export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true
});
export async function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true
});

const testsRoot = path.resolve(__dirname, '..');
const testsRoot = path.resolve(__dirname, '..');
const files = await glob('**/**.test.js', { cwd: testsRoot });

return new Promise((c, e) => {
const testFiles = new glob.Glob("**/**.test.js", { cwd: testsRoot });
const testFileStream = testFiles.stream();
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));

testFileStream.on("data", (file) => {
mocha.addFile(path.resolve(testsRoot, file));
});
testFileStream.on("error", (err) => {
e(err);
});
testFileStream.on("end", () => {
try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
});
try {
return new Promise<void>((c, e) => {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
});
} catch (err) {
console.error(err);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2019",
"module": "Node16",
"target": "ES2022",
"lib": [
"ES2019"
"ES2022"
],
"types": ["node"],
"moduleResolution": "node",
"sourceMap": true,
"strict": true /* enable all strict type-checking options */
/* Additional Checks */
Expand Down
27 changes: 9 additions & 18 deletions test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ describe('test code generator', function () {
"activationEvents": [],
"devDependencies": devDependencies([
"@types/vscode",
"@types/glob",
"@types/mocha",
"@types/node",
"@typescript-eslint/parser",
Expand Down Expand Up @@ -707,7 +706,6 @@ describe('test code generator', function () {
"activationEvents": [],
"devDependencies": devDependencies([
"@types/vscode",
"@types/glob",
"@types/mocha",
"@types/node",
"eslint",
Expand Down Expand Up @@ -739,11 +737,11 @@ describe('test code generator', function () {
};
const expectedTsConfig = {
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"module": "Node16",
"target": "ES2022",
"outDir": "out",
"lib": [
"ES2020"
"ES2022"
],
"sourceMap": true,
"rootDir": "src",
Expand Down Expand Up @@ -788,7 +786,6 @@ describe('test code generator', function () {
"activationEvents": [],
"devDependencies": devDependencies([
"@types/vscode",
"@types/glob",
"@types/mocha",
"@types/node",
"eslint",
Expand Down Expand Up @@ -820,11 +817,11 @@ describe('test code generator', function () {
};
const expectedTsConfig = {
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"module": "Node16",
"target": "ES2022",
"outDir": "out",
"lib": [
"ES2020"
"ES2022"
],
"sourceMap": true,
"rootDir": "src",
Expand Down Expand Up @@ -870,7 +867,6 @@ describe('test code generator', function () {
"activationEvents": [],
"devDependencies": devDependencies([
"@types/vscode",
"@types/glob",
"@types/mocha",
"@types/node",
"@typescript-eslint/parser",
Expand Down Expand Up @@ -942,7 +938,6 @@ describe('test code generator', function () {
"activationEvents": [],
"devDependencies": devDependencies([
"@types/vscode",
"@types/glob",
"@types/mocha",
"@types/node",
"@typescript-eslint/parser",
Expand Down Expand Up @@ -1014,7 +1009,6 @@ describe('test code generator', function () {
"activationEvents": [],
"devDependencies": devDependencies([
"@types/vscode",
"@types/glob",
"@types/mocha",
"@types/node",
"eslint",
Expand Down Expand Up @@ -1075,7 +1069,6 @@ describe('test code generator', function () {
"activationEvents": [],
"devDependencies": devDependencies([
"@types/vscode",
"@types/glob",
"@types/mocha",
"@types/node",
"eslint",
Expand Down Expand Up @@ -1125,11 +1118,11 @@ describe('test code generator', function () {
try {
const expectedJSConfig = {
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"module": "Node16",
"target": "ES2022",
"checkJs": true,
"lib": [
"ES2020"
"ES2022"
]
},
"exclude": [
Expand Down Expand Up @@ -1503,7 +1496,6 @@ describe('test code generator', function () {
"test": "node ./out/test/runTest.js"
},
"devDependencies": devDependencies([
"@types/glob",
"@types/mocha",
"@types/node",
"@types/vscode",
Expand Down Expand Up @@ -1587,7 +1579,6 @@ describe('test code generator', function () {
"test": "node ./out/test/runTest.js"
},
"devDependencies": devDependencies([
"@types/glob",
"@types/mocha",
"@types/node",
"@types/vscode",
Expand Down