Skip to content

Commit e93fcc0

Browse files
committed
feat: add example generator
1 parent 59ca5ab commit e93fcc0

8 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* Common shared example code
3+
*/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* Android example code
3+
*/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* Types
3+
*/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* iOS example code
3+
*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* This file can be ignored when creating projects.
3+
* Only used for demoing apps within this workspace.
4+
* Should contain empty implementations
5+
*/
6+
7+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "@stackblitz/nativescript-<%= name %>",
3+
"version": "0.0.1",
4+
"main": "index",
5+
"types": "index.d.ts"
6+
}

‎tools/generators/add/index.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { generateFiles, joinPathFragments, Tree } from '@nrwl/devkit';
2+
import { library as libraryGenerator } from '@nativescript/nx/src/generators/library/library';
3+
4+
export default async function(tree: Tree, schema: any) {
5+
const name = schema.name;
6+
await libraryGenerator(tree, {name});
7+
tree.delete(`libs/nativescript-${name}/src`);
8+
generateFiles(tree, joinPathFragments(__dirname, 'files', 'libs'), `./packages/nativescript-${name}`, {
9+
name,
10+
tmpl: '',
11+
dot: '.',
12+
});
13+
}

‎tools/generators/add/schema.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"cli": "nx",
4+
"$id": "add",
5+
"type": "object",
6+
"properties": {
7+
"name": {
8+
"type": "string",
9+
"description": "Example name",
10+
"$default": {
11+
"$source": "argv",
12+
"index": 0
13+
}
14+
}
15+
},
16+
"required": ["name"]
17+
}

0 commit comments

Comments
 (0)