Skip to content

Commit f33428d

Browse files
committed
add typescript support
1 parent 5e514f0 commit f33428d

Some content is hidden

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

42 files changed

+62
-30
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
coverage
33
.nyc_output
44
/.project
5+
dist

cli/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
import process from 'node:process';
3-
import YeomanCommand from '../lib/util/command.js';
3+
import YeomanCommand from '../src/util/command.js';
44
import packageJson from '../package.json';
55
import Env from '..';
66
import { printGroupedGenerator, environmentAction } from './utils.js';

cli/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { groupBy } from 'lodash';
22
import createLogger from 'debug';
3-
import { Environment } from '../lib/index.js';
4-
import { toNamespace } from '../lib/util/namespace.js';
3+
import { Environment } from '../src/index.js';
4+
import { toNamespace } from '../src/util/namespace.js';
55

66
const debug = createLogger('yeoman:yoe');
77

package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@
2222
"type": "module",
2323
"exports": {
2424
".": {
25-
"import": "./lib/index.mjs"
25+
"import": "./dist/index.js"
2626
},
2727
"./cli/*": "./cli/*.js",
28-
"./lib/*": "./lib/*.js",
29-
"./lib/util/*": "./lib/util/*.js",
30-
"./transform": "./lib/util/transform.js",
28+
"./lib/*": "./dist/*.js",
29+
"./lib/util/*": "./dist/util/*.js",
30+
"./transform": "./dist/util/transform.js",
3131
"./package.json": "./package.json",
32-
"./namespace": "./lib/util/namespace.js",
32+
"./namespace": "./dist/util/namespace.js",
3333
"./cli": "./cli/index.js"
3434
},
35-
"main": "./lib/index.mjs",
35+
"main": "./dist/index.js",
3636
"bin": {
3737
"yoe": "cli/index.js"
3838
},
3939
"files": [
4040
"cli",
41-
"lib"
41+
"dist"
4242
],
4343
"scripts": {
4444
"doc": "npm run doc:generate && npm run doc:fix && npm run doc:prettier",
@@ -106,6 +106,7 @@
106106
"sinon": "^15.0.4",
107107
"sinon-test": "^3.1.5",
108108
"tui-jsdoc-template": "^1.2.2",
109+
"typescript": "^5.0.4",
109110
"xo": "0.54.2",
110111
"yeoman-assert": "^3.1.1",
111112
"yeoman-generator": "^5.8.0",

lib/adapter.js src/adapter.js

File renamed without changes.

lib/command.js src/command.js

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/index.mjs src/index.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/resolver.js src/resolver.js

File renamed without changes.
File renamed without changes.

lib/store.js src/store.js

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/util/esm.js src/util/esm.js

File renamed without changes.

lib/util/log.js src/util/log.js

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/util/util.js src/util/util.js

File renamed without changes.

test/adapter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import assert from 'yeoman-assert';
33
import sinon from 'sinon';
44
import logSymbols from 'log-symbols';
55
import stripAnsi from 'strip-ansi';
6-
import { TerminalAdapter } from '../lib/index.mjs';
7-
import createLog from '../lib/util/log.js';
6+
import { TerminalAdapter } from '../src/index.js';
7+
import createLog from '../src/util/log.js';
88

99
describe('TerminalAdapter', () => {
1010
beforeEach(function () {

test/binary-diff.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path, { dirname } from 'node:path';
22
import assert from 'node:assert';
33
import fs from 'node:fs';
44
import { fileURLToPath } from 'node:url';
5-
import { isBinary } from '../lib/util/binary-diff.js';
5+
import { isBinary } from '../src/util/binary-diff.js';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = dirname(__filename);

test/command.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
44
import { createRequire } from 'node:module';
55
import sinon from 'sinon';
66
import semver from 'semver';
7-
import Environment from '../lib/index.mjs';
7+
import Environment from '../src/index.js';
88

99
const require = createRequire(import.meta.url);
1010
const __filename = fileURLToPath(import.meta.url);

test/composability.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from 'node:assert';
2-
import Environment from '../lib/index.mjs';
2+
import Environment from '../src/index.js';
33

44
describe('composability', () => {
55
before(function () {

test/conflicter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import sinon from 'sinon';
88
import slash from 'slash';
99
import semver from 'semver';
1010
import { TestAdapter } from 'yeoman-test';
11-
import { Conflicter } from '../lib/index.mjs';
11+
import { Conflicter } from '../src/index.js';
1212

1313
const require = createRequire(import.meta.url);
1414
const __filename = fileURLToPath(import.meta.url);

test/environment.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import sinonTestFactory from 'sinon-test';
1010
import Generator from 'yeoman-generator';
1111
import assert from 'yeoman-assert';
1212
import semver from 'semver';
13-
import Environment, { TerminalAdapter } from '../lib/index.mjs';
13+
import Environment, { TerminalAdapter } from '../src/index.js';
1414

1515
const require = createRequire(import.meta.url);
1616
const generatorPackageJson = require('yeoman-generator/package.json');
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Environment from '../../../../lib/index.mjs';
1+
import Environment from '../../../../src/index.js';
22
const maybeGenerator = await import(Environment.lookupGenerator('dummy:app'));
33
const Generator = maybeGenerator.default ?? maybeGenerator;
44
export default class extends Generator {};

test/helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { createHelpers } from 'yeoman-test';
2-
import Environment from '../lib/environment.js';
2+
import Environment from '../src/environment.js';
33

44
export default createHelpers({ createEnv: Environment.createEnv });

test/namespace.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from 'node:assert';
2-
import { requireNamespace, isNamespace } from '../lib/util/namespace.js';
2+
import { requireNamespace, isNamespace } from '../src/util/namespace.js';
33

44
const fields = [
55
'complete',

test/package-manager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from 'node:assert';
22
import path, { dirname } from 'node:path';
33
import { fileURLToPath } from 'node:url';
44
import sinon from 'sinon';
5-
import PackageManagerMixin from '../lib/package-manager.js';
5+
import PackageManagerMixin from '../src/package-manager.js';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = dirname(__filename);

test/plugins.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import os from 'node:os';
33
import path from 'node:path';
44
import process from 'node:process';
55
import fs from 'fs-extra';
6-
import Environment from '../lib/index.mjs';
7-
import YeomanRepository from '../lib/util/repository.js';
6+
import Environment from '../src/index.js';
7+
import YeomanRepository from '../src/util/repository.js';
88

99
const tmpdir = path.join(os.tmpdir(), 'yeoman-environment/light');
1010

test/resolver.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import fs from 'fs-extra';
88
import { expect } from 'esmocha';
99
import { execaSync } from 'execa';
1010
import slash from 'slash';
11-
import Environment from '../lib/index.mjs';
12-
import { execaOutput } from '../lib/util/util.js';
11+
import Environment from '../src/index.js';
12+
import { execaOutput } from '../src/util/util.js';
1313

1414
const require = createRequire(import.meta.url);
1515

test/spawn-command.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, esmocha, describe, beforeEach, it, afterEach } from 'esmocha';
22

33
const execa = await esmocha.mock('execa');
4-
const { default: spawnCommand } = await import('../lib/spawn-command.js');
4+
const { default: spawnCommand } = await import('../src/spawn-command.js');
55

66
describe('environment (spawn-command)', () => {
77
let cwd;

test/store.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from 'node:assert';
22
import { createRequire } from 'node:module';
33
import path, { dirname } from 'node:path';
44
import { fileURLToPath } from 'node:url';
5-
import Store from '../lib/store.js';
5+
import Store from '../src/store.js';
66

77
const require = createRequire(import.meta.url);
88
const __filename = fileURLToPath(import.meta.url);

test/transform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path, { dirname } from 'node:path';
33
import { fileURLToPath } from 'node:url';
44
import sinon from 'sinon';
55
import { pipeline, passthrough } from 'p-transform';
6-
import { getConflicterStatusForFile, createYoRcTransform, createConflicterStatusTransform } from '../lib/util/transform.js';
6+
import { getConflicterStatusForFile, createYoRcTransform, createConflicterStatusTransform } from '../src/util/transform.js';
77

88
const __filename = fileURLToPath(import.meta.url);
99
const __dirname = dirname(__filename);

test/util.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'node:assert';
2-
import Environment from '../lib/index.mjs';
3-
import { duplicateEnv } from '../lib/util/util.js';
2+
import Environment from '../src/index.js';
3+
import { duplicateEnv } from '../src/util/util.js';
44

55
describe('util', () => {
66
describe('.duplicateEnv()', () => {

tsconfig.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"include": ["./src"],
3+
"compilerOptions": {
4+
/* Language and Environment */
5+
"target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
6+
"lib": ["ES2022"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
7+
"types": [],
8+
9+
/* Modules */
10+
"module": "node16" /* Specify what module code is generated. */,
11+
"rootDir": "" /* Specify the root folder within your source files. */,
12+
13+
/* Emit */
14+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
15+
"declaration": true,
16+
"sourceMap": true,
17+
"allowJs": true,
18+
19+
/* Interop Constraints */
20+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
21+
22+
/* Type Checking */
23+
"strict": true /* Enable all strict type-checking options. */,
24+
"noImplicitAny": true,
25+
26+
/* Completeness */
27+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
28+
}
29+
}

0 commit comments

Comments
 (0)