Skip to content

Commit

Permalink
first monoclean version
Browse files Browse the repository at this point in the history
  • Loading branch information
teintinu committed Jul 25, 2021
1 parent 9fcfa88 commit 86588e6
Show file tree
Hide file tree
Showing 120 changed files with 8,961 additions and 6,793 deletions.
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/go/.devcontainer/base.Dockerfile

# [Choice] Go version: 1, 1.16, 1.15
ARG VARIANT="1.16"
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}

# [Option] Install Node.js
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment the next line to use go get to install anything else you need
# RUN go get -x <your-dependency-or-tool>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
38 changes: 38 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/go
{
"name": "Go",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.15
"VARIANT": "1.16",
// Options
"INSTALL_NODE": "true",
"NODE_VERSION": "lts/*"
}
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Set *default* container specific settings.json values on container create.
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
22 changes: 0 additions & 22 deletions .github/workflows/go.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish

on:
push:
tags:
- v**

permissions:
contents: write

jobs:

Publish:
runs-on: ubuntu-latest
steps:

# setup
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.17.3
- name: Prepare publishment
run: ./scripts/prepare.sh

# test
- name: Test
run: ./scripts/test.sh

# goreleaser:

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# publish:

- name: Publish NPM
uses: JS-DevTools/npm-publish@v1
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.NPM_TOKEN }}
package: npm/package.json
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test

on:
push:
branches:
- "*"
tags-ignore:
- "*"
pull_request:
branches:
- "*"
tags-ignore:
- "*"

permissions:
contents: write

jobs:

Test:
runs-on: ubuntu-latest
steps:

# setup
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.17.3
- name: Prepare publishment
run: ./scripts/prepare.sh

# test
- name: Test
run: ./scripts/test.sh
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
/uni
/monoclean

node_modules

npm/

snapshot/**/*.js
snapshot/**/*.map
snapshot/**/*.json
snapshot/**/stderr
snapshot/**/stdout
snapshot/**/yarn-lock

dist/
22 changes: 22 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

before:
hooks:
- go mod tidy
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"golang.go",
"ms-vscode-remote.remote-containers"
]
}
11 changes: 10 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"name": "reverse-args",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "main.go",
"cwd": "example",
"args": ["run", "./reverse-args.ts", "a", "b", "c"]
},
{
"name": "simple-workspace(deps)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"cwd": "${workspaceFolder}/examples/simple-workspace",
"args": ["deps"]
}
]
}
113 changes: 35 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,93 +1,50 @@
# Unirepo
# monoclean

Unirepo is an extremely opinionated TypeScript build tool.
A clean mono workspace automation

Typical monorepo management tools in the Node.js ecosystem provide automation
around package maintenance, but still permit and require users to muck around
with poly-package configuration. Package boundaries must be manually
maintained, each with its own sub-configuration.
# install

Unirepo is different because sub-package configuration is managed centrally and
uniformly. Package boundaries are managed automatically via bundling and code
splitting.
`npm i -g monoclean`

You will have one and only one list of dependencies. Your `package.json` files
will be generated from that source configuration. Same for `tsconfig.json`.
The source configuration file - believe it or not - allows code comments.
# Get stared

Unirepo is _fast_ because it is ships as a native binary and builds your code
using [esbuild][1].
## declare you workspace `monoclean.yml`

Additionally, Unirepo has a `run` subcommand that acts as a substitute for
[`ts-node`][2]. The `run` subcommand also supports a `--watch` flag, and so
acts as a substitute for [`node-dev`][3] (or [`ts-node-dev`][4]) as well.
Sourcemaps are always enabled.

As mentioned, Unirepo is extremely opinionated. Those opinions will evolve into
documentation, including a growing list of
[anti-features](./doc/anti-features.md).

Want to see it in action?
Check out the [Demo Video](https://www.youtube.com/watch?v=RJfLA7EM-Uw)!

## Status

Alpha! Don't use this yet.

See the [versioning guide](./doc/versioning.md) and the
[roadmap](./doc/roadmap.md).

Only works for targeting Node currently. Targeting Browsers is planned.

## Installation

```bash
go get -u github.com/deref/uni
```
engines:
node: "v14.17.3"
npm: "6.14.13"
workspace:
name: "example"
version: "1.0.0"
packages:
"@example/a":
folder: "a"
dependencies:
"@example/b": "*"
"@example/b":
folder: "b"
```

## Usage

- [Configuration](./doc/config.md)
- [Migration Guide](./doc/migrate.md)

### Setup

1. Create a `uni.yml` file with some package entrypoints.
2. Manually add dependencies to your config file.
3. Run `uni deps`.

### Development

- Use `uni run src/program.ts` to execute programs. They must export a `main` function.
- Use `uni build some-package` to pre-compile into `out/dist`.

### Publishing

Here's the steps to do in your CI flow:

1. `uni build --version $VERSION --types` to create packages with version numbers and types definitions.
2. `uni pack` to create packed `.tgz` files.
3. `uni publish` to automate `npm publish ./path/to/package.tgz`.

## Other Features
### `monoclean deps`

### Patching
It will create and maintain automatically package.json, tsconfig.json, eslint.json, jest.config.js...

The [patch-package][5] utility is always available.
### `monoclean run`

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

Functionality similar to [check-engine][6] is builtin, but much faster
and with caching.
### `monoclean`

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

Any runnable script can be exposed as an executable in a package. A shim script
(with a `#!`) will be produced automatically.
### another commands
- [ ] monoclean build
- [ ] monoclean deploy

[1]: https://esbuild.github.io/
[2]: https://github.com/TypeStrong/ts-node
[3]: https://github.com/fgnass/node-dev
[4]: https://github.com/wclr/ts-node-dev
[5]: https://github.com/ds300/patch-package
[6]: https://github.com/mohlsen/check-engine
## Notes
- This project is in alfa version, use responsibly.
- This project is based on https://github.com/deref/uni
Binary file added bin/goreleaser
Binary file not shown.
2 changes: 1 addition & 1 deletion cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"fmt"

"github.com/deref/uni/internal"
"github.com/spf13/cobra"
"github.com/teintinu/monoclean/internal"
)

var buildOpts internal.BuildOptions
Expand Down
Loading

0 comments on commit 86588e6

Please sign in to comment.