Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jcormont committed Jul 17, 2019
0 parents commit cc86898
Show file tree
Hide file tree
Showing 31 changed files with 859 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
*.log
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Jelmer Cormont

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Create Typescene Web App

Create front end applications with the Typescene framework, using the command line (CLI).

## Getting Started

You'll need to have NodeJS installed on your computer, but you do **not** need to install anything else.

To create a new app in a folder named `my-webapp`, run the following command in the Terminal (Mac) or Command Prompt (Windows):

```bash
npx create-typescene-webapp my-webapp
```

This will create a folder *inside* the current folder, copy source files, and install packages using NPM.

After installation, run the following commands to start a development server and open your default browser:

```bash
cd my-webapp
npm run start
```

## Options

You may use the following command line arguments to configure the installation.

| Argument | Effect |
|-----------------|-------------|
| `--js` | Use JS (ES6) only, instead of TypeScript |
| `--git` | Initialize a Git repository |
| `--bundler=`... | Use a specific bundler (either `webpack` or `parcel`) |
| `--overwrite` | Force overwrite existing files |

## Reach Out!

Find us on [Twitter](https://twitter.com/typescene) for the latest news, and please consider giving us a ⭐️ star on [GitHub](https://github.com/typescene/typescene)!

## Support

Support Typescene on [Patreon](https://www.patreon.com/typescene) for financial contributions.

For contributions in the form of bug fixes and changes, feel free to use [Pull Requests](https://github.com/typescene/typescene/pulls) or send us a DM on Twitter to discuss how best to approach your issue.

## License

The Typescene source code is licensed under the MIT license.
2 changes: 2 additions & 0 deletions bin/create-typescene-webapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require("../dist/index.js")
166 changes: 166 additions & 0 deletions package-lock.json

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

40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "create-typescene-app",
"version": "1.0.0",
"description": "Generator for apps using the Typescene framework",
"author": "Jelmer Cormont",
"license": "MIT",
"keywords": [
"typescene",
"generator",
"cli"
],
"repository": {
"type": "git",
"url": "git+https://github.com/typescene/create-typescene-webapp.git"
},
"bugs": {
"url": "https://github.com/typescene/create-typescene-webapp/issues"
},
"homepage": "http://typescene.dev/",
"main": "./dist/index.js",
"bin": "bin/create-typescene-webapp",
"files": [
"bin",
"index.js"
],
"scripts": {
"clean": "rimraf dist",
"prepublishOnly": "npm run build",
"prebuild": "npm run clean",
"build": "tsc -p src"
},
"dependencies": {
"chalk": "^2.4.2"
},
"devDependencies": {
"@types/node": "^12.6.6",
"typescript": "^3.5.3",
"rimraf": "^2.6.3"
}
}
38 changes: 38 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as path from "path";

const hasFlag = (...str: string[]) =>
str.some(flag => process.argv.some(s => s === flag));

const getOption = (name: string) =>
(process.argv.find(s => s.startsWith(name + "=")) || "")
.replace(/^.*\=/, "");

const folder = process.argv.slice(2).find(s => s[0] !== "-") || "";
const fullFolder = folder && path.resolve(folder);
const name = folder && path.basename(fullFolder);

const config = {
/** Project name */
name,

/** Folder name */
folder,

/** Absolute folder name */
fullFolder,

/** Force overwrite */
overwrite: hasFlag("--overwrite"),

/** Git init? */
git: hasFlag("-g", "--git"),

/** Use TypeScript? */
ts: !hasFlag("-j", "--js"),

/** Bundler (defaults to webpack) */
bundler: (getOption("--bundler") || getOption("-b") ||
"webpack").toLowerCase()
}

export default config;
Loading

0 comments on commit cc86898

Please sign in to comment.