Skip to content

Commit 8874989

Browse files
tino.goetzTino
authored andcommitted
feat: introduce first beta
* generalize template content * improve local template-development via deno
1 parent 3a65193 commit 8874989

File tree

119 files changed

+13724
-842
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+13724
-842
lines changed

.gitignore

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,85 @@ coverage
1515

1616
# Misc
1717
.DS_Store
18+
19+
### Node template
20+
# Logs
21+
/logs
22+
*.log
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# Runtime data
28+
pids
29+
*.pid
30+
*.seed
31+
*.pid.lock
32+
33+
# Directory for instrumented libs generated by jscoverage/JSCover
34+
lib-cov
35+
36+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
37+
.grunt
38+
39+
# Bower dependency directory (https://bower.io/)
40+
bower_components
41+
42+
# node-waf configuration
43+
.lock-wscript
44+
45+
# Compiled binary addons (https://nodejs.org/api/addons.html)
46+
build/Release
47+
48+
# Dependency directories
49+
node_modules/
50+
jspm_packages/
51+
52+
# TypeScript v1 declaration files
53+
typings/
54+
55+
# Optional npm cache directory
56+
.npm
57+
58+
# Optional eslint cache
59+
.eslintcache
60+
61+
# Optional REPL history
62+
.node_repl_history
63+
64+
# Output of 'npm pack'
65+
*.tgz
66+
67+
# Yarn Integrity file
68+
.yarn-integrity
69+
70+
# dotenv environment variables file
71+
.env
72+
73+
# parcel-bundler cache (https://parceljs.org/)
74+
.cache
75+
76+
# next.js build output
77+
.next
78+
79+
# nuxt.js build output
80+
.nuxt
81+
82+
# Nuxt generate
83+
dist
84+
85+
# vuepress build output
86+
.vuepress/dist
87+
88+
# Serverless directories
89+
.serverless
90+
91+
# Service worker
92+
sw.*
93+
94+
# Vim swap files
95+
*.swp
96+
97+
# Generated config files
98+
/lib/template/frameworks/nuxt/nuxt.config.ts
99+
/lib/template/frameworks/nuxt/tsconfig.json

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## Init 0.1.0
7+
* introduce first beta
8+
* generalize template content
9+
* improve local template-development via deno
10+
11+
612
## Init 0.0.1
713

814
* introduce client app generator

LOCAL_DEVELOPMENT.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Local Development
2+
3+
<img align="right" src=https://denolib.github.io/high-res-deno-logo/deno_hr_circle.png height="200px">
4+
5+
Make sure to have [deno](https://deno.land) installed
6+
7+
#### Support for your IDE
8+
* https://plugins.jetbrains.com/plugin/14382-deno
9+
* https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
10+
11+
1. Generate Config Files
12+
```bash
13+
# in the root directory run:
14+
deno run --allow-run --allow-write ./generateConfigFiles.ts
15+
```
16+
17+
2. Run and develop the template app
18+
```bash
19+
# in the app directory run:
20+
yarn install
21+
22+
# and
23+
yarn dev
24+
```
25+
26+
3. Reset the template
27+
```bash
28+
# in the app directory run:
29+
yarn reset:template
30+
```
31+
32+
4. Install the package from local template
33+
> Simulate `yarn create @borek-digital/client-app <my-app>` with packages on your local machine
34+
35+
```bash
36+
# install current package globally
37+
# in the root directory run:
38+
yarn global add file:$PWD
39+
40+
# generate a new project
41+
# anywhere:
42+
create-client-app <my-app>
43+
```
44+
45+
For detailed explanation on how things work, check out the following docs
46+
* [Yarn CLI](https://classic.yarnpkg.com/en/docs/cli/create)
47+
* [SAO](https://github.com/saojs/sao)
48+
* [CAC](https://github.com/cacjs/cac)

README.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
11
![project-preview](https://repository-images.githubusercontent.com/321372855/d5341c00-3eef-11eb-98df-ea53afd93f66)
22

3-
# Create Client App
4-
> Create a highly opinionated, but standardized borek.digital client app
5-
63
![NPM Publish](https://github.com/borekDigital/create-client-app/workflows/NPM%20Publish/badge.svg)
74
![GitHub](https://img.shields.io/github/license/borekDigital/create-client-app)
85
[![NPM version](https://img.shields.io/npm/v/@borek-digital/create-client-app.svg?style=flat)](https://www.npmjs.com/package/@borek-digital/create-client-app)
96

7+
# Create Client App
8+
> Create a highly opinionated, but standardized borek.digital client app
9+
1010
## Getting started
1111
> Make sure to have [yarn](https://classic.yarnpkg.com/en) (>= 1.10) installed
1212
```bash
1313
yarn create @borek-digital/client-app <my-app>
1414
```
1515

16-
## Contribute
17-
18-
### Local Development
19-
> Make sure to have [yarn](https://classic.yarnpkg.com/en) installed
20-
21-
Simulate `yarn create @borek-digital/client-app <my-app>` with packages on your local machine
22-
23-
```bash
24-
# install current package globally
25-
# in the create-client-app directory:
26-
yarn global add file:$PWD
16+
...that's basically it - have fun 🤓
2717

28-
# generate a new project
29-
# anywhere:
30-
create-client-app <my-app>
31-
```
32-
33-
For detailed explanation on how things work, check out the following docs
34-
* [Yarn CLI](https://classic.yarnpkg.com/en/docs/cli/create)
35-
* [SAO](https://github.com/saojs/sao)
36-
* [CAC](https://github.com/cacjs/cac)
18+
## Contribute
19+
see some hints for [local development of the template](LOCAL_DEVELOPMENT.md)

generateConfigFiles.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { urlJoin } from 'https://deno.land/x/url_join/mod.ts';
2+
import { exec } from 'https://cdn.depjs.com/exec/mod.ts'
3+
4+
const libDir = 'lib'
5+
const libTemplateDir = urlJoin(libDir, 'template')
6+
const libNuxtDir = urlJoin(libTemplateDir, 'frameworks/nuxt')
7+
8+
const templatePathNuxtConfig = urlJoin(libNuxtDir, 'nuxt.config.ejs')
9+
const outputPathNuxtConfig = urlJoin(libNuxtDir, 'nuxt.config.ts')
10+
11+
const templatePathTsConfig = urlJoin(libNuxtDir, 'tsconfig.ejs')
12+
const outputPathTsConfig = urlJoin(libNuxtDir, 'tsconfig.json')
13+
14+
const readNuxtConfigTemplate = Deno.run({
15+
cmd: [
16+
'deno',
17+
'run',
18+
'--allow-read',
19+
'./readConfigTemplate.ts',
20+
templatePathNuxtConfig
21+
],
22+
stdout: 'piped',
23+
stderr: 'piped',
24+
});
25+
26+
const readTsConfigTemplate = Deno.run({
27+
cmd: [
28+
'deno',
29+
'run',
30+
'--allow-read',
31+
'./readConfigTemplate.ts',
32+
templatePathTsConfig
33+
],
34+
stdout: 'piped',
35+
stderr: 'piped',
36+
});
37+
38+
// nuxt.config
39+
const statusNuxtConfig = await readNuxtConfigTemplate.status();
40+
41+
if (statusNuxtConfig.code === 0) {
42+
const rawOutput = await readNuxtConfigTemplate.output();
43+
const string = new TextDecoder().decode(rawOutput)
44+
45+
await Deno.writeTextFile(outputPathNuxtConfig, string);
46+
47+
// await exec({
48+
// cmd: ['yarn', 'lint:fix'],
49+
// cwd: `./${libNuxtDir}`,
50+
// })
51+
52+
console.log(`\n🎉 Successfully created ${outputPathNuxtConfig}\n`)
53+
} else {
54+
const rawError = await readNuxtConfigTemplate.stderrOutput();
55+
const errorString = new TextDecoder().decode(rawError);
56+
57+
console.log(errorString);
58+
}
59+
60+
// tsconfig
61+
const statusTsConfig = await readTsConfigTemplate.status();
62+
63+
if (statusTsConfig.code === 0) {
64+
const rawOutput = await readTsConfigTemplate.output();
65+
const string = new TextDecoder().decode(rawOutput)
66+
67+
await Deno.writeTextFile(outputPathTsConfig, string);
68+
69+
console.log(`\n🥳 Successfully created ${outputPathTsConfig}\n`)
70+
} else {
71+
const rawError = await readTsConfigTemplate.stderrOutput();
72+
const errorString = new TextDecoder().decode(rawError);
73+
74+
console.log(errorString);
75+
}
76+
77+
Deno.exit();

lib/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ cli
3838
if (files.length) {
3939
return console.log(chalk.red(`Can't create ${outDir} because there's already a non-empty directory ${outDir} existing in path.`))
4040
}
41-
console.log(chalk`✨ Generating Nuxt.js project in {cyan ${outDir}}`)
41+
console.log(chalk`\n✨ Generating a borek.digital client app in {cyan ${outDir}}\n`)
4242

4343
const { verbose, answers } = cliOptions
4444
const logLevel = verbose ? 4 : 2
45-
// See https://saojs.org/api.html#standalone-cli
45+
// See https://sao.vercel.app/api.html#standalone-cli
4646
sao({ generator, outDir, logLevel, answers, cliOptions })
4747
.run()
4848
.catch((err) => {

lib/package.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,17 @@ module.exports = {
1111
requireJSON (filename) {
1212
return JSON.parse(JSON.stringify(this.requireFile(filename)))
1313
},
14-
loadPackage (name, generator) {
15-
if (!name || name === 'none') {
16-
return {}
17-
}
18-
const prefix = name === 'nuxt' ? 'nuxt' : `frameworks/${name}`
19-
20-
const pkg = this.requireJSON(`./template/${prefix}/package.json`)
21-
const pkgHandler = this.requireFile(`./template/${prefix}/package.js`)
14+
loadFramework (name, generator) {
15+
const pkg = this.requireJSON(`./template/frameworks/${name}/package.json`)
16+
const pkgHandler = this.requireFile(`./template/frameworks/${name}/package.js`)
2217

2318
return pkgHandler.apply ? pkgHandler.apply(pkg, generator) : pkg
2419
},
2520
load (generator) {
26-
const nuxtPkg = this.loadPackage('nuxt', generator)
27-
const uiPkg = this.loadPackage('vuetify', generator)
28-
const testPkg = this.loadPackage('jest', generator)
21+
const nuxt = this.loadFramework('nuxt', generator)
22+
const jest = this.loadFramework('jest', generator)
2923

30-
const pkg = merge(nuxtPkg, uiPkg, testPkg)
24+
const pkg = merge(nuxt, jest)
3125

3226
pkg.dependencies = sortByKey(pkg.dependencies)
3327
pkg.devDependencies = sortByKey(pkg.devDependencies)

lib/prompts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = [
1111
pageSize: 10,
1212
choices: [
1313
{ name: 'Axios - Promise based HTTP client', value: 'axios' },
14+
{ name: 'NoIndex - Request crawlers to not index the page', value: 'noindex' },
1415
],
1516
default: []
1617
},

0 commit comments

Comments
 (0)