Skip to content

Commit

Permalink
Merge pull request #77 from CrystallizeAPI/feature-full-bun
Browse files Browse the repository at this point in the history
feat: new crystallize cli
  • Loading branch information
Plopix authored Jan 14, 2025
2 parents 38f228b + c857f58 commit 6ea31ae
Show file tree
Hide file tree
Showing 64 changed files with 3,019 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/components/crystallize-cli"
directory: "/components/cli"
schedule:
interval: "weekly"
40 changes: 40 additions & 0 deletions .github/workflows/cli-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Crystallize CLI

on:
push:
branches: ["main"]
pull_request:
types: [opened, synchronize, reopened]

jobs:
build-and-test:
name: 🏗️ Build and Test
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: false

- name: ⎔ Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: 📥 Download deps
working-directory: components/cli
run: bun install --frozen-lockfile

- name: 🔍 Valid commit message
working-directory: components/cli
if: ${{ github.event_name == 'pull_request' }}
run: bun commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

- name: 💄 Prettier
working-directory: components/cli
run: bun prettier --check .

- name: 📲 Test the builds
working-directory: components/cli
run: make build
2 changes: 1 addition & 1 deletion .github/workflows/crystallize-cli-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Crystallize CLI
name: Crystallize CLI (Legacy)

on:
push:
Expand Down
26 changes: 26 additions & 0 deletions components/cli/.commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"header-max-length": [0, "never", 100],
"body-max-line-length": [2, "always", 400],
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"docs",
"feature",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"wip"
]
]
}
}
11 changes: 11 additions & 0 deletions components/cli/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Thanks for your pull request! We love contributions.

However, this repository is what we call a "subtree split": a read-only copy of one directory of the main repository. It enables developers to depend on specific repository.

If you want to contribute, you should instead open a pull request on the main repository:

https://github.com/CrystallizeAPI/tools

Thank you for your contribution!

PS: if you haven't already, please add tests.
9 changes: 9 additions & 0 deletions components/cli/.github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Thanks for reporting an issue! We love feedback.

However, this repository is what we call a "subtree split": a read-only copy of one directory of the main repository. It enables developers to depend on specific repository.

If you want to report or contribute, you should instead open your issue on the main repository:

https://github.com/CrystallizeAPI/tools

Thank you for your contribution!
21 changes: 21 additions & 0 deletions components/cli/.github/workflows/auto-close-issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
issues:
types: [opened, edited]

jobs:
autoclose:
runs-on: ubuntu-latest
steps:
- name: Close Issue
uses: peter-evans/close-issue@v1
with:
comment: |
Thanks for reporting an issue! We love feedback.
However, this repository is what we call a "subtree split": a read-only copy of one directory of the main repository. It enables developers to depend on specific repository.
If you want to report or contribute, you should instead open your issue on the main repository:
https://github.com/CrystallizeAPI/tools
Thank you for your contribution!
23 changes: 23 additions & 0 deletions components/cli/.github/workflows/auto-close-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
pull_request:
types: [opened, edited, reopened]

jobs:
autoclose:
runs-on: ubuntu-latest
steps:
- name: Close Pull Request
uses: peter-evans/close-pull@v1
with:
comment: |
Thanks for your pull request! We love contributions.
However, this repository is what we call a "subtree split": a read-only copy of one directory of the main repository. It enables developers to depend on specific repository.
If you want to contribute, you should instead open a pull request on the main repository:
https://github.com/CrystallizeAPI/tools
Thank you for your contribution!
PS: if you haven't already, please add tests.
52 changes: 52 additions & 0 deletions components/cli/.github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
push:
tags:
- '*'

name: Release a New Version

jobs:
releaseandpublish:
name: Release on Github
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: false

- name: ⎔ Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: 📥 Download deps
working-directory: components/cli
run: bun install --frozen-lockfile

- name: 🔨 Compiling the different versions
working-directory: components/cli
run: make build-all

- name: 🏷 Create GitHub Release
run: |
TAG_MESSAGE=$(gh api repos/${{ github.repository }}/git/tags/${GITHUB_SHA} --jq '.message' || git log -1 --pretty=format:%B $GITHUB_SHA)
TAG_NAME=$(gh api repos/${{ github.repository }}/git/tags/${GITHUB_SHA} --jq '.tag')
gh release create "${TAG_NAME}" --title "Release ${TAG_NAME}" --notes "${TAG_MESSAGE}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 🚀 Upload Assets
run: |
ASSET_PLATFORMS=("bun-linux-x64 bun-linux-arm64 bun-windows-x64 bun-darwin-x64 bun-darwin-arm64")
for platform in "${ASSET_PLATFORMS[@]}"; do
if [ -f "crystallize-$platform" ]; then
gh release upload "${GITHUB_REF_NAME} ($platform)" "crystallize-$platform" --clobber
echo "Uploaded file for platform $platform"
else
echo "File for platform $platform not found, skipping."
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions components/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
crystallize
2 changes: 2 additions & 0 deletions components/cli/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules

10 changes: 10 additions & 0 deletions components/cli/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tabWidth": 4,
"semi": true,
"useTabs": false,
"bracketSpacing": true,
"bracketSameLine": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
}
59 changes: 59 additions & 0 deletions components/cli/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"editor.detectIndentation": false,
"editor.tabSize": 4,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"typescript.suggest.paths": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/node_modules": true,
"**/.contentlayer": true,
"**/build": true,
"**/dist": true,
"**/.next": true,
"**/.astro": true,
"**/.turbo": true,
"**/.wrangler": true,
"**/.cache": true,
"**/.react-router": true
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/dist/*/**": true,
"**/build/*/**": true,
"**/.astro/*/**": true,
"**/.wrangler/*/**": true,
"**/coverage/*/**": true,
"**/tmp/*/**": true,
"**/.nx/*/**": true,
"**/.run/*/**": true
},
"todo-tree.general.tags": ["@todo:", "@fixme:", "@bug:"],
"todo-tree.general.statusBar": "top three",
"todo-tree.tree.groupedByTag": true,
"todo-tree.general.statusBarClickBehaviour": "reveal",
"todo-tree.general.tagGroups": {
"TODOs": ["@todo:"],
"BUGs": ["@fixme:", "@bug:"]
},
"todo-tree.highlights.customHighlight": {
"TODOs": {
"icon": "flame",
"foreground": "#ff9900"
},
"BUGs": {
"icon": "bug",
"foreground": "#ff0000"
}
},
"files.associations": {
"**/web/**/*.css": "tailwindcss"
}
}
21 changes: 21 additions & 0 deletions components/cli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2025 Crystallize, https://crystallize.com

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.
38 changes: 38 additions & 0 deletions components/cli/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# === Makefile Helper ===

# Styles
YELLOW=$(shell echo "\033[00;33m")
RED=$(shell echo "\033[00;31m")
RESTORE=$(shell echo "\033[0m")

.DEFAULT_GOAL := list

.PHONY: list
list:
@echo "******************************"
@echo "${YELLOW}Available targets${RESTORE}:"
@grep -E '^[a-zA-Z-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " ${YELLOW}%-15s${RESTORE} > %s\n", $$1, $$2}'
@echo "${RED}==============================${RESTORE}"

.PHONY: codeclean
codeclean: ## Code Clean
@bun prettier --write .

.PHONY: build
build: ## Build
@bun build --bundle src/index.ts --outfile crystallize.js --target=bun
@bun shim.ts
@bun build --compile --minify crystallize.js --outfile crystallize
@rm crystallize.js
@rm -f ./.*.bun-build


.PHONY: build-all
build-all:
@bun build --bundle src/index.ts --outfile crystallize.js --target=bun
@bun shim.ts
for target in bun-linux-x64 bun-linux-arm64 bun-windows-x64 bun-darwin-x64 bun-darwin-arm64; do \
bun build --compile --minify crystallize.js --outfile crystallize-$$target --target=$$target; \
done
@rm crystallize.js
@rm -f ./.*.bun-build
53 changes: 53 additions & 0 deletions components/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Crystallize CLI

---

This repository is what we call a "subtree split": a read-only copy of one directory of the main repository.

If you want to report or contribute, you should do it on the main repository: https://github.com/CrystallizeAPI/tools

---

## Help

```bash
npx @crystallize/cli-next@latest --help
```

## Features

### Install a new project based on a Boilerplate

```bash
npx @crystallize/cli-next@latest install ~/my-projects/my-ecommerce
```

This will create a new folder, download the boilerplate and `npm install` it.

```bash
npx @crystallize/cli-next@latest install ~/my-projects/my-ecommerce --bootstrap-tenant
```

This will do the same as the previous command but it will create a new Tenant with clean data from the Boilerplate.

### Dump a tenant

```bash
npx @crystallize/cli-next@latest dump ~/my-projects/mydumpfolder tenantIdentifier
```

This is dumping a Tenant.

### Install a new project based on a Boilerplate

```bash
npx @crystallize/cli-next@latest import ~/my-projects/mydumpfolder/spec.json aNewTenant
```

This is importing a Tenant based on a dump

### More Options

```bash
npx @crystallize/cli-next@latest --help
```
Binary file added components/cli/bun.lockb
Binary file not shown.
Loading

0 comments on commit 6ea31ae

Please sign in to comment.