diff --git a/.npmrc b/.npmrc index cad57977..1dab4ed4 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -save-exact = true \ No newline at end of file +save-exact = true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d3f4c038..e83fe86b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -138,6 +138,16 @@ After your pull request is merged, you can safely delete your branch and pull th
-### ▶ 9. That's it! Thank you for your contribution! 🙏💓 +## ▶ 9. Publishing to a local registry + +To test if your changes will actually work once the changes are published, +it can be useful to publish to a local registry. + +- Run `npm i -g verdaccio` in Terminal 1 (keep it running) +- Run `verdaccio +- Run `npm adduser --registry http://localhost:4873` in Terminal 2 (real credentials are not required, you just need to be logged in. You can use your own login details. +- Run `npm publish [package] --registry=http://localhost:4783` + +### ▶ 10. That's it! Thank you for your contribution! 🙏💓 [commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit# diff --git a/README.md b/README.md index 7629d37c..2f5477f3 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ npm install -D qwik-nx ## Usage +### Generating a workspace + +``` +npx create-nx-workspace org-workspace --preset=qwik-nx +``` + ### Generating an application ``` diff --git a/packages/qwik-nx/generators.json b/packages/qwik-nx/generators.json index c2b63789..5e71767f 100644 --- a/packages/qwik-nx/generators.json +++ b/packages/qwik-nx/generators.json @@ -29,6 +29,11 @@ "schema": "./src/generators/library/schema.json", "description": "library generator", "aliases": ["lib"] + }, + "preset": { + "factory": "./src/generators/preset/generator", + "schema": "./src/generators/preset/schema.json", + "description": "preset generator" } } } diff --git a/packages/qwik-nx/src/generators/preset/generator.spec.ts b/packages/qwik-nx/src/generators/preset/generator.spec.ts new file mode 100644 index 00000000..66b3e93a --- /dev/null +++ b/packages/qwik-nx/src/generators/preset/generator.spec.ts @@ -0,0 +1,27 @@ +import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; +import { Tree, readProjectConfiguration } from '@nrwl/devkit'; + +import generator from './generator'; +import { QwikWorkspacePresetGeneratorSchema } from './schema'; + +describe('preset generator', () => { + let appTree: Tree; + const options: QwikWorkspacePresetGeneratorSchema = { + name: 'test', + style: 'css', + linter: 'none', + skipFormat: false, + unitTestRunner: 'none', + strict: false, + }; + + beforeEach(() => { + appTree = createTreeWithEmptyWorkspace(); + }); + + it('should run successfully', async () => { + await generator(appTree, options); + const config = readProjectConfiguration(appTree, 'test'); + expect(config).toBeDefined(); + }); +}); diff --git a/packages/qwik-nx/src/generators/preset/generator.ts b/packages/qwik-nx/src/generators/preset/generator.ts new file mode 100644 index 00000000..0731095c --- /dev/null +++ b/packages/qwik-nx/src/generators/preset/generator.ts @@ -0,0 +1,13 @@ +import { Tree } from '@nrwl/devkit'; +import { QwikWorkspacePresetGeneratorSchema } from './schema'; +import applicationGenerator from '../application/generator'; + +export default async function ( + tree: Tree, + options: QwikWorkspacePresetGeneratorSchema +) { + options.directory = ''; + options.name = options.qwikAppName ?? options.name; + options.style = options.qwikAppStyle ?? options.style; + return applicationGenerator(tree, options); +} diff --git a/packages/qwik-nx/src/generators/preset/schema.d.ts b/packages/qwik-nx/src/generators/preset/schema.d.ts new file mode 100644 index 00000000..3862e64b --- /dev/null +++ b/packages/qwik-nx/src/generators/preset/schema.d.ts @@ -0,0 +1,13 @@ +export interface QwikWorkspacePresetGeneratorSchema { + name: string; + qwikAppName: string; + tags?: string; + directory?: string; + + style: 'css' | 'scss' | 'styl' | 'less' | 'none'; + qwikAppStyle: 'css' | 'scss' | 'styl' | 'less' | 'none'; + linter: 'eslint' | 'none'; + skipFormat: boolean; + unitTestRunner: 'vitest' | 'none'; + strict: boolean; +} diff --git a/packages/qwik-nx/src/generators/preset/schema.json b/packages/qwik-nx/src/generators/preset/schema.json new file mode 100644 index 00000000..51a18c34 --- /dev/null +++ b/packages/qwik-nx/src/generators/preset/schema.json @@ -0,0 +1,70 @@ +{ + "$schema": "http://json-schema.org/schema", + "cli": "nx", + "$id": "QwikNxPreset", + "title": "", + "type": "object", + "properties": { + "qwikAppName": { + "type": "string", + "description": "", + "$default": { + "$source": "argv", + "index": 0 + }, + "x-prompt": "What name would you like to use?" + }, + "tags": { + "type": "string", + "description": "Add tags to the project (used for linting)", + "alias": "t" + }, + "qwikAppStyle": { + "description": "The file extension to be used for style files.", + "type": "string", + "default": "css", + "alias": "s", + "x-prompt": { + "message": "Which stylesheet format would you like to use?", + "type": "list", + "items": [ + { + "value": "css", + "label": "CSS" + }, + { + "value": "scss", + "label": "SASS(.scss) [ http://sass-lang.com ]" + }, + { + "value": "styl", + "label": "Stylus(.styl) [ http://stylus-lang.com ]" + }, + { + "value": "less", + "label": "LESS [ http://lesscss.org ]" + } + ], + "default": "css" + } + }, + "linter": { + "description": "The tool to use for running lint checks.", + "type": "string", + "enum": ["eslint", "none"], + "default": "eslint" + }, + "unitTestRunner": { + "type": "string", + "enum": ["vitest", "none"], + "description": "Test runner to use for unit tests.", + "default": "vitest" + }, + "strict": { + "type": "boolean", + "description": "Creates an application with strict mode and strict type checking.", + "default": true + } + }, + "required": ["name"] +}