From ac57abb921c035530fdee9c74e663cc2da1b193f Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Mon, 12 Mar 2018 00:42:42 -0400 Subject: [PATCH] docs(examples): remove examples (no longer needed) --- .npmignore | 1 - README.md | 6 +--- bin/typescript-starter | 2 +- examples/browser/package.json | 21 ------------ examples/browser/rollup.config.js | 27 --------------- examples/browser/src/index.html | 10 ------ examples/browser/src/test.ts | 24 ------------- examples/browser/tsconfig.json | 16 --------- examples/node-typescript/package.json | 17 ---------- examples/node-typescript/src/test.ts | 12 ------- examples/node-typescript/tsconfig.json | 10 ------ examples/node-vanilla/package.json | 12 ------- examples/node-vanilla/test.js | 15 -------- examples/readme.md | 47 -------------------------- src/cli/tests/cli.integration.spec.ts | 12 +++---- src/cli/typescript-starter.ts | 9 ----- 16 files changed, 8 insertions(+), 233 deletions(-) delete mode 100644 examples/browser/package.json delete mode 100644 examples/browser/rollup.config.js delete mode 100644 examples/browser/src/index.html delete mode 100644 examples/browser/src/test.ts delete mode 100644 examples/browser/tsconfig.json delete mode 100644 examples/node-typescript/package.json delete mode 100644 examples/node-typescript/src/test.ts delete mode 100644 examples/node-typescript/tsconfig.json delete mode 100644 examples/node-vanilla/package.json delete mode 100644 examples/node-vanilla/test.js delete mode 100644 examples/readme.md diff --git a/.npmignore b/.npmignore index b18d791..88949d4 100644 --- a/.npmignore +++ b/.npmignore @@ -11,4 +11,3 @@ build/docs coverage .nyc_output *.log -examples diff --git a/README.md b/README.md index 6acab84..9821fa5 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,6 @@ Also consider installing editor extensions for [TSLint](https://github.com/Micro Typescript Editor Support – vscode

-## View usage examples - -To see how this starter can be used as a dependency in other projects, check out the [`examples`](./examples) folder. The example in the VSCode screenshot above is from [`examples/node-typescript`](./examples/node-typescript). - # Developing with typescript-starter ## Development zen @@ -343,7 +339,7 @@ If you're using [VS Code](https://code.visualstudio.com/), the `Debug CLI` launc # In the wild -You can find more advanced configurations, usage examples, and inspiration from projects using `typescript-starter`. +You can find more advanced configurations, usage examples, and inspiration from other projects using `typescript-starter`: * [BitAuth](https://github.com/bitauth/) – A universal identity and authentication protocol, based on bitcoin * [s6: Super Simple Secrets \* Simple Secure Storage](https://gitlab.com/td7x/s6/) – An NPM library and tool to sprawl secrets with S3, ease, and encryption diff --git a/bin/typescript-starter b/bin/typescript-starter index ffbcebd..81bdc13 100755 --- a/bin/typescript-starter +++ b/bin/typescript-starter @@ -6,4 +6,4 @@ * (https://github.com/Microsoft/TypeScript/issues/16667), we track this file * with Git, and simply require the generated CLI. */ -require('../build/main/cli/cli.js'); \ No newline at end of file +require('../build/main/cli/cli.js'); diff --git a/examples/browser/package.json b/examples/browser/package.json deleted file mode 100644 index 8ef7a67..0000000 --- a/examples/browser/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "typescript-starter-example-browser", - "version": "1.0.0", - "license": "MIT", - "scripts": { - "start": "http-server -c-1 ./build/ -o", - "build": "rollup -c && cpy src/index.html build/" - }, - "devDependencies": { - "cpy-cli": "^1.0.1", - "http-server": "^0.9.0", - "rollup": "^0.41.4", - "rollup-plugin-node-resolve": "^2.0.0", - "rollup-plugin-typescript": "^0.8.1", - "typescript": "^2.2.0" - }, - "dependencies": { - "typescript-starter": "^1.2.1" - }, - "private": true -} diff --git a/examples/browser/rollup.config.js b/examples/browser/rollup.config.js deleted file mode 100644 index e955042..0000000 --- a/examples/browser/rollup.config.js +++ /dev/null @@ -1,27 +0,0 @@ -// rollup.config.js -import typescript from 'rollup-plugin-typescript'; -import nodeResolve from 'rollup-plugin-node-resolve'; - -const pkg = require('./package'); - -export default { - entry: 'src/test.ts', - moduleId: pkg.name, - moduleName: 'BrowserTest', - // entry: 'dist/es/index.js', - dest: 'build/test.js', - format: 'iife', - sourceMap: true, - plugins: [ - typescript({ - typescript: require('typescript') // use local version - }), - nodeResolve({ - module: true, - jsnext: true, - browser: true, - extensions: [ '.js', '.json' ], - preferBuiltins: false - }) - ] -} diff --git a/examples/browser/src/index.html b/examples/browser/src/index.html deleted file mode 100644 index ff76b7e..0000000 --- a/examples/browser/src/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/examples/browser/src/test.ts b/examples/browser/src/test.ts deleted file mode 100644 index ec1201b..0000000 --- a/examples/browser/src/test.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Note: we're not using the double method, so it should be excluded from the bundle -import { power, asyncABC } from 'typescript-starter' - -let output = '' - -function log (str: string) { - console.log(str) - output += str + '\n' -} - -function logAndAlert (data: string[]) { - log('✔ asyncABC returned: ' + data) - window.alert(output) -} - -log('Output:') - -if (power(3,4) === 81) { - log('✔ power(3,4) === 81') -} else { - log('The "power" method seems to be broken.') -} - -asyncABC().then( abc => logAndAlert(abc) ) diff --git a/examples/browser/tsconfig.json b/examples/browser/tsconfig.json deleted file mode 100644 index 8d64366..0000000 --- a/examples/browser/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "build", - "rootDir": "src", - "module": "es6", - "declaration": false, - "removeComments": true, - "lib": [ - "dom" - ] - }, - "include": [ - "src/*.ts" - ] -} diff --git a/examples/node-typescript/package.json b/examples/node-typescript/package.json deleted file mode 100644 index 34a6a0c..0000000 --- a/examples/node-typescript/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "typescript-starter-example-node-typescript", - "version": "1.0.0", - "license": "MIT", - "scripts": { - "start": "node build/test.js", - "build": "tsc" - }, - "devDependencies": { - "@types/node": "^7.0.5", - "typescript": "^2.1.6" - }, - "dependencies": { - "typescript-starter": "^1.2.1" - }, - "private": true -} diff --git a/examples/node-typescript/src/test.ts b/examples/node-typescript/src/test.ts deleted file mode 100644 index 05c3d5b..0000000 --- a/examples/node-typescript/src/test.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Typescript should resolve this using the same algorithm as Node.js. -// See examples/node-vanilla for more info. -import { double, power, asyncABC } from 'typescript-starter' -import * as assert from 'assert' - -assert(double(6) === 12) -console.log('✔ double(6) === 12') - -assert(power(3,4) === 81) -console.log('✔ power(3,4) === 81') - -asyncABC().then( abc => console.log('✔ asyncABC returned:', abc) ) diff --git a/examples/node-typescript/tsconfig.json b/examples/node-typescript/tsconfig.json deleted file mode 100644 index f086f69..0000000 --- a/examples/node-typescript/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "build", - "rootDir": "src" - }, - "include": [ - "src/*.ts" - ] -} diff --git a/examples/node-vanilla/package.json b/examples/node-vanilla/package.json deleted file mode 100644 index 43b5b9a..0000000 --- a/examples/node-vanilla/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "typescript-starter-example-node-vanilla", - "version": "1.0.0", - "license": "MIT", - "scripts": { - "start": "node test.js" - }, - "dependencies": { - "typescript-starter": "^1.2.1" - }, - "private": true -} diff --git a/examples/node-vanilla/test.js b/examples/node-vanilla/test.js deleted file mode 100644 index 8462f20..0000000 --- a/examples/node-vanilla/test.js +++ /dev/null @@ -1,15 +0,0 @@ -// Node.js should resolve this to the root of the repo. Since the path returns a -// directory, node will look for the `main` property in `package.json`, which -// should point to the `main` build. -var starter = require('typescript-starter'); - -// now we can use the library -var assert = require('assert'); - -assert(starter.double(6) === 12); -console.log("✔ starter.double(6) === 12"); - -assert(starter.power(3,4) === 81); -console.log("✔ starter.power(3,4) === 81"); - -starter.asyncABC().then( abc => console.log("✔ asyncABC returned:", abc) ); diff --git a/examples/readme.md b/examples/readme.md deleted file mode 100644 index 789d712..0000000 --- a/examples/readme.md +++ /dev/null @@ -1,47 +0,0 @@ -# Usage Examples - -This directory (`/examples`) can be deleted when forking this project. It contains some simple examples of how forks of `typescript-starter` can be used by other projects. (Usually you'll want to provide these instructions in your root `readme.md`.) - -## Node (Vanilla) - -This shows the simplest use case – a quick, hacked-together Node.js project with no type safety, and no pre-processing. This is the way most of the Node.js ecosystem currently expects to import a node modules. - -```bash -cd examples/node-vanilla - -# install and run the example -npm install -npm run -``` - -## Node (Typescript) - -This is for larger and more established Node.js projects which use Typescript for type safety. You'll notice that the type declarations and inline documentation from `typescript-starter` are accessible to [Typescript-compatible editors](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Editor-Support) like [vscode](https://code.visualstudio.com/). - -```bash -cd examples/node-typescript - - # install the dependencies -npm install -# type-check and build the example -npm run build -# run the example -npm start -``` - -## Browser (tree-shaking with Rollup) - -This project imports the `power` and `asyncABC` functions from the ES6 output of `typescript-starter`, without importing the `double` function. This allows for the `double` method to be completely excluded from output via [Rollup's tree-shaking](http://rollupjs.org/), making the final javascript bundle potentially much smaller, even before using a minifier like [Uglify](https://github.com/mishoo/UglifyJS2). - -To demonstrate, this example doesn't minify or remove comments. You can see where some javascript has been excluded from the bundle. - -```bash -cd examples/browser - -# install the dependencies -npm install -# build the javascript bundle -npm run build -# start a server and open the test in a browser -npm start -``` diff --git a/src/cli/tests/cli.integration.spec.ts b/src/cli/tests/cli.integration.spec.ts index a3a7db2..63ba4f9 100644 --- a/src/cli/tests/cli.integration.spec.ts +++ b/src/cli/tests/cli.integration.spec.ts @@ -141,7 +141,7 @@ test(`${ const map = await hashAllTheThings(TestDirectories.one); t.deepEqual(map, { 'test-1/README.md': '7a9f4efa9213266c3800f3cc82a53ba7', - 'test-1/bin/typescript-starter': 'a4ad3923f37f50df986b43b1adb9f6b3', + 'test-1/bin/typescript-starter': 'df05a2c6c849f47761f0e24230359d3e', 'test-1/src/index.ts': '5991bedc40ac87a01d880c6db16fe349', 'test-1/src/lib/number.spec.ts': '40ebb014eb7871d1f810c618aba1d589', 'test-1/src/lib/number.ts': '43756f90e6ac0b1c4ee6c81d8ab969c7', @@ -179,7 +179,7 @@ test(`${ const map = await hashAllTheThings(TestDirectories.two); t.deepEqual(map, { 'test-2/README.md': 'ddaf27da4cc4ca5225785f0ac8f4da58', - 'test-2/bin/typescript-starter': 'a4ad3923f37f50df986b43b1adb9f6b3', + 'test-2/bin/typescript-starter': 'df05a2c6c849f47761f0e24230359d3e', 'test-2/src/index.ts': 'fbc67c2cbf3a7d37e4e02583bf06eec9', 'test-2/src/lib/async.spec.ts': '1e83b84de3f3b068244885219acb42bd', 'test-2/src/lib/async.ts': '9012c267bb25fa98ad2561929de3d4e2', @@ -285,7 +285,7 @@ test(`${ const map = await hashAllTheThings(TestDirectories.three); t.deepEqual(map, { 'test-3/README.md': 'c52631ebf78f6b030af9a109b769b647', - 'test-3/bin/typescript-starter': 'a4ad3923f37f50df986b43b1adb9f6b3', + 'test-3/bin/typescript-starter': 'df05a2c6c849f47761f0e24230359d3e', 'test-3/src/index.ts': 'fbc67c2cbf3a7d37e4e02583bf06eec9', 'test-3/src/lib/async.spec.ts': '1e83b84de3f3b068244885219acb42bd', 'test-3/src/lib/async.ts': '9012c267bb25fa98ad2561929de3d4e2', @@ -315,7 +315,7 @@ test(`${ const map = await hashAllTheThings(TestDirectories.four); t.deepEqual(map, { 'test-4/README.md': 'a3e0699b39498df4843c9dde95f1e000', - 'test-4/bin/typescript-starter': 'a4ad3923f37f50df986b43b1adb9f6b3', + 'test-4/bin/typescript-starter': 'df05a2c6c849f47761f0e24230359d3e', 'test-4/src/index.ts': '5991bedc40ac87a01d880c6db16fe349', 'test-4/src/lib/number.spec.ts': '40ebb014eb7871d1f810c618aba1d589', 'test-4/src/lib/number.ts': '43756f90e6ac0b1c4ee6c81d8ab969c7', @@ -380,7 +380,7 @@ test(`${ t.deepEqual(map, { 'test-5/LICENSE': 'd11b4dba04062af8bd80b052066daf1c', 'test-5/README.md': '8fc7ecb21d7d47289e4b2469eea4db39', - 'test-5/bin/typescript-starter': 'a4ad3923f37f50df986b43b1adb9f6b3', + 'test-5/bin/typescript-starter': 'df05a2c6c849f47761f0e24230359d3e', 'test-5/package.json': '350b37ef2d615462eeefc27d84d1eb21', 'test-5/src/index.ts': '5991bedc40ac87a01d880c6db16fe349', 'test-5/src/lib/number.spec.ts': '40ebb014eb7871d1f810c618aba1d589', @@ -413,7 +413,7 @@ test(`${TestDirectories.six}: Sandboxed: yarn, no initial commit`, async t => { t.deepEqual(map, { 'test-6/LICENSE': '1dfe8c78c6af40fc14ea3b40133f1fa5', 'test-6/README.md': 'd809bcbf240f44b51b575a3d49936232', - 'test-6/bin/typescript-starter': 'a4ad3923f37f50df986b43b1adb9f6b3', + 'test-6/bin/typescript-starter': 'df05a2c6c849f47761f0e24230359d3e', 'test-6/package.json': '635cf9c0e9fd16e9c29679108b8ebc3d', 'test-6/src/index.ts': 'fbc67c2cbf3a7d37e4e02583bf06eec9', 'test-6/src/lib/async.spec.ts': '1e83b84de3f3b068244885219acb42bd', diff --git a/src/cli/typescript-starter.ts b/src/cli/typescript-starter.ts index 6279cb9..800a01a 100644 --- a/src/cli/typescript-starter.ts +++ b/src/cli/typescript-starter.ts @@ -114,14 +114,6 @@ export async function typescriptStarter( } spinnerGitignore.succeed(); - const spinnerNpmignore = ora('Updating .npmignore').start(); - await replace({ - files: join(projectPath, '.npmignore'), - from: 'examples\n', - to: '' - }); - spinnerNpmignore.succeed(); - const spinnerLicense = ora('Updating LICENSE').start(); await replace({ files: join(projectPath, 'LICENSE'), @@ -133,7 +125,6 @@ export async function typescriptStarter( const spinnerDelete = ora('Deleting unnecessary files').start(); await del([ - join(projectPath, 'examples'), join(projectPath, 'CHANGELOG.md'), join(projectPath, 'README.md'), join(projectPath, 'package-lock.json'),