Skip to content

Commit

Permalink
chore: Monorepo refactor (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 authored Apr 4, 2024
1 parent 978fcb6 commit cf088b5
Show file tree
Hide file tree
Showing 38 changed files with 153 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Basic Setup
description: Install PNPM, Node, and dependencies
description: Install Bun and dependencies
runs:
using: composite
steps:
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ on:
- main

jobs:
checks:
npm-checks:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: bun build:npm
- run: bun check
build:
working-directory: npm
- run: bun test
working-directory: npm
web-checks:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: bun build:web:nuxt
tests:
- run: bun check
working-directory: web
web-build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- uses: bun test
- run: bun run build:nuxt
working-directory: web
11 changes: 0 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
node_modules
.output
.data
.nuxt
.nitro
.cache
dist
coverage
.cutlistrc
.DS_Store
.env
.env.*
!.env.example
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# onshape-cutlist
# @aklinker1/cutlist

Website and NPM tool for generating cutlists for an onshape assembly.

Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions npm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
coverage
8 changes: 4 additions & 4 deletions build.npm.ts → npm/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Cleanup
import { rmdir } from 'node:fs/promises';
await rmdir('dist/npm', { recursive: true }).catch(() => {});
await rmdir('dist', { recursive: true }).catch(() => {});
import pkg from './package.json';

// Build Declaration File
Expand All @@ -12,13 +12,13 @@ if (tsc.exitCode != null && tsc.exitCode > 0) process.exit(tsc.exitCode);

// Build JS
await Bun.build({
entrypoints: ['src/index.ts'],
outdir: 'dist/npm',
entrypoints: ['src/index.ts', 'src/onshape.ts'],
outdir: 'dist',
target: 'node',
splitting: true,
external: Object.keys(pkg.dependencies).concat(
Object.keys(pkg.devDependencies),
),
});

console.log('\x1b[1m\x1b[32m✔\x1b[0m Build \x1b[36mdist/npm\x1b[0m');
console.log('\x1b[1m\x1b[32m✔\x1b[0m Build \x1b[36mdist\x1b[0m');
55 changes: 55 additions & 0 deletions npm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "@aklinker1/cutlist",
"version": "0.4.0",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/aklinker1/cutlist"
},
"keywords": [
"onshape",
"cutlist",
"woodworking"
],
"license": "MIT",
"author": {
"name": "Aaron Klinker",
"email": "[email protected]"
},
"files": [
"dist"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"./onshape": {
"import": {
"types": "./dist/onshape.d.ts",
"import": "./dist/onshape.js"
}
}
},
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"check": "check -b ../node_modules/.bin",
"dev": "bun test --watch",
"build": "bun build.ts",
"prepare": "bun run build"
},
"dependencies": {
"@antfu/utils": "^0.7.7",
"base64-js": "^1.5.1",
"consola": "^3.2.3",
"ofetch": "^1.3.3",
"zod": "^3.22.4"
},
"devDependencies": {
"publint": "^0.2.7",
"typescript": "^5.0.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/index.ts → npm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BoardLayout, Rectangle } from './geometry';
import { Distance } from './units';

export * from './types';
export * from './units';

export async function getBoardLayouts(
onshape: OnshapeApiClient,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tsconfig.build.json → npm/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"extends": "./tsconfig.json",
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "dist/npm"
"outDir": "dist"
},
"include": ["src/**/*"],
"exclude": ["src/cli.ts", "src/**/*.test.ts"]
"exclude": ["src/**/*.test.ts"]
}
3 changes: 3 additions & 0 deletions npm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../tsconfig.json"
}
77 changes: 13 additions & 64 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,77 +1,22 @@
{
"name": "onshape-cutlist",
"version": "0.4.0",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/aklinker1/onshape-cutlist"
},
"keywords": [
"onshape",
"cutlist",
"woodworking"
],
"license": "MIT",
"author": {
"name": "Aaron Klinker",
"email": "[email protected]"
},
"files": [
"bin",
"dist/npm"
"private": true,
"workspaces": [
"npm",
"web"
],
"bin": {
"cutlist": "./bin/cutlist.mjs"
},
"exports": {
".": {
"import": {
"types": "./dist/npm/index.d.ts",
"import": "./dist/npm/index.js"
}
}
},
"module": "./dist/npm/index.js",
"types": "./dist/npm/index.d.ts",
"scripts": {
"dev": "nuxt dev",
"build:npm": "bun build.npm.ts",
"build:web": "bun build:web:nuxt && bun build:web:docker",
"build:web:nuxt": "nuxt build",
"build:web:docker": "docker build . -t aklinker1/cutlist --platform=linux/amd64",
"preview:web": "nuxt preview",
"preview:web:docker": "docker run -it -p 3000:3000 --env-file .env aklinker1/cutlist",
"publish:web:docker": "bun build:web && docker push aklinker1/cutlist",
"prepare": "simple-git-hooks",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@antfu/utils": "^0.7.7",
"@tanstack/vue-query": "^5.28.4",
"base64-js": "^1.5.1",
"consola": "^3.2.3",
"js-yaml": "^4.1.0",
"ofetch": "^1.3.3",
"zod": "^3.22.4"
"dev": "bun --cwd web dev",
"check": "bun --cwd npm check && bun --cwd web check",
"prepare": "simple-git-hooks"
},
"devDependencies": {
"@aklinker1/check": "^1.1.0",
"@nuxt/ui": "^2.14.2",
"@types/bun": "latest",
"@types/js-yaml": "^4.0.9",
"@vueuse/core": "^10.9.0",
"@vueuse/nuxt": "^10.9.0",
"lint-staged": "^15.2.2",
"nuxt": "^3.11.0",
"prettier": "^3.2.5",
"publint": "^0.2.7",
"simple-git-hooks": "^2.11.0",
"typescript": "^5.0.0",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
"simple-git-hooks": "^2.11.0"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
"pre-commit": "bun lint-staged"
},
"lint-staged": {
"*": "prettier --ignore-unknown --write"
Expand All @@ -80,5 +25,9 @@
"excludeAuthors": [
"[email protected]"
]
},
"dependencies": {
"@aklinker1/check": "^1.3.1",
"standard-version": "^9.5.0"
}
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json",
"compilerOptions": {
// Enable latest features
"lib": ["ESNext"],
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.output
.nuxt
.nitro
.env
.env.*
!.env.example
File renamed without changes.
4 changes: 2 additions & 2 deletions web/components/LayoutList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { BoardLayout } from '~~/src';
import { Distance } from '~~/src/units';
import type { BoardLayout } from '@aklinker1/cutlist';
import { Distance } from '@aklinker1/cutlist';
defineProps<{
layouts: BoardLayout[];
Expand Down
2 changes: 1 addition & 1 deletion web/components/LayoutListItem.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { Distance } from '~~/src/units';
import { Distance } from '@aklinker1/cutlist';
const props = defineProps<{
layout: BoardLayout;
Expand Down
8 changes: 4 additions & 4 deletions web/components/MainSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { Config, Project } from '~~/src';
import { Distance } from '~~/src/units';
import type { Config, Project } from '@aklinker1/cutlist';
import { Distance } from '@aklinker1/cutlist';
const url = useAssemblyUrl();
Expand Down Expand Up @@ -64,7 +64,7 @@ const tab = ref<'bom' | 'stock' | 'settings' | 'warnings'>('bom');
color="black"
variant="ghost"
square
to="https://github.com/aklinker1/onshape-cutlist/wiki"
to="https://github.com/aklinker1/cutlist/wiki"
target="_blank"
>
User Manual
Expand All @@ -75,7 +75,7 @@ const tab = ref<'bom' | 'stock' | 'settings' | 'warnings'>('bom');
color="black"
variant="ghost"
square
to="https://github.com/aklinker1/onshape-cutlist"
to="https://github.com/aklinker1/cutlist"
target="_blank"
>
GitHub
Expand Down
2 changes: 1 addition & 1 deletion web/components/StockMatrixInput.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { StockMatrix } from '~~/src';
import { StockMatrix } from '@aklinker1/cutlist';
import { z } from 'zod';
import YAML from 'js-yaml';
Expand Down
2 changes: 1 addition & 1 deletion web/composables/useBladeWidth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Distance } from '~~/src/units';
import { Distance } from '@aklinker1/cutlist';

/**
* Returns the blade width in standard units based off the settings.
Expand Down
2 changes: 1 addition & 1 deletion web/composables/useBoardLayoutsQuery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery } from '@tanstack/vue-query';
import { useOnshapeUrl } from './useOnshapeUrl';
import { type Project, getBoardLayouts, type Config } from '~~/src';
import { type Project, getBoardLayouts, type Config } from '@aklinker1/cutlist';

export default function () {
const onshape = useOnshapeApi();
Expand Down
2 changes: 1 addition & 1 deletion web/composables/useFormatDistance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Distance, toFraction } from '~~/src/units';
import { Distance, toFraction } from '@aklinker1/cutlist';

export default function () {
const unit = useDistanceUnit();
Expand Down
2 changes: 1 addition & 1 deletion web/composables/useOnshapeApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineOnshapeApi } from '~~/src/onshape';
import { defineOnshapeApi } from '@aklinker1/cutlist/onshape';

export default createGlobalState(() =>
defineOnshapeApi({
Expand Down
2 changes: 1 addition & 1 deletion web/composables/useStock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StockMatrix } from '~~/src';
import type { StockMatrix } from '@aklinker1/cutlist';

export default createGlobalState(() =>
useLocalStorage<StockMatrix[]>('@cutlist/stock', [
Expand Down
1 change: 0 additions & 1 deletion nuxt.config.ts → web/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { resolve } from 'node:path';

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
srcDir: 'web',
modules: ['@nuxt/ui', '@vueuse/nuxt'],
ssr: true, // SSG
runtimeConfig: {
Expand Down
Loading

0 comments on commit cf088b5

Please sign in to comment.