generator-reshow 0.0.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/generators/app/README.md +4 -0
- package/generators/app/__tests__/TestApp.js +15 -4
- package/generators/app/index.js +32 -45
- package/generators/app/templates/README.md +9 -0
- package/generators/app/templates/data/env +1 -0
- package/generators/app/templates/package.json +7 -9
- package/generators/app/templates/screen.sh +34 -0
- package/generators/app/templates/ui/pages/Page1.jsx +8 -0
- package/generators/app/templates/ui/pages/Page2.jsx +8 -0
- package/generators/app/templates/ui/pages/index.jsx +5 -3
- package/generators/app/templates/ui/templates/Doc.jsx +1 -1
- package/generators/compile-sh/README.md +8 -0
- package/generators/compile-sh/__tests__/Test.js +45 -0
- package/generators/compile-sh/index.js +12 -0
- package/generators/{app → compile-sh}/templates/compile.sh +47 -10
- package/generators/generator/README.md +9 -0
- package/generators/generator/__tests__/TestGenerator.js +44 -0
- package/generators/generator/index.js +31 -51
- package/generators/generator/templates/README.md +9 -0
- package/generators/generator/templates/Test.js +45 -0
- package/generators/generator/templates/index.js +65 -0
- package/generators/generator/templates/templates/README.md +9 -0
- package/generators/library/README.md +9 -0
- package/generators/library/__tests__/Test.js +45 -0
- package/generators/library/index.js +84 -0
- package/generators/library/templates/README.md +15 -0
- package/generators/library/templates/Test.js +10 -0
- package/generators/library/templates/compile.sh +3 -0
- package/generators/library/templates/package.json +34 -0
- package/generators/library/templates/src/index.js +3 -0
- package/generators/library/templates/yarn.lock +4075 -0
- package/generators/npm/README.md +9 -0
- package/generators/npm/__tests__/Test.js +46 -0
- package/generators/npm/index.js +92 -0
- package/generators/npm/templates/README.md +15 -0
- package/generators/npm/templates/Test.js +10 -0
- package/generators/npm/templates/package.json +34 -0
- package/generators/npm/templates/src/index.js +5 -0
- package/generators/npm/templates/src/init.js +8 -0
- package/generators/npm/templates/yarn.lock +4026 -0
- package/package.json +7 -3
- package/generators/app/templates/.gitignore +0 -8
- package/generators/app/templates/ui/pages/Atoms.jsx +0 -8
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://yeoman.io/authoring/testing.html
|
|
3
|
+
* https://gilsondev.gitbooks.io/yeoman-authoring/content/authoring/unit_testing.html
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/yeoman/yeoman-assert/blob/main/index.js
|
|
6
|
+
* https://github.com/yeoman/yeoman-test/blob/main/lib/run-context.js
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const getYoUnit = require("yo-unit");
|
|
10
|
+
const { YoTest, assert } = getYoUnit();
|
|
11
|
+
|
|
12
|
+
describe("!! <%= mainName %> !!", () => {
|
|
13
|
+
let runResult;
|
|
14
|
+
|
|
15
|
+
before(async () => {
|
|
16
|
+
runResult = await YoTest({
|
|
17
|
+
source: __dirname + "/../.",
|
|
18
|
+
params: {
|
|
19
|
+
isReady: true,
|
|
20
|
+
appNamee: "foo",
|
|
21
|
+
description: "foo-desc",
|
|
22
|
+
keyword: "foo-keyword",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
after(() => {
|
|
28
|
+
if (runResult) {
|
|
29
|
+
runResult.restore();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should have folder", () => {
|
|
34
|
+
// assert.file(["src", "ui"]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should have file", () => {
|
|
38
|
+
// assert.file(["compile.sh", "index.html"]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should have content", () => {
|
|
42
|
+
// assert.fileContent('composer.json', 'foo-desc');
|
|
43
|
+
// assert.fileContent('.circleci/config.yml', 'foo');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const getYo = require("yo-reshow");
|
|
2
|
+
const { YoGenerator, YoHelper, commonPrompt } = getYo();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <%= mainName %> Generator
|
|
6
|
+
*/
|
|
7
|
+
module.exports = class extends YoGenerator {
|
|
8
|
+
/**
|
|
9
|
+
* Run loop (Life cycle)
|
|
10
|
+
* https://yeoman.io/authoring/running-context.html#the-run-loop
|
|
11
|
+
*
|
|
12
|
+
* 1. initializing
|
|
13
|
+
* 2. prompting
|
|
14
|
+
* 3. configuring
|
|
15
|
+
* 4. default
|
|
16
|
+
* 5. writing
|
|
17
|
+
* 6. conflicts
|
|
18
|
+
* 7. install
|
|
19
|
+
* 8. end
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Questions.
|
|
24
|
+
*
|
|
25
|
+
* https://www.alwaystwisted.com/post.php?s=using-lists-in-a-yeoman-generator
|
|
26
|
+
* https://github.com/SBoudrias/Inquirer.js
|
|
27
|
+
*/
|
|
28
|
+
async prompting() {
|
|
29
|
+
const {
|
|
30
|
+
say,
|
|
31
|
+
handleAnswers,
|
|
32
|
+
mergePromptOrOption,
|
|
33
|
+
promptChainLocator,
|
|
34
|
+
promptChain,
|
|
35
|
+
} = YoHelper(this);
|
|
36
|
+
|
|
37
|
+
const prompts = [
|
|
38
|
+
...commonPrompt.mainName(this),
|
|
39
|
+
...commonPrompt.desc(this),
|
|
40
|
+
/*
|
|
41
|
+
{
|
|
42
|
+
type: "input",
|
|
43
|
+
name: "xxx",
|
|
44
|
+
message: "Please input xxx?",
|
|
45
|
+
default: "",
|
|
46
|
+
},
|
|
47
|
+
*/
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const answers = await mergePromptOrOption(prompts, (nextPrompts) =>
|
|
51
|
+
promptChain(promptChainLocator(nextPrompts))
|
|
52
|
+
);
|
|
53
|
+
handleAnswers(answers, payload => { say(payload) });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
writing() {
|
|
57
|
+
this.env.options.nodePackageManager = "yarn";
|
|
58
|
+
const { cp, chMainName } = YoHelper(this);
|
|
59
|
+
|
|
60
|
+
// handle change to new folder
|
|
61
|
+
chMainName(this.mainName);
|
|
62
|
+
|
|
63
|
+
// handle copy file
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://yeoman.io/authoring/testing.html
|
|
3
|
+
* https://gilsondev.gitbooks.io/yeoman-authoring/content/authoring/unit_testing.html
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/yeoman/yeoman-assert/blob/main/index.js
|
|
6
|
+
* https://github.com/yeoman/yeoman-test/blob/main/lib/run-context.js
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const getYoUnit = require("yo-unit");
|
|
10
|
+
const { YoTest, assert } = getYoUnit();
|
|
11
|
+
|
|
12
|
+
describe("!! library !!", () => {
|
|
13
|
+
let runResult;
|
|
14
|
+
|
|
15
|
+
before(async () => {
|
|
16
|
+
runResult = await YoTest({
|
|
17
|
+
source: __dirname + "/../.",
|
|
18
|
+
params: {
|
|
19
|
+
isReady: true,
|
|
20
|
+
appNamee: "foo",
|
|
21
|
+
description: "foo-desc",
|
|
22
|
+
keyword: "foo-keyword",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
after(() => {
|
|
28
|
+
if (runResult) {
|
|
29
|
+
runResult.restore();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should have folder", () => {
|
|
34
|
+
// assert.file(["src", "ui"]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should have file", () => {
|
|
38
|
+
// assert.file(["compile.sh", "index.html"]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should have content", () => {
|
|
42
|
+
// assert.fileContent('composer.json', 'foo-desc');
|
|
43
|
+
// assert.fileContent('.circleci/config.yml', 'foo');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const getYo = require("yo-reshow");
|
|
2
|
+
const { YoGenerator, YoHelper, commonPrompt } = getYo();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Library Generator
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports = class extends YoGenerator {
|
|
9
|
+
constructor(args, opts) {
|
|
10
|
+
super(args, opts);
|
|
11
|
+
this.argument("mainName", { type: String, required: false });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Run loop (Life cycle)
|
|
16
|
+
* https://yeoman.io/authoring/running-context.html#the-run-loop
|
|
17
|
+
*
|
|
18
|
+
* 1. initializing
|
|
19
|
+
* 2. prompting
|
|
20
|
+
* 3. configuring
|
|
21
|
+
* 4. default
|
|
22
|
+
* 5. writing
|
|
23
|
+
* 6. conflicts
|
|
24
|
+
* 7. install
|
|
25
|
+
* 8. end
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Questions.
|
|
30
|
+
*
|
|
31
|
+
* https://www.alwaystwisted.com/post.php?s=using-lists-in-a-yeoman-generator
|
|
32
|
+
* https://github.com/SBoudrias/Inquirer.js
|
|
33
|
+
*/
|
|
34
|
+
async prompting() {
|
|
35
|
+
this.env.options.nodePackageManager = "yarn";
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
mergePromptOrOption,
|
|
39
|
+
promptChainLocator,
|
|
40
|
+
promptChain,
|
|
41
|
+
} = YoHelper(this);
|
|
42
|
+
|
|
43
|
+
const prompts = [
|
|
44
|
+
...commonPrompt.mainName(this),
|
|
45
|
+
...commonPrompt.desc(this),
|
|
46
|
+
...commonPrompt.author(this),
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const answers = await mergePromptOrOption(
|
|
50
|
+
prompts,
|
|
51
|
+
(nextPrompts) => promptChain(promptChainLocator(nextPrompts))
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
this.mainName = answers.mainName;
|
|
55
|
+
this.payload = {
|
|
56
|
+
...answers,
|
|
57
|
+
mainName: this.mainName,
|
|
58
|
+
description: answers.description || 'TODO: description',
|
|
59
|
+
keyword: answers.keyword || this.mainName,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
writing() {
|
|
64
|
+
const { cp, chMainName } = YoHelper(this);
|
|
65
|
+
|
|
66
|
+
// handle change to new folder
|
|
67
|
+
chMainName(this.mainName);
|
|
68
|
+
|
|
69
|
+
// handle copy file
|
|
70
|
+
cp("README.md", null, this.payload);
|
|
71
|
+
cp("compile.sh", null, this.payload);
|
|
72
|
+
cp("package.json", null, this.payload);
|
|
73
|
+
cp("src", null, this.payload);
|
|
74
|
+
cp("Test.js", "src/__tests__/Test.js", this.payload);
|
|
75
|
+
cp("yarn.lock");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
end() {
|
|
79
|
+
if (!this.options?.skipInstall) {
|
|
80
|
+
const { say, onExit } = YoHelper(this);
|
|
81
|
+
onExit(()=>say('Next you could try "npm run build" or "npm run test"'));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `<%= mainName %>`
|
|
2
|
+
|
|
3
|
+
> <%= description %>
|
|
4
|
+
|
|
5
|
+
## Repositories
|
|
6
|
+
* GIT
|
|
7
|
+
* https://github.com/react-atomic/react-atomic-organism/tree/main/packages/lib/<%= mainName %>
|
|
8
|
+
* NPM
|
|
9
|
+
* https://www.npmjs.com/package/<%= mainName %>
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= mainName %>",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "https://github.com/react-atomic/react-atomic-organism",
|
|
6
|
+
"directory": "packages/lib/<%= mainName %>"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://github.com/react-atomic/react-atomic-organism/tree/main/packages/lib/<%= mainName %>",
|
|
9
|
+
"description": "<%= description %>",
|
|
10
|
+
"version": "0.0.0",
|
|
11
|
+
"main": "./build/cjs/src/index.js",
|
|
12
|
+
"module": "./build/es/src/index.js",
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "<%= authorName %> <<%= authorEmail %>>",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"reshow-constant": "*"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@babel/cli": "^7.x",
|
|
21
|
+
"reshow-unit": "*"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"clean": "find ./build -name '*.*' | xargs rm -rf",
|
|
25
|
+
"build:cjs": "BABEL_ENV=cjs babel src -d build/cjs/src --root-mode upward",
|
|
26
|
+
"build:es": "BABEL_ENV=es babel src -d build/es/src --root-mode upward",
|
|
27
|
+
"build": "npm run clean && npm run build:cjs && npm run build:es",
|
|
28
|
+
"mochaFor": "mocha -r jsdom-global/register",
|
|
29
|
+
"mocha": "npm run mochaFor -- 'build/cjs/**/__tests__/*.js'",
|
|
30
|
+
"test": "npm run build && npm run mocha",
|
|
31
|
+
"prepublishOnly": "npm run test"
|
|
32
|
+
},
|
|
33
|
+
"files": ["build", "package.json", "README.md"]
|
|
34
|
+
}
|