Skip to content

Commit

Permalink
monoclean-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
teintinu committed Jul 25, 2021
1 parent 28ac3a9 commit 1705fbb
Show file tree
Hide file tree
Showing 13 changed files with 253 additions and 40 deletions.
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"golang.go",
"ms-vscode-remote.remote-containers"
"ms-vscode-remote.remote-containers",
"redhat.vscode-yaml",
"golang.go"
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"yaml.schemas": {
"docs/monoclean-schema.json": [
"monoclean.yml"
]
}
}
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# monoclean

A clean mono workspace automation
A clean repository automation for Typescript mono workspace projects. Includes yarn, jest and eslint predifined configurations. Customizations and new automations automations are planned.

# install

Expand All @@ -11,10 +11,6 @@ A clean mono workspace automation
## declare you workspace `monoclean.yml`

```
engines:
node: "v14.17.3"
npm: "6.14.13"
workspace:
name: "example"
version: "1.0.0"
Expand All @@ -37,7 +33,7 @@ It will create and maintain automatically package.json, tsconfig.json, eslint.js

`monoclean run [PACKAGE]` use esbuild to fasterly run `src/index.ts` on desired `[PACKAGE]`

### `monoclean`
### `monoclean test`

`monoclean test [PACKAGE]` use esbuild and jest to fasterly test all packages in the workspace

Expand Down
38 changes: 38 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Welcome to GitHub Pages

You can use the [editor on GitHub](https://github.com/teintinu/monoclean/edit/main/docs/index.md) to maintain and preview the content for your website in Markdown files.

Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files.

### Markdown

Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for

```markdown
Syntax highlighted code block

# Header 1
## Header 2
### Header 3

- Bulleted
- List

1. Numbered
2. List

**Bold** and _Italic_ and `Code` text

[Link](url) and ![Image](src)
```

For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/).

### Jekyll Themes

Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/teintinu/monoclean/settings/pages). The name of this theme is saved in the Jekyll `_config.yml` configuration file.

### Support or Contact

Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out.

139 changes: 139 additions & 0 deletions docs/monoclean-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "A clean repository automation for Typescript mono workspace projects",
"description": "A clean repository automation for Typescript mono workspace projects. Includes yarn, jest and eslint predifined configurations. Customizations and new automations automations are planned.",
"$id": "http://example.com/example.json",
"type": "object",
"required": [
"packages",
"workspace"
],
"properties": {
"engines": {
"$id": "#/properties/engines",
"type": "object",
"title": "Define Node engine version",
"required": [
"node",
"npm"
],
"properties": {
"node": {
"$id": "#/properties/engines/properties/node",
"type": "string",
"title": "Node.js version",
"examples": [
"v14.17.3"
]
},
"npm": {
"$id": "#/properties/engines/properties/npm",
"type": "string",
"title": "npm version",
"examples": [
"6.14.13"
]
}
},
"additionalProperties": false
},
"workspace": {
"$id": "#/properties/workspace",
"type": "object",
"title": "Workspace definition",
"required": [
"name",
"version"
],
"properties": {
"name": {
"$id": "#/properties/workspace/properties/name",
"$ref": "#/definitions/name",
"title": "The name of workspace"
},
"version": {
"$id": "#/properties/workspace/properties/version",
"$ref": "#/definitions/version",
"title": "Version used for all packages in that workspaces"
},
"dependencies": {
"$id": "#/properties/workspace/properties/dependencies",
"$ref": "#/definitions/dependencies",
"title": "The dependencies for all workspace"
}
},
"additionalProperties": false
},
"packages": {
"$id": "#/properties/packages",
"$ref": "#/definitions/packageList",
"title": "The packages on this workspace"
},
"business-rules": {
"$id": "#/properties/packages",
"$ref": "#/definitions/packageList",
"title": "These Clean Architecture packages defines business-rules"
},
"applications": {
"$id": "#/properties/packages",
"$ref": "#/definitions/packageList",
"title": "These Clean Architecture packages defines applications"
},
"adapters": {
"$id": "#/properties/packages",
"$ref": "#/definitions/packageList",
"title": "These Clean Architecture packages defines adapters"
}
},
"definitions": {
"name": {
"type": "string",
"pattern": "^([a-z][a-z1-9\\-]+)|(@[a-z][a-z1-9\\-]+\\/[a-z][a-z1-9\\-]*)$"
},
"version": {
"type": "string",
"pattern": "^([~^><=]*\\d+\\.\\d+\\.\\d+)|(\\*)$"
},
"dependencies": {
"type": "object",
"patternProperties": {
"^([a-z][a-z1-9\\-]+)|(@[a-z][a-z1-9\\-]+\\/[a-z][a-z1-9\\-]*)$": {
"$ref": "#/definitions/version"
}
},
"additionalProperties": false
},
"packageList": {
"type": "object",
"patternProperties": {
"^([a-z][a-z1-9\\-]+)|(@[a-z][a-z1-9\\-]+\\/[a-z][a-z1-9\\-]*)$": {
"$ref": "#/definitions/packageDef"
}
},
"additionalProperties": false
},
"packageDef": {
"type": "object",
"required": [
"folder"
],
"properties": {
"folder": {
"type": "string",
"title": "folder of this package relative to workspace",
"pattern": "^[^\\.\\/\\\\]"
},
"public": {
"type": "boolean",
"title": "Publish this package as public"
},
"dependencies": {
"$ref": "#/definitions/dependencies",
"title": "The dependencies for all workspace"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
2 changes: 1 addition & 1 deletion examples/new/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ tmp
out
.eslintrc.json
coverage
.vscode/extensions.json
.vscode

13 changes: 5 additions & 8 deletions examples/new/monoclean.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@

workspace:
name: "new"
version: "1.0.0"
dependencies:
"@types/node": 14.14.31
react: 17.0.1
"@types/react": 17.0.2

name: new
version: 1.0.0

packages:
"@new/a":
public: true
folder: "a"
dependencies:
"@new/b": "*"
"@new/b": "*"

"@new/b":
public: true
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-workspace/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ tmp
out
.eslintrc.json
coverage
.vscode/extensions.json
.vscode

4 changes: 0 additions & 4 deletions examples/simple-workspace/monoclean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,3 @@ packages:
workspace:
name: "simple-workspace"
version: "1.0.0"
dependencies:
"@types/node": 14.14.31
react: 17.0.1
"@types/react": 17.0.2
26 changes: 23 additions & 3 deletions internal/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func ConfigureRepository(repo *Repository) error {
if err := configureGitIgnore(repo); err != nil {
return err
}
if err := configureVsCodeSettings(repo); err != nil {
return err
}
if err := configureVsCodeRecommendedExtensions(repo); err != nil {
return err
}
Expand Down Expand Up @@ -83,19 +86,34 @@ tmp
out
.eslintrc.json
coverage
.vscode/extensions.json
.vscode
`

err := ioutil.WriteFile(gitignore, []byte(content), 0644)
return err
}

func configureVsCodeRecommendedExtensions(repo *Repository) error {
func configureVsCodeSettings(repo *Repository) error {
var vscodeDir = path.Join(repo.RootDir, ".vscode")
if err := os.MkdirAll(vscodeDir, 0755); err != nil {
return err
}
var extensionsJson = path.Join(vscodeDir, "settings.json")
var content = `{
"yaml.schemas": {
"https://teintinu.github.io/monoclean/monoclean-schema.json": [
"monoclean.yml"
]
}
}
`
err := ioutil.WriteFile(extensionsJson, []byte(content), 0644)
return err
}

func configureVsCodeRecommendedExtensions(repo *Repository) error {
var vscodeDir = path.Join(repo.RootDir, ".vscode")
var extensionsJson = path.Join(vscodeDir, "extensions.json")
var content = `{
"recommendations": [
Expand All @@ -111,7 +129,9 @@ func configureNvmRc(repo *Repository) error {

npmRc := path.Join(repo.RootDir, ".nvm.rc")
var content = repo.Engines["node"]

if len(content) == 0 {
return nil
}
err := ioutil.WriteFile(npmRc, []byte(content), 0644)
return err
}
Expand Down
17 changes: 17 additions & 0 deletions scripts/create-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

const fs = require("fs");
const stdinBuffer = fs.readFileSync(0, 'utf-8');
const versions = stdinBuffer
.split('\n')
.filter((l) => l.startsWith('v'))
.map((l) => l.substr(1).split('.').map(n=>parseInt(n,10)))
.sort((a, b) => {
for (let i = 0; i <= 2; i++) {
const d = b[ i ] - a[ i ]
if (d !== 0) return d
}
return 0
})
const last = versions[ 0 ]
const next = [ last[ 0 ], last[ 1 ], last[ 2 ] + 1 ]
console.log("v" + next.join('.'));
17 changes: 17 additions & 0 deletions scripts/create-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e

ROOT=`realpath $(dirname $0)/..`
cd $ROOT

next=`git tag -l | node $ROOT/scripts/create-version.js`

echo "Publish next version: $next"
read -p "Are you sure? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git tag $next
git push origin $next
fi
15 changes: 0 additions & 15 deletions scripts/createtag.sh

This file was deleted.

0 comments on commit 1705fbb

Please sign in to comment.