Skip to content

Commit

Permalink
add typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed May 7, 2023
1 parent 5e514f0 commit f33428d
Show file tree
Hide file tree
Showing 42 changed files with 62 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
coverage
.nyc_output
/.project
dist
2 changes: 1 addition & 1 deletion cli/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import process from 'node:process';
import YeomanCommand from '../lib/util/command.js';
import YeomanCommand from '../src/util/command.js';
import packageJson from '../package.json';
import Env from '..';
import { printGroupedGenerator, environmentAction } from './utils.js';
Expand Down
4 changes: 2 additions & 2 deletions cli/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { groupBy } from 'lodash';
import createLogger from 'debug';
import { Environment } from '../lib/index.js';
import { toNamespace } from '../lib/util/namespace.js';
import { Environment } from '../src/index.js';
import { toNamespace } from '../src/util/namespace.js';

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

Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.mjs"
"import": "./dist/index.js"
},
"./cli/*": "./cli/*.js",
"./lib/*": "./lib/*.js",
"./lib/util/*": "./lib/util/*.js",
"./transform": "./lib/util/transform.js",
"./lib/*": "./dist/*.js",
"./lib/util/*": "./dist/util/*.js",
"./transform": "./dist/util/transform.js",
"./package.json": "./package.json",
"./namespace": "./lib/util/namespace.js",
"./namespace": "./dist/util/namespace.js",
"./cli": "./cli/index.js"
},
"main": "./lib/index.mjs",
"main": "./dist/index.js",
"bin": {
"yoe": "cli/index.js"
},
"files": [
"cli",
"lib"
"dist"
],
"scripts": {
"doc": "npm run doc:generate && npm run doc:fix && npm run doc:prettier",
Expand Down Expand Up @@ -106,6 +106,7 @@
"sinon": "^15.0.4",
"sinon-test": "^3.1.5",
"tui-jsdoc-template": "^1.2.2",
"typescript": "^5.0.4",
"xo": "0.54.2",
"yeoman-assert": "^3.1.1",
"yeoman-generator": "^5.8.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import assert from 'yeoman-assert';
import sinon from 'sinon';
import logSymbols from 'log-symbols';
import stripAnsi from 'strip-ansi';
import { TerminalAdapter } from '../lib/index.mjs';
import createLog from '../lib/util/log.js';
import { TerminalAdapter } from '../src/index.js';
import createLog from '../src/util/log.js';

describe('TerminalAdapter', () => {
beforeEach(function () {
Expand Down
2 changes: 1 addition & 1 deletion test/binary-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path, { dirname } from 'node:path';
import assert from 'node:assert';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { isBinary } from '../lib/util/binary-diff.js';
import { isBinary } from '../src/util/binary-diff.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down
2 changes: 1 addition & 1 deletion test/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
import sinon from 'sinon';
import semver from 'semver';
import Environment from '../lib/index.mjs';
import Environment from '../src/index.js';

const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
Expand Down
2 changes: 1 addition & 1 deletion test/composability.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'node:assert';
import Environment from '../lib/index.mjs';
import Environment from '../src/index.js';

describe('composability', () => {
before(function () {
Expand Down
2 changes: 1 addition & 1 deletion test/conflicter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sinon from 'sinon';
import slash from 'slash';
import semver from 'semver';
import { TestAdapter } from 'yeoman-test';
import { Conflicter } from '../lib/index.mjs';
import { Conflicter } from '../src/index.js';

const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
Expand Down
2 changes: 1 addition & 1 deletion test/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sinonTestFactory from 'sinon-test';
import Generator from 'yeoman-generator';
import assert from 'yeoman-assert';
import semver from 'semver';
import Environment, { TerminalAdapter } from '../lib/index.mjs';
import Environment, { TerminalAdapter } from '../src/index.js';

const require = createRequire(import.meta.url);
const generatorPackageJson = require('yeoman-generator/package.json');
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/generator-environment-extend/app/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Environment from '../../../../lib/index.mjs';
import Environment from '../../../../src/index.js';
const maybeGenerator = await import(Environment.lookupGenerator('dummy:app'));
const Generator = maybeGenerator.default ?? maybeGenerator;
export default class extends Generator {};
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createHelpers } from 'yeoman-test';
import Environment from '../lib/environment.js';
import Environment from '../src/environment.js';

export default createHelpers({ createEnv: Environment.createEnv });
2 changes: 1 addition & 1 deletion test/namespace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'node:assert';
import { requireNamespace, isNamespace } from '../lib/util/namespace.js';
import { requireNamespace, isNamespace } from '../src/util/namespace.js';

const fields = [
'complete',
Expand Down
2 changes: 1 addition & 1 deletion test/package-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert';
import path, { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import sinon from 'sinon';
import PackageManagerMixin from '../lib/package-manager.js';
import PackageManagerMixin from '../src/package-manager.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down
4 changes: 2 additions & 2 deletions test/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import fs from 'fs-extra';
import Environment from '../lib/index.mjs';
import YeomanRepository from '../lib/util/repository.js';
import Environment from '../src/index.js';
import YeomanRepository from '../src/util/repository.js';

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

Expand Down
4 changes: 2 additions & 2 deletions test/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import fs from 'fs-extra';
import { expect } from 'esmocha';
import { execaSync } from 'execa';
import slash from 'slash';
import Environment from '../lib/index.mjs';
import { execaOutput } from '../lib/util/util.js';
import Environment from '../src/index.js';
import { execaOutput } from '../src/util/util.js';

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

Expand Down
2 changes: 1 addition & 1 deletion test/spawn-command.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, esmocha, describe, beforeEach, it, afterEach } from 'esmocha';

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

describe('environment (spawn-command)', () => {
let cwd;
Expand Down
2 changes: 1 addition & 1 deletion test/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert';
import { createRequire } from 'node:module';
import path, { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import Store from '../lib/store.js';
import Store from '../src/store.js';

const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
Expand Down
2 changes: 1 addition & 1 deletion test/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path, { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import sinon from 'sinon';
import { pipeline, passthrough } from 'p-transform';
import { getConflicterStatusForFile, createYoRcTransform, createConflicterStatusTransform } from '../lib/util/transform.js';
import { getConflicterStatusForFile, createYoRcTransform, createConflicterStatusTransform } from '../src/util/transform.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down
4 changes: 2 additions & 2 deletions test/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert';
import Environment from '../lib/index.mjs';
import { duplicateEnv } from '../lib/util/util.js';
import Environment from '../src/index.js';
import { duplicateEnv } from '../src/util/util.js';

describe('util', () => {
describe('.duplicateEnv()', () => {
Expand Down
29 changes: 29 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"include": ["./src"],
"compilerOptions": {
/* Language and Environment */
"target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"lib": ["ES2022"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
"types": [],

/* Modules */
"module": "node16" /* Specify what module code is generated. */,
"rootDir": "" /* Specify the root folder within your source files. */,

/* Emit */
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"declaration": true,
"sourceMap": true,
"allowJs": true,

/* Interop Constraints */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,

/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true,

/* Completeness */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

0 comments on commit f33428d

Please sign in to comment.