Skip to content

Commit c6cb3b2

Browse files
author
Nenad Vićentić
committed
refactor: Convert to TypeScript. No functional changes. Minimum NodeJS version set to 14.17, since it's minimum runtime requirement for TypeScript 5.1+.
1 parent 08b3461 commit c6cb3b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3390
-2924
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ The `au new` command now simplify wraps `npx makes aurelia/v1`. Users can direct
3535

3636
Run `npm test` to run the unit tests.
3737

38+
To run and individual test, you can use command with filters. For example:
39+
40+
```powershell
41+
npx jasmine spec/lib/build/bundled-source.spec.js --filter="transform saves cache"
42+
```
43+
3844
## Release new aurelia-cli version
3945

4046
Just run `npm version patch` (or minor or major)

bin/aurelia-cli.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!/usr/bin/env node
22

3+
/**
4+
* @import { CLI } from '../dist/cli'
5+
*/
6+
37
const resolve = require('resolve');
48

59
const semver = require('semver');
610
const nodeVersion = process.versions.node;
7-
if (semver.lt(nodeVersion, '10.12.0')) {
11+
if (semver.lt(nodeVersion, '14.17.0')) {
812
console.error(`You are running Node.js v${nodeVersion}.
9-
aurelia-cli requires Node.js v10.12.0 or above.
13+
aurelia-cli requires Node.js v14.17.0 or above.
1014
Please upgrade to latest Node.js https://nodejs.org`);
1115
process.exit(1);
1216
}
@@ -22,10 +26,11 @@ let originalBaseDir = process.cwd();
2226
resolve('aurelia-cli', {
2327
basedir: originalBaseDir
2428
}, function(error, projectLocalCli) {
29+
/** @type {CLI} */
2530
let cli;
2631

2732
if (commandName === 'new' || error) {
28-
cli = new (require('../lib/index').CLI);
33+
cli = new (require('../dist/index').CLI);
2934
cli.options.runningGlobally = true;
3035
} else {
3136
cli = new (require(projectLocalCli).CLI);

build/clean-dir.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { rmSync, mkdirSync } from 'node:fs';
2+
3+
rmSync('./dist', { recursive: true, force: true});
4+
mkdirSync('./dist');

build/copy-files.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import * as cpx from 'cpx';
2+
3+
cpx.copy('src/**/*.json', 'dist')
4+
.on('copy', (e) => console.log(`Copied: ${e.srcPath}`));
5+
cpx.copy('src/**/*.txt', 'dist')
6+
.on('copy', (e) => console.log(`Copied: ${e.srcPath}`));

eslint.config.mjs

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
1-
import globals from "globals";
2-
import eslint from "@eslint/js";
1+
// @ts-check
32

4-
export default [
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
import stylistic from '@stylistic/eslint-plugin';
6+
import stylisticJS from '@stylistic/eslint-plugin-js';
7+
8+
export default tseslint.config(
59
{
6-
ignores: ["lib/build/amodro-trace", "**/dist"],
10+
ignores: ['src/build/amodro-trace', '**/dist', '**/lib', './spec', './build', './bin']
711
},
812
eslint.configs.recommended,
13+
tseslint.configs.recommended,
914
{
1015
languageOptions: {
11-
globals: {
12-
...globals.node,
13-
...globals.jasmine,
14-
},
15-
16-
ecmaVersion: 2019,
17-
sourceType: "commonjs",
16+
parserOptions: {
17+
projectService: true,
18+
tsconfigRootDir: import.meta.dirname
19+
}
1820
},
19-
21+
plugins: {
22+
'@stylistic': stylistic,
23+
'@stylistic/js': stylisticJS
24+
}
25+
},
26+
{
2027
rules: {
21-
"no-prototype-builtins": 0,
22-
"no-console": 0,
23-
"getter-return": 0,
24-
"no-inner-declarations": 0,
25-
26-
"comma-dangle": ["error", {
27-
arrays: "never",
28-
objects: "never",
29-
imports: "never",
30-
exports: "never",
31-
functions: "never",
28+
'no-prototype-builtins': 0,
29+
'no-console': 0,
30+
'getter-return': 0,
31+
'no-inner-declarations': 0,
32+
'comma-dangle': ['error', {
33+
arrays: 'never',
34+
objects: 'never',
35+
imports: 'never',
36+
exports: 'never',
37+
functions: 'never'
3238
}],
33-
},
39+
'prefer-rest-params': 'warn',
40+
'prefer-spread': 'warn',
41+
'@stylistic/js/quotes': ['warn', 'single'],
42+
'@typescript-eslint/no-explicit-any': 'warn',
43+
'@typescript-eslint/no-require-imports': 'warn',
44+
'@typescript-eslint/no-floating-promises': 'error',
45+
'@typescript-eslint/no-misused-promises': 'error'
46+
}
3447
}
35-
];
48+
);

jsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "./",
5+
"allowJs": true,
6+
"types": ["node"]
7+
},
8+
"include": ["bin", "build", "eslint.config.mjs"]
9+
}

package.json

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aurelia-cli",
3-
"version": "3.0.4",
3+
"version": "3.1.0-beta.1",
44
"description": "The command line tooling for Aurelia.",
55
"keywords": [
66
"aurelia",
@@ -16,21 +16,29 @@
1616
"aurelia": "bin/aurelia-cli.js",
1717
"au": "bin/aurelia-cli.js"
1818
},
19+
"type": "commonjs",
1920
"scripts": {
20-
"lint": "eslint lib spec",
21-
"pretest": "npm run lint",
21+
"prebuild": "node build/clean-dir.mjs && npm run lint",
22+
"build": "tsc",
23+
"postbuild": "node build/copy-files.mjs",
24+
"lint": "eslint src",
25+
"pretest": "npm run lint && npm run build",
2226
"test": "jasmine",
2327
"coverage": "c8 jasmine",
2428
"test:watch": "nodemon -x 'npm test'",
29+
"prepare": "npm run build",
2530
"preversion": "npm test",
2631
"version": "standard-changelog && git add CHANGELOG.md",
2732
"postversion": "git push && git push --tags && npm publish"
2833
},
2934
"license": "MIT",
3035
"author": "Rob Eisenberg <[email protected]> (http://robeisenberg.com/)",
31-
"main": "lib/index.js",
36+
"main": "dist/index.js",
37+
"typings": "dist/index.d.ts",
3238
"files": [
3339
"bin",
40+
"build",
41+
"dist",
3442
"lib"
3543
],
3644
"repository": {
@@ -81,21 +89,34 @@
8189
"string_decoder": "^1.3.0",
8290
"terser": "^5.36.0",
8391
"timers-browserify": "^2.0.12",
92+
"tslib": "^2.8.1",
8493
"tty-browserify": "0.0.1",
85-
"typescript": "^5.6.3",
94+
"typescript": "^5.8.3",
8695
"url": "^0.11.4",
8796
"util": "^0.12.5",
8897
"vm-browserify": "^1.1.2"
8998
},
9099
"devDependencies": {
100+
"@eslint/js": "^9.24.0",
101+
"@stylistic/eslint-plugin": "^4.2.0",
102+
"@stylistic/eslint-plugin-js": "^4.2.0",
103+
"@types/convert-source-map": "^2.0.3",
104+
"@types/gulp": "^4.0.17",
105+
"@types/jasmine": "^5.1.7",
106+
"@types/lodash": "^4.17.16",
107+
"@types/map-stream": "^0.0.3",
91108
"@types/node": "^22.8.1",
109+
"@types/resolve": "^1.20.6",
110+
"@types/vinyl-fs": "^3.0.5",
92111
"c8": "^10.1.2",
93-
"eslint": "^9.13.0",
112+
"cpx": "^1.5.0",
113+
"eslint": "^9.24.0",
94114
"globals": "^15.11.0",
95115
"jasmine": "^5.4.0",
96116
"jasmine-spec-reporter": "^7.0.0",
97117
"nodemon": "^3.1.7",
98118
"standard-changelog": "^6.0.0",
119+
"typescript-eslint": "^8.29.0",
99120
"yargs": "^17.7.2"
100121
}
101122
}

spec/helpers/setup.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const isDebugMode = typeof v8debug === 'object' ||
2+
/--debug|--inspect/.test(process.execArgv.join(' ')) ||
3+
process.env.VSCODE_INSPECTOR_OPTIONS;
4+
5+
if (isDebugMode) {
6+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60 * 1000; // 1 minute timeout in debug mode
7+
console.log('Debug mode detected - extended timeouts enabled');
8+
}

spec/jsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": null,
5+
"rootDirs": ["../src", "./"],
6+
"allowJs": true,
7+
"module": "CommonJS",
8+
"types": ["node", "jasmine"]
9+
},
10+
"include": [
11+
"./**/*.js"
12+
]
13+
}

spec/lib/build/ast-matcher.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const meriyah = require('meriyah');
22

3-
const astm = require('../../../lib/build/ast-matcher');
3+
const astm = require('../../../dist/build/ast-matcher');
44
const extract = astm.extract;
55
const compilePattern = astm.compilePattern;
66
const astMatcher = astm.astMatcher;

0 commit comments

Comments
 (0)