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 committed Jan 14, 2025
1 parent 84103a7 commit 1cf364a
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 50 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy to Pages

on:
push:
branches: ['main']
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: false

- name: 📦 Setup Pages
uses: actions/configure-pages@v5

- name: 🦾 Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/'

- name: 🚢 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
18 changes: 8 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,29 @@ jobs:
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')
TAG_NAME=${GITHUB_REF_NAME}
TAG_MESSAGE=$(git tag -l --format='%(contents)' "$TAG_NAME")
gh release create "${TAG_NAME}" --title "Release ${TAG_NAME}" --notes "${TAG_MESSAGE}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_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")
ASSET_PLATFORMS=("bun-linux-x64" "bun-linux-arm64" "bun-windows-x64.exe" "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"
gh release upload "${GITHUB_REF_NAME}" "crystallize-$platform" --clobber
echo "Uploaded file for platform $platform"
else
echo "File for platform $platform not found, skipping."
echo "File for platform $platform not found, skipping."
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ codeclean: ## Code Clean
build: ## Build
@bun build --bundle src/index.ts --outfile crystallize.js --target=bun
@bun shim.ts
@bun build --compile --minify crystallize.js --outfile crystallize
@bun build --compile crystallize.js --outfile crystallize
@rm crystallize.js
@rm -f ./.*.bun-build

Expand Down
40 changes: 2 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,7 @@ If you want to report or contribute, you should do it on the main repository: ht
## Help

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

## 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
```
@todo!
13 changes: 13 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
<title>Crystallize CLI</title>
</head>
<body>
<pre>
<h1>Crystallize CLI</h1>
<p>Crystallize CLI is a command line tool that helps you to manage your Crystallize projects.</p>
<h2>Installation</h2>
<p>curl -LSs https://crystallizeapi.github.io/cli/install.bash | bash</p>
</pre>
</body>
</html>
42 changes: 42 additions & 0 deletions docs/install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

CRYSTALLIZE_HOME="$HOME/.crystallize"
mkdir -p $CRYSTALLIZE_HOME
cd $CRYSTALLIZE_HOME

OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

if [ "$ARCH" = "x86_64" ]; then
ARCH="x64"
elif [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
else
echo "❌ Unsupported architecture: $ARCH"
exit 1
fi

FILE="bun-${OS}-${ARCH}"

LATEST_RELEASE=$(curl -s "https://api.github.com/repos/crystallizeapi/cli/releases/latest" | grep tag_name | cut -d'"' -f 4)
URL="https://github.com/CrystallizeAPI/cli/releases/download/${LATEST_RELEASE}/crystallize-${FILE}"

echo "🌍 Detected platform: ${OS}-${ARCH}"
echo "📥 Downloading file: ${URL}"

if curl -fLO "${URL}"; then
echo "✅ Successfully downloaded ${FILE}"
else
echo "❌ Failed to download ${FILE}. Please check the URL or platform."
exit 1
fi

ln -sf $CRYSTALLIZE_HOME/crystallize-${FILE} $HOME/crystallize
chmod +x $HOME/crystallize

echo "You can now use Crystallize CLI by running: ~/crystallize"
echo ""
echo "- You may want to put ~/crystallize in you PATH"
echo "- You may want to creat an alias (in your .zshrc or .bashrc) alias crystallize='~/crystallize'"

~/crystallize
2 changes: 1 addition & 1 deletion shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
const bin = Bun.file('crystallize.js');
let content = await new Response(bin).text();
const pattern = /var Yoga = await initYoga\(await E\(_\(import\.meta\.url\)\.resolve\("\.\/yoga\.wasm"\)\)\);/g;
const replacement = `import Yoga from 'yoga-wasm-web/dist/yoga.wasm';`;
const replacement = `import initYogaAsm from 'yoga-wasm-web/asm'; const Yoga = initYogaAsm();`;
content = content.replace(pattern, replacement);
await Bun.write('crystallize.js', content);
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ try {
} else {
logger.fatal(`Unknown error.`);
}
console.error(exception);
logMemory();
process.exit(1);
}
Expand Down

0 comments on commit 1cf364a

Please sign in to comment.