1
0
mirror of synced 2025-11-08 04:48:04 +00:00

docs(examples): remove examples (no longer needed)

This commit is contained in:
Jason Dreyzehner
2018-03-12 00:42:42 -04:00
parent b1110bcd2d
commit ac57abb921
16 changed files with 8 additions and 233 deletions

View File

@@ -11,4 +11,3 @@ build/docs
coverage
.nyc_output
*.log
examples

View File

@@ -56,10 +56,6 @@ Also consider installing editor extensions for [TSLint](https://github.com/Micro
<img alt="Typescript Editor Support vscode" width="600" src="https://cloud.githubusercontent.com/assets/904007/23042221/ccebd534-f465-11e6-838d-e2449899282c.png">
</p>
## 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

View File

@@ -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');
require('../build/main/cli/cli.js');

View File

@@ -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
}

View File

@@ -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
})
]
}

View File

@@ -1,10 +0,0 @@
<html>
<head>
<script src="test.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -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) )

View File

@@ -1,16 +0,0 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "build",
"rootDir": "src",
"module": "es6",
"declaration": false,
"removeComments": true,
"lib": [
"dom"
]
},
"include": [
"src/*.ts"
]
}

View File

@@ -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
}

View File

@@ -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) )

View File

@@ -1,10 +0,0 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "build",
"rootDir": "src"
},
"include": [
"src/*.ts"
]
}

View File

@@ -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
}

View File

@@ -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) );

View File

@@ -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
```

View File

@@ -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',

View File

@@ -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'),