-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
790 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.json"], | ||
"parser": "jsonc-eslint-parser", | ||
"rules": { | ||
"@nx/dependency-checks": "error" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# create-pubkey-ui-app | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Building | ||
|
||
Run `nx build create-pubkey-ui-app` to build the library. | ||
|
||
## Running unit tests | ||
|
||
Run `nx test create-pubkey-ui-app` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env node | ||
|
||
import { createWorkspace } from 'create-nx-workspace' | ||
|
||
async function main() { | ||
const name = process.argv[2] // TODO: use libraries like yargs or enquirer to set your workspace name | ||
if (!name) { | ||
throw new Error('Please provide a name for the workspace') | ||
} | ||
|
||
console.log(`Creating the workspace: ${name}`) | ||
|
||
// This assumes "@pubkey-ui/generators" and "create-pubkey-ui-app" are at the same version | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const presetVersion = require('../package.json').version | ||
|
||
// TODO: update below to customize the workspace | ||
const { directory } = await createWorkspace(`@pubkey-ui/generators@${presetVersion}`, { | ||
name, | ||
nxCloud: false, | ||
packageManager: 'npm', | ||
webName: 'web', | ||
}) | ||
|
||
console.log(`Successfully created the workspace: ${directory}.`) | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'create-pubkey-ui-app', | ||
preset: '../../jest.preset.js', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/packages/create-pubkey-ui-app', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "create-pubkey-ui-app", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"create-nx-workspace": "17.1.3" | ||
}, | ||
"type": "commonjs", | ||
"main": "./src/index.js", | ||
"typings": "./src/index.d.ts", | ||
"bin": { | ||
"create-pubkey-ui-app": "./bin/index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "create-pubkey-ui-app", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/create-pubkey-ui-app/bin", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/js:tsc", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/packages/create-pubkey-ui-app", | ||
"main": "packages/create-pubkey-ui-app/bin/index.ts", | ||
"tsConfig": "packages/create-pubkey-ui-app/tsconfig.lib.json", | ||
"assets": ["packages/create-pubkey-ui-app/*.md"] | ||
} | ||
}, | ||
"publish": { | ||
"command": "node tools/scripts/publish.mjs create-pubkey-ui-app {args.ver} {args.tag}", | ||
"dependsOn": ["build"] | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["packages/create-pubkey-ui-app/**/*.ts", "packages/create-pubkey-ui-app/package.json"] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "packages/create-pubkey-ui-app/jest.config.ts" | ||
} | ||
} | ||
}, | ||
"tags": [], | ||
"implicitDependencies": ["generators"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"include": ["src/**/*.ts", "bin/**/*.ts"], | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { execSync } from 'child_process' | ||
import { join, dirname } from 'path' | ||
import { mkdirSync, rmSync } from 'fs' | ||
|
||
describe('create-pubkey-ui-app', () => { | ||
let projectDirectory: string | ||
|
||
afterAll(() => { | ||
// Cleanup the test project | ||
rmSync(projectDirectory, { | ||
recursive: true, | ||
force: true, | ||
}) | ||
}) | ||
|
||
it('should be installed', () => { | ||
projectDirectory = createTestProject() | ||
|
||
// npm ls will fail if the package is not installed properly | ||
execSync('npm ls @pubkey-ui/generators', { | ||
cwd: projectDirectory, | ||
stdio: 'inherit', | ||
}) | ||
}) | ||
}) | ||
|
||
/** | ||
* Creates a test project with create-nx-workspace and installs the plugin | ||
* @returns The directory where the test project was created | ||
*/ | ||
function createTestProject(extraArgs = '') { | ||
const projectName = 'test-project' | ||
const projectDirectory = join(process.cwd(), 'tmp', projectName) | ||
|
||
// Ensure projectDirectory is empty | ||
rmSync(projectDirectory, { | ||
recursive: true, | ||
force: true, | ||
}) | ||
mkdirSync(dirname(projectDirectory), { | ||
recursive: true, | ||
}) | ||
|
||
execSync(`npx --yes create-pubkey-ui-app@e2e ${projectName} ${extraArgs}`, { | ||
cwd: dirname(projectDirectory), | ||
stdio: 'inherit', | ||
env: process.env, | ||
}) | ||
console.log(`Created test project in "${projectDirectory}"`) | ||
|
||
return projectDirectory | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/generators/src/generators/application/application-generator-schema.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable */ | ||
/** | ||
* This file was automatically generated by json-schema-to-typescript. | ||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, | ||
* and run json-schema-to-typescript to regenerate this file. | ||
*/ | ||
|
||
export interface ApplicationGeneratorSchema { | ||
/** | ||
* Name of the application | ||
*/ | ||
name: string | ||
/** | ||
* Name of the web application (overrides name) | ||
*/ | ||
webName?: string | ||
/** | ||
* Skip formatting files | ||
*/ | ||
skipFormat?: boolean | ||
/** | ||
* Anchor template to use | ||
*/ | ||
anchor?: 'none' | 'counter' | 'hello-world' | ||
/** | ||
* Anchor project name | ||
*/ | ||
anchorName?: string | ||
} |
39 changes: 39 additions & 0 deletions
39
packages/generators/src/generators/application/application-generator-schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"$id": "ApplicationGeneratorSchema", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "Name of the application", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name would you like to use?" | ||
}, | ||
"webName": { | ||
"type": "string", | ||
"description": "Name of the web application (overrides name)" | ||
}, | ||
"skipFormat": { | ||
"description": "Skip formatting files", | ||
"type": "boolean", | ||
"default": false, | ||
"x-priority": "internal" | ||
}, | ||
"anchor": { | ||
"type": "string", | ||
"description": "Anchor template to use", | ||
"enum": ["none", "counter", "hello-world"], | ||
"default": "counter" | ||
}, | ||
"anchorName": { | ||
"type": "string", | ||
"description": "Anchor project name", | ||
"default": "anchor" | ||
} | ||
}, | ||
"required": ["name"] | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/generators/src/generators/application/application-generator.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing' | ||
import { Tree, readProjectConfiguration } from '@nx/devkit' | ||
|
||
import { applicationGenerator } from './application-generator' | ||
import { ApplicationGeneratorSchema } from './application-generator-schema' | ||
|
||
describe('application generator', () => { | ||
let tree: Tree | ||
const options: ApplicationGeneratorSchema = { name: 'test' } | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace() | ||
}) | ||
|
||
it('should run successfully', async () => { | ||
await applicationGenerator(tree, options) | ||
const config = readProjectConfiguration(tree, 'test') | ||
expect(config).toBeDefined() | ||
}) | ||
}) |
Oops, something went wrong.