This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add generator to monorepo * Squash all attempts (+21 squashed commits) Squashed commits: [cca27ae] enable jest projects [e7dc4ce] wip [dd3ea7a] run in order [cf87275] define projects [69baf16] use specific version [c880cfa] ignore generator test [e9e0fd3] update travis [4bbb3c0] update travis [d63118b] update travis config [267fe08] remove config [44883e8] update travis [40580c3] reduce node version [59b6add] update ignore rule [fbbd03c] update readme [b299dfe] remove script [a988933] fix test and lint [95b7d5b] try install and not install [f4583b4] remove unnecessary files [c735329] remove eslint-config-xo [49b3106] pass lint and test [56c6def] remove git and readd * can get test to pass if exclude generator-superset * add afterall to correct working directory * update config * add readme
- Loading branch information
Showing
13 changed files
with
272 additions
and
5 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
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 @@ | ||
* text=auto |
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,32 @@ | ||
# generator-superset | ||
|
||
[![Version](https://img.shields.io/npm/v/@superset-ui/generator-superset.svg?style=flat)](https://img.shields.io/npm/v/@superset-ui/generator-superset.svg?style=flat-square) | ||
[![David (path)](https://img.shields.io/david/apache-superset/superset-ui.svg?path=packages%2Fgenerator-superset&style=flat-square)](https://david-dm.org/apache-superset/superset-ui?path=packages/generator-superset) | ||
|
||
> Scaffolder for Superset | ||
## Installation | ||
|
||
First, install [Yeoman](http://yeoman.io) and `generator-superset` using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)). | ||
|
||
```bash | ||
npm install -g yo | ||
npm install -g @superset-ui/generator-superset | ||
``` | ||
|
||
## Usage | ||
|
||
Generate a new package in `@superset-ui` | ||
|
||
```bash | ||
cd superset-ui/packages | ||
mkdir superset-ui-new-package | ||
cd superset-ui-new-package | ||
yo @superset-ui/superset | ||
``` | ||
|
||
## License | ||
|
||
Apache-2.0 | ||
|
||
[learn more about Yeoman](http://yeoman.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,12 @@ | ||
const Generator = require('yeoman-generator'); | ||
|
||
module.exports = class extends Generator { | ||
initializing() { | ||
// Redirect the default 'app' generator | ||
// to 'package' subgenerator | ||
// until there are multiple subgenerators | ||
// then this can be changed into a menu to select | ||
// subgenerator. | ||
this.composeWith(require.resolve('../package')); | ||
} | ||
}; |
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 @@ | ||
/* eslint-disable sort-keys */ | ||
|
||
const Generator = require('yeoman-generator'); | ||
const chalk = require('chalk'); | ||
const yosay = require('yosay'); | ||
|
||
module.exports = class extends Generator { | ||
async prompting() { | ||
// Have Yeoman greet the user. | ||
this.log(yosay(`Welcome to the rad ${chalk.red('generator-superset')} generator!`)); | ||
|
||
this.option('skipInstall'); | ||
|
||
this.answers = await this.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: 'Package name:', | ||
default: this.appname.replace('superset ui ', ''), // Default to current folder name | ||
}, | ||
]); | ||
} | ||
|
||
writing() { | ||
this.fs.copyTpl( | ||
this.templatePath('package.json'), | ||
this.destinationPath('package.json'), | ||
this.answers, | ||
); | ||
this.fs.copyTpl( | ||
this.templatePath('README.md'), | ||
this.destinationPath('README.md'), | ||
this.answers, | ||
); | ||
this.fs.copy(this.templatePath('src/index.js'), this.destinationPath('src/index.js')); | ||
this.fs.copy(this.templatePath('test/index.js'), this.destinationPath('test/index.test.js')); | ||
} | ||
}; |
27 changes: 27 additions & 0 deletions
27
packages/generator-superset/generators/package/templates/README.md
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,27 @@ | ||
## @superset-ui/<%= name %> | ||
|
||
[![Version](https://img.shields.io/npm/v/@superset-ui/<%= name | ||
%>.svg?style=flat)](https://img.shields.io/npm/v/@superset-ui/<%= name %>.svg?style=flat) | ||
[![David (path)](https://img.shields.io/david/apache-superset/superset-ui.svg?path=packages%2Fsuperset-ui-<%= | ||
name | ||
%>&style=flat-square)](https://david-dm.org/apache-superset/superset-ui?path=packages/superset-ui-<%= | ||
name %>) | ||
|
||
Description | ||
|
||
#### Example usage | ||
|
||
```js | ||
import { xxx } from '@superset-ui/<%= name %>'; | ||
``` | ||
|
||
#### API | ||
|
||
`fn(args)` | ||
|
||
- Do something | ||
|
||
### Development | ||
|
||
`@data-ui/build-config` is used to manage the build configuration for this package including babel | ||
builds, jest testing, eslint, and prettier. |
26 changes: 26 additions & 0 deletions
26
packages/generator-superset/generators/package/templates/package.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,26 @@ | ||
{ | ||
"name": "@superset-ui/<%= name %>", | ||
"version": "0.0.0", | ||
"description": "Superset UI <%= name %>", | ||
"sideEffects": false, | ||
"main": "lib/index.js", | ||
"module": "esm/index.js", | ||
"files": [ | ||
"esm", | ||
"lib" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/apache-superset/superset-ui.git" | ||
}, | ||
"keywords": ["superset"], | ||
"author": "Superset", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/apache-superset/superset-ui/issues" | ||
}, | ||
"homepage": "https://github.com/apache-superset/superset-ui#readme", | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/generator-superset/generators/package/templates/src/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,2 @@ | ||
const x = 1; | ||
export default x; |
5 changes: 5 additions & 0 deletions
5
packages/generator-superset/generators/package/templates/test/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,5 @@ | ||
describe('My Test', () => { | ||
it('tests something', () => { | ||
expect(1).toEqual(1); | ||
}); | ||
}); |
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,37 @@ | ||
{ | ||
"name": "generator-superset", | ||
"version": "0.0.0", | ||
"description": "Scaffolder for Superset", | ||
"bugs": { | ||
"url": "https://github.com/apache-superset/superset-ui/issues" | ||
}, | ||
"homepage": "https://github.com/apache-superset/superset-ui#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/apache-superset/superset-ui.git" | ||
}, | ||
"author": "Superset", | ||
"files": [ | ||
"generators" | ||
], | ||
"main": "generators/index.js", | ||
"keywords": [ | ||
"yeoman", | ||
"generator", | ||
"superset", | ||
"yeoman-generator" | ||
], | ||
"devDependencies": { | ||
"yeoman-test": "^1.9.1", | ||
"yeoman-assert": "^3.1.0" | ||
}, | ||
"engines": { | ||
"npm": ">= 4.0.0" | ||
}, | ||
"dependencies": { | ||
"yeoman-generator": "^3.1.1", | ||
"chalk": "^2.4.1", | ||
"yosay": "^2.0.2" | ||
}, | ||
"license": "Apache-2.0" | ||
} |
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,34 @@ | ||
const path = require('path'); | ||
const assert = require('yeoman-assert'); | ||
const helpers = require('yeoman-test'); | ||
|
||
describe('generator-superset:app', () => { | ||
let dir; | ||
|
||
beforeAll(() => { | ||
dir = process.cwd(); | ||
|
||
return helpers | ||
.run(path.join(__dirname, '../generators/app')) | ||
.withPrompts({ name: 'my-package' }); | ||
}); | ||
|
||
it('creates files', () => { | ||
assert.file(['package.json', 'README.md', 'src/index.js', 'test/index.test.js']); | ||
}); | ||
|
||
/* | ||
* Change working directory back to original working directory | ||
* after the test has completed. | ||
* yeoman tests switch to tmp directory and write files there. | ||
* Usually this is fine for solo package. | ||
* However, for a monorepo like this one, | ||
* it made jest confuses with current directory | ||
* (being in tmp directory instead of superset-ui root) | ||
* and interferes with other tests in sibling packages | ||
* that are run after the yeoman tests. | ||
*/ | ||
afterAll(() => { | ||
process.chdir(dir); | ||
}); | ||
}); |
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,35 @@ | ||
const path = require('path'); | ||
const assert = require('yeoman-assert'); | ||
const helpers = require('yeoman-test'); | ||
|
||
describe('generator-superset:package', () => { | ||
let dir; | ||
|
||
beforeAll(() => { | ||
dir = process.cwd(); | ||
|
||
return helpers | ||
.run(path.join(__dirname, '../generators/package')) | ||
.withPrompts({ name: 'my-package' }) | ||
.withOptions({ skipInstall: true }); | ||
}); | ||
|
||
it('creates files', () => { | ||
assert.file(['package.json', 'README.md', 'src/index.js', 'test/index.test.js']); | ||
}); | ||
|
||
/* | ||
* Change working directory back to original working directory | ||
* after the test has completed. | ||
* yeoman tests switch to tmp directory and write files there. | ||
* Usually this is fine for solo package. | ||
* However, for a monorepo like this one, | ||
* it made jest confuses with current directory | ||
* (being in tmp directory instead of superset-ui root) | ||
* and interferes with other tests in sibling packages | ||
* that are run after the yeoman tests. | ||
*/ | ||
afterAll(() => { | ||
process.chdir(dir); | ||
}); | ||
}); |