diff --git a/.gitignore b/.gitignore index cf7b6ba..f14f6bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,10 @@ -node_modules +.cache +.idea/* +.nyc_output build +node_modules test src/**.js -.idea/* - coverage -.nyc_output *.log - -yarn.lock \ No newline at end of file +yarn.lock diff --git a/README.md b/README.md index e8e7b61..7719cb7 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Run one simple command to install and use the interactive project generator. You'll need [Node](https://nodejs.org/) `v10` or later. -```bash +```sh npx typescript-starter ``` @@ -56,15 +56,21 @@ Also consider installing editor extensions for [ESLint](https://github.com/Micro ## Development zen -To start working, run the `watch` task using [`npm`](https://docs.npmjs.com/getting-started/what-is-npm) or [`yarn`](https://yarnpkg.com/). +To start working, run the `watch:build` task using [`npm`](https://docs.npmjs.com/getting-started/what-is-npm) or [`yarn`](https://yarnpkg.com/). -```bash -npm run watch +```sh +npm run watch:build ``` -This starter includes a watch task which makes development faster and more interactive. It's particularly helpful for [TDD](https://en.wikipedia.org/wiki/Test-driven_development)/[BDD](https://en.wikipedia.org/wiki/Behavior-driven_development) workflows. +In another terminal tab/window, run the `watch:test` task: -The watch task will build and watch the entire project for changes (to both the library source files and test source files). As you develop, you can add tests for new functionality – which will initially fail – before developing the new functionality. Each time you save, any changes will be rebuilt and retested. +```sh +npm run watch:test +``` + +These watch tasks make development much faster and more interactive. They're particularly helpful for [TDD](https://en.wikipedia.org/wiki/Test-driven_development)/[BDD](https://en.wikipedia.org/wiki/Behavior-driven_development) workflows. + +These watch tasks will build and watch the entire project for changes (to both the library source files and test source files). As you develop, you can add tests for new functionality – which will initially fail – before developing the new functionality. Each time you save, any changes will be rebuilt and retested.
@@ -83,7 +89,7 @@ To enable additional Typescript type checking features (a good idea for mission-
To automatically fix `eslint` and `prettier` formatting issues, run:
-```
+```sh
npm run fix
```
@@ -91,7 +97,7 @@ npm run fix
To generate and view test coverage, run:
-```bash
+```sh
npm run cov
```
@@ -105,7 +111,7 @@ This will create an HTML report of test coverage – source-mapped back to Types
The src folder is analyzed and documentation is automatically generated using [TypeDoc](https://github.com/TypeStrong/typedoc).
-```bash
+```sh
npm run doc
```
@@ -115,7 +121,7 @@ Since types are tracked by Typescript, there's no need to indicate types in JSDo
To generate and publish your documentation to [GitHub Pages](https://pages.github.com/) use the following command:
-```bash
+```sh
npm run doc:publish
```
@@ -127,7 +133,7 @@ Once published, your documentation should be available at the proper GitHub Page
For more advanced documentation generation, you can provide your own [TypeDoc theme](http://typedoc.org/guides/themes/), or [build your own documentation](https://blog.cloudflare.com/generating-documentation-for-typescript-projects/) using the JSON TypeDoc export:
-```bash
+```sh
npm run doc:json
```
@@ -135,7 +141,7 @@ npm run doc:json
It's recommended that you install [`commitizen`](https://github.com/commitizen/cz-cli) to make commits to your project.
-```bash
+```sh
npm install -g commitizen
# commit your changes:
@@ -144,7 +150,7 @@ git cz
This project is tooled for [conventional changelog](https://github.com/conventional-changelog/conventional-changelog) to make managing releases easier. See the [standard-version](https://github.com/conventional-changelog/standard-version) documentation for more information on the workflow, or [`CHANGELOG.md`](CHANGELOG.md) for an example.
-```bash
+```sh
# bump package.json version, update CHANGELOG.md, git tag the release
npm run version
```
@@ -155,7 +161,7 @@ You may find a tool like [**`wip`**](https://github.com/bitjson/wip) helpful for
Bringing together many of the steps above, this repo includes a one-step release preparation command.
-```bash
+```sh
# Prepare a standard release:
npm run prepare-release
```
@@ -170,7 +176,7 @@ This command runs the following tasks:
When the script finishes, it will log the final command needed to push the release commit to the repo and publish the package on the `npm` registry:
-```bash
+```sh
git push --follow-tags origin master; npm publish
```
@@ -178,7 +184,7 @@ Look over the release if you'd like, then execute the command to publish everyth
You can also prepare a non-standard release:
-```bash
+```sh
# Or a non-standard release:
# Reset the repo to the latest commit and build everything
diff --git a/package.json b/package.json
index bf5a383..1eaacd3 100644
--- a/package.json
+++ b/package.json
@@ -29,18 +29,19 @@
"appveyor"
],
"scripts": {
- "build": "run-s clean && run-p build:*",
+ "build": "run-p build:*",
"build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json",
"fix": "run-s fix:*",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
"fix:lint": "eslint . --ext .ts --fix",
"test": "run-s build test:*",
- "test:lint": "eslint . --ext .ts",
+ "test:lint": "eslint src --ext .ts",
"test:prettier": "prettier \"src/**/*.ts\" --list-different",
"test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.ts}\"",
"test:unit": "nyc --silent ava",
- "watch": "run-s clean build:main && run-p \"build:main -- -w\" \"test:unit -- --watch\"",
+ "watch:build": "tsc -p tsconfig.json -w",
+ "watch:test": "nyc --silent ava --watch",
"cov": "run-s build test:unit cov:html cov:lcov && open-cli coverage/index.html",
"cov:html": "nyc report --reporter=html",
"cov:lcov": "nyc report --reporter=lcov",
@@ -52,7 +53,6 @@
"doc:publish": "gh-pages -m \"[ci skip] Updates\" -d build/docs",
"version": "standard-version",
"reset-hard": "git clean -dfx && git reset --hard && npm i",
- "clean": "trash build test",
"prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish"
},
"engines": {
@@ -126,7 +126,11 @@
}
},
"files": [
+ "!test",
"!build/module/**"
+ ],
+ "ignoredByWatcher": [
+ "test"
]
},
"config": {
diff --git a/src/cli/tests/cli.integration.spec.ts b/src/cli/tests/cli.integration.spec.ts
index 2da1f2b..82b3ffe 100644
--- a/src/cli/tests/cli.integration.spec.ts
+++ b/src/cli/tests/cli.integration.spec.ts
@@ -13,6 +13,7 @@
* `diff build/test-one/package.json build/test-two/package.json`
*/
+import { existsSync, mkdirSync } from 'fs';
import { join, relative } from 'path';
import test, { ExecutionContext } from 'ava';
@@ -45,7 +46,11 @@ const repoInfo = {
branch: branch === 'HEAD' ? '.' : branch,
repo: process.cwd(),
};
-const buildDir = join(process.cwd(), 'build');
+const testDir = join(process.cwd(), 'test');
+if (existsSync(testDir)) {
+ del.sync(testDir);
+}
+mkdirSync(testDir);
const env = {
TYPESCRIPT_STARTER_REPO_BRANCH: repoInfo.branch,
TYPESCRIPT_STARTER_REPO_URL: repoInfo.repo,
@@ -60,18 +65,6 @@ enum TestDirectories {
six = 'test-6',
}
-// If the tests all pass, the TestDirectories will automatically be cleaned up.
-test.after(async () => {
- await del([
- `./build/${TestDirectories.one}`,
- `./build/${TestDirectories.two}`,
- `./build/${TestDirectories.three}`,
- `./build/${TestDirectories.four}`,
- `./build/${TestDirectories.five}`,
- `./build/${TestDirectories.six}`,
- ]);
-});
-
test('returns version', async (t) => {
const expected = meow('').pkg.version;
t.truthy(typeof expected === 'string');
@@ -103,7 +96,7 @@ async function hashAllTheThings(
projectName: string,
sandboxed = false
): Promise<{ readonly [filename: string]: string }> {
- const projectDir = normalizePath(join(buildDir, projectName));
+ const projectDir = normalizePath(join(testDir, projectName));
const rawFilePaths: ReadonlyArray