From c1f9716d8b5da976465998ef30f3db2781d549d4 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sat, 1 Oct 2022 14:18:16 +0200 Subject: [PATCH] move astro-reactive-form to separate workspace --- demo/package.json | 4 +- demo/src/pages/index.astro | 11 ++- index.ts | 3 - package-lock.json | 93 +++++++++++++------ package.json | 40 +------- .../astro-reactive-form}/Form.astro | 5 +- .../astro-reactive-form/README.md | 0 .../components}/Field.astro | 6 +- .../components}/FieldSet.astro | 2 +- .../astro-reactive-form}/core/form-control.ts | 9 ++ .../astro-reactive-form}/core/form-group.ts | 0 packages/astro-reactive-form/core/index.ts | 2 + packages/astro-reactive-form/index.ts | 2 + packages/astro-reactive-form/package.json | 58 ++++++++++++ .../test}/Form.astro.test.js | 0 packages/astro-reactive-form/tsconfig.json | 3 + src/index.ts | 3 - tsconfig.json | 3 +- 18 files changed, 163 insertions(+), 81 deletions(-) delete mode 100644 index.ts rename {src => packages/astro-reactive-form}/Form.astro (64%) rename README.md => packages/astro-reactive-form/README.md (100%) rename {src => packages/astro-reactive-form/components}/Field.astro (85%) rename {src => packages/astro-reactive-form/components}/FieldSet.astro (84%) rename {src => packages/astro-reactive-form}/core/form-control.ts (74%) rename {src => packages/astro-reactive-form}/core/form-group.ts (100%) create mode 100644 packages/astro-reactive-form/core/index.ts create mode 100644 packages/astro-reactive-form/index.ts create mode 100644 packages/astro-reactive-form/package.json rename {test => packages/astro-reactive-form/test}/Form.astro.test.js (100%) create mode 100644 packages/astro-reactive-form/tsconfig.json delete mode 100644 src/index.ts diff --git a/demo/package.json b/demo/package.json index 9c315f6..99f0c66 100644 --- a/demo/package.json +++ b/demo/package.json @@ -11,11 +11,11 @@ "astro": "astro" }, "dependencies": { - "astro": "^1.4.2" + "astro": "^1.4.2", + "astro-reactive-form": "^0.1.1" }, "description": "``` npm create astro@latest -- --template minimal ```", "main": "index.js", - "devDependencies": {}, "repository": { "type": "git", "url": "git+https://github.com/ayoayco/astro-reactive-form.git" diff --git a/demo/src/pages/index.astro b/demo/src/pages/index.astro index 620d6b4..5309841 100644 --- a/demo/src/pages/index.astro +++ b/demo/src/pages/index.astro @@ -1,5 +1,7 @@ --- -import Form, { FormGroup } from '../../../'; +import { FormGroup, Submit } from 'astro-reactive-form/core'; +import Form from 'astro-reactive-form'; + const form = new FormGroup([ { name: 'username', @@ -19,6 +21,13 @@ form.controls.push({ name: 'is-awesome', label: 'is Awesome?', }); + +form.controls.push({ + type: 'submit', + name: 'submit', + value: 'Submit', + callBack: () => console.log('hey'), +} as Submit); --- diff --git a/index.ts b/index.ts deleted file mode 100644 index ab80aaf..0000000 --- a/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Form from './src/Form.astro'; -export default Form; -export * from './src/index'; diff --git a/package-lock.json b/package-lock.json index 17e4595..fcef22c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,45 +1,25 @@ { - "name": "astro-reactive-form", - "version": "0.1.1", + "name": "astro-reactive-form-workspace", + "version": "0.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "astro-reactive-form", - "version": "0.1.1", + "name": "astro-reactive-form-workspace", + "version": "0.0.0", "license": "ISC", "workspaces": [ - "demo" - ], - "devDependencies": { - "@types/chai": "^4.3.3", - "@types/eslint": "^8.4.6", - "@types/mocha": "^9.1.1", - "@types/node": "^18.7.18", - "@types/prettier": "^2.7.0", - "@typescript-eslint/eslint-plugin": "^5.37.0", - "@typescript-eslint/parser": "^5.37.0", - "astro": "^1.0.0", - "astro-component-tester": "^0.6.0", - "chai": "^4.3.6", - "eslint": "^8.23.1", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-prettier": "^4.2.1", - "mocha": "^10.0.0", - "prettier": "^2.7.1", - "prettier-plugin-astro": "^0.5.4", - "typescript": "^4.8.3" - }, - "peerDependencies": { - "astro": "^1.0.0" - } + "demo", + "packages/astro-reactive-form" + ] }, "demo": { "name": "@example/minimal", "version": "0.0.1", "license": "ISC", "dependencies": { - "astro": "^1.4.2" + "astro": "^1.4.2", + "astro-reactive-form": "^0.1.1" }, "devDependencies": {} }, @@ -1408,6 +1388,10 @@ "astro": "^1.0.0-rc.1" } }, + "node_modules/astro-reactive-form": { + "resolved": "packages/astro-reactive-form", + "link": true + }, "node_modules/bail": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", @@ -7938,6 +7922,32 @@ "type": "github", "url": "https://github.com/sponsors/wooorm" } + }, + "packages/astro-reactive-form": { + "version": "0.1.1", + "license": "ISC", + "devDependencies": { + "@types/chai": "^4.3.3", + "@types/eslint": "^8.4.6", + "@types/mocha": "^9.1.1", + "@types/node": "^18.7.18", + "@types/prettier": "^2.7.0", + "@typescript-eslint/eslint-plugin": "^5.37.0", + "@typescript-eslint/parser": "^5.37.0", + "astro": "^1.0.0", + "astro-component-tester": "^0.6.0", + "chai": "^4.3.6", + "eslint": "^8.23.1", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.2.1", + "mocha": "^10.0.0", + "prettier": "^2.7.1", + "prettier-plugin-astro": "^0.5.4", + "typescript": "^4.8.3" + }, + "peerDependencies": { + "astro": "^1.0.0" + } } }, "dependencies": { @@ -8376,7 +8386,8 @@ "@example/minimal": { "version": "file:demo", "requires": { - "astro": "^1.4.2" + "astro": "^1.4.2", + "astro-reactive-form": "*" } }, "@humanwhocodes/config-array": { @@ -8984,6 +8995,28 @@ "dev": true, "requires": {} }, + "astro-reactive-form": { + "version": "file:packages/astro-reactive-form", + "requires": { + "@types/chai": "^4.3.3", + "@types/eslint": "^8.4.6", + "@types/mocha": "^9.1.1", + "@types/node": "^18.7.18", + "@types/prettier": "^2.7.0", + "@typescript-eslint/eslint-plugin": "^5.37.0", + "@typescript-eslint/parser": "^5.37.0", + "astro": "^1.0.0", + "astro-component-tester": "^0.6.0", + "chai": "^4.3.6", + "eslint": "^8.23.1", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.2.1", + "mocha": "^10.0.0", + "prettier": "^2.7.1", + "prettier-plugin-astro": "^0.5.4", + "typescript": "^4.8.3" + } + }, "bail": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", diff --git a/package.json b/package.json index a2dc5fd..e50e06a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "astro-reactive-form", - "description": "The Reactive Form component for Astro 🔥", - "version": "0.1.1", + "name": "astro-reactive-form-workspace", + "description": "Astro Reactive Form Workspace", + "version": "0.0.0", "repository": "https://github.com/ayoayco/astro-reactive-form", "homepage": "https://ayco.io/showcase/astro-reactive-form", "type": "module", @@ -13,15 +13,6 @@ "email": "ramon.aycojr@gmail.com", "url": "https://ayco.io" }, - "files": [ - "src", - "index.ts" - ], - "keywords": [ - "astro-component", - "css", - "ui" - ], "scripts": { "test": "mocha --parallel --timeout 15000", "test:watch": "mocha --watch --parallel --timeout 15000", @@ -30,30 +21,9 @@ "lint:fix": "eslint --fix . --ext .ts,.js", "demo": "npm run dev -w demo" }, - "devDependencies": { - "@types/chai": "^4.3.3", - "@types/eslint": "^8.4.6", - "@types/mocha": "^9.1.1", - "@types/node": "^18.7.18", - "@types/prettier": "^2.7.0", - "@typescript-eslint/eslint-plugin": "^5.37.0", - "@typescript-eslint/parser": "^5.37.0", - "astro": "^1.0.0", - "astro-component-tester": "^0.6.0", - "chai": "^4.3.6", - "eslint": "^8.23.1", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-prettier": "^4.2.1", - "mocha": "^10.0.0", - "prettier": "^2.7.1", - "prettier-plugin-astro": "^0.5.4", - "typescript": "^4.8.3" - }, - "peerDependencies": { - "astro": "^1.0.0" - }, "license": "ISC", "workspaces": [ - "demo" + "demo", + "packages/astro-reactive-form" ] } diff --git a/src/Form.astro b/packages/astro-reactive-form/Form.astro similarity index 64% rename from src/Form.astro rename to packages/astro-reactive-form/Form.astro index 0dd02a5..3d0eea8 100644 --- a/src/Form.astro +++ b/packages/astro-reactive-form/Form.astro @@ -1,6 +1,7 @@ --- -import { FormGroup } from './core/form-group'; -import FieldSet from './FieldSet.astro'; +import type { FormGroup } from './core'; +import FieldSet from './components/FieldSet.astro'; + export interface Props { formGroups: FormGroup[]; } diff --git a/README.md b/packages/astro-reactive-form/README.md similarity index 100% rename from README.md rename to packages/astro-reactive-form/README.md diff --git a/src/Field.astro b/packages/astro-reactive-form/components/Field.astro similarity index 85% rename from src/Field.astro rename to packages/astro-reactive-form/components/Field.astro index 1b6e571..583b7cc 100644 --- a/src/Field.astro +++ b/packages/astro-reactive-form/components/Field.astro @@ -1,5 +1,5 @@ --- -import { FormControl } from './core/form-control'; +import { FormControl } from '../core/form-control'; export interface Props { control: FormControl; @@ -10,9 +10,9 @@ const { control } = Astro.props;
{ - control.label && (!control.labelPosition || control.labelPosition === 'left') ? ( + control.label && (!control.labelPosition || control.labelPosition === 'left') && ( - ) : null + ) } void; +} diff --git a/src/core/form-group.ts b/packages/astro-reactive-form/core/form-group.ts similarity index 100% rename from src/core/form-group.ts rename to packages/astro-reactive-form/core/form-group.ts diff --git a/packages/astro-reactive-form/core/index.ts b/packages/astro-reactive-form/core/index.ts new file mode 100644 index 0000000..cb076a1 --- /dev/null +++ b/packages/astro-reactive-form/core/index.ts @@ -0,0 +1,2 @@ +export * from './form-control'; +export * from './form-group'; diff --git a/packages/astro-reactive-form/index.ts b/packages/astro-reactive-form/index.ts new file mode 100644 index 0000000..52eccd6 --- /dev/null +++ b/packages/astro-reactive-form/index.ts @@ -0,0 +1,2 @@ +import Form from './Form.astro'; +export default Form; diff --git a/packages/astro-reactive-form/package.json b/packages/astro-reactive-form/package.json new file mode 100644 index 0000000..4e7ff6e --- /dev/null +++ b/packages/astro-reactive-form/package.json @@ -0,0 +1,58 @@ +{ + "name": "astro-reactive-form", + "description": "The Reactive Form component for Astro 🔥", + "version": "0.1.1", + "repository": "https://github.com/ayoayco/astro-reactive-form", + "homepage": "https://ayco.io/showcase/astro-reactive-form", + "type": "module", + "exports": { + ".": "./index.ts", + "./core": "./core/index.ts" + }, + "author": { + "name": "Ayo Ayco", + "email": "ramon.aycojr@gmail.com", + "url": "https://ayco.io" + }, + "files": [ + "core/", + "components/", + "Form.astro", + "index.ts" + ], + "keywords": [ + "astro-component", + "css", + "ui" + ], + "scripts": { + "test": "mocha --parallel --timeout 15000", + "test:watch": "mocha --watch --parallel --timeout 15000", + "format": "prettier -w .", + "lint": "eslint . --ext .ts,.js", + "lint:fix": "eslint --fix . --ext .ts,.js" + }, + "devDependencies": { + "@types/chai": "^4.3.3", + "@types/eslint": "^8.4.6", + "@types/mocha": "^9.1.1", + "@types/node": "^18.7.18", + "@types/prettier": "^2.7.0", + "@typescript-eslint/eslint-plugin": "^5.37.0", + "@typescript-eslint/parser": "^5.37.0", + "astro": "^1.0.0", + "astro-component-tester": "^0.6.0", + "chai": "^4.3.6", + "eslint": "^8.23.1", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.2.1", + "mocha": "^10.0.0", + "prettier": "^2.7.1", + "prettier-plugin-astro": "^0.5.4", + "typescript": "^4.8.3" + }, + "peerDependencies": { + "astro": "^1.0.0" + }, + "license": "ISC" +} diff --git a/test/Form.astro.test.js b/packages/astro-reactive-form/test/Form.astro.test.js similarity index 100% rename from test/Form.astro.test.js rename to packages/astro-reactive-form/test/Form.astro.test.js diff --git a/packages/astro-reactive-form/tsconfig.json b/packages/astro-reactive-form/tsconfig.json new file mode 100644 index 0000000..fbc2f5f --- /dev/null +++ b/packages/astro-reactive-form/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "astro/tsconfigs/strictest" +} diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 9530b6b..0000000 --- a/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './Form.astro'; -export * from './core/form-group'; -export * from './core/form-control'; diff --git a/tsconfig.json b/tsconfig.json index b4c42f4..7ba0404 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,6 @@ "allowJs": true, "noEmit": true }, - "include": ["index.ts", "src"] + "include": ["index.ts", "src"], + "extends": "astro/tsconfigs/strictest" }