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.
Files changed (44) hide show
  1. package/README.md +4 -4
  2. package/generators/app/README.md +4 -0
  3. package/generators/app/__tests__/TestApp.js +15 -4
  4. package/generators/app/index.js +32 -45
  5. package/generators/app/templates/README.md +9 -0
  6. package/generators/app/templates/data/env +1 -0
  7. package/generators/app/templates/package.json +7 -9
  8. package/generators/app/templates/screen.sh +34 -0
  9. package/generators/app/templates/ui/pages/Page1.jsx +8 -0
  10. package/generators/app/templates/ui/pages/Page2.jsx +8 -0
  11. package/generators/app/templates/ui/pages/index.jsx +5 -3
  12. package/generators/app/templates/ui/templates/Doc.jsx +1 -1
  13. package/generators/compile-sh/README.md +8 -0
  14. package/generators/compile-sh/__tests__/Test.js +45 -0
  15. package/generators/compile-sh/index.js +12 -0
  16. package/generators/{app → compile-sh}/templates/compile.sh +47 -10
  17. package/generators/generator/README.md +9 -0
  18. package/generators/generator/__tests__/TestGenerator.js +44 -0
  19. package/generators/generator/index.js +31 -51
  20. package/generators/generator/templates/README.md +9 -0
  21. package/generators/generator/templates/Test.js +45 -0
  22. package/generators/generator/templates/index.js +65 -0
  23. package/generators/generator/templates/templates/README.md +9 -0
  24. package/generators/library/README.md +9 -0
  25. package/generators/library/__tests__/Test.js +45 -0
  26. package/generators/library/index.js +84 -0
  27. package/generators/library/templates/README.md +15 -0
  28. package/generators/library/templates/Test.js +10 -0
  29. package/generators/library/templates/compile.sh +3 -0
  30. package/generators/library/templates/package.json +34 -0
  31. package/generators/library/templates/src/index.js +3 -0
  32. package/generators/library/templates/yarn.lock +4075 -0
  33. package/generators/npm/README.md +9 -0
  34. package/generators/npm/__tests__/Test.js +46 -0
  35. package/generators/npm/index.js +92 -0
  36. package/generators/npm/templates/README.md +15 -0
  37. package/generators/npm/templates/Test.js +10 -0
  38. package/generators/npm/templates/package.json +34 -0
  39. package/generators/npm/templates/src/index.js +5 -0
  40. package/generators/npm/templates/src/init.js +8 -0
  41. package/generators/npm/templates/yarn.lock +4026 -0
  42. package/package.json +7 -3
  43. package/generators/app/templates/.gitignore +0 -8
  44. package/generators/app/templates/ui/pages/Atoms.jsx +0 -8
@@ -0,0 +1,9 @@
1
+ # `npm`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ npx yonpx reshow:npm
9
+ ```
@@ -0,0 +1,46 @@
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("!! npm !!", () => {
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
+ const {generator} = runResult;
43
+ // assert.fileContent('composer.json', 'foo-desc');
44
+ // assert.fileContent('.circleci/config.yml', 'foo');
45
+ });
46
+ });
@@ -0,0 +1,92 @@
1
+ const getYo = require("yo-reshow");
2
+ const { YoGenerator, YoHelper, commonPrompt } = getYo();
3
+
4
+ /**
5
+ * NPM Generator
6
+ */
7
+
8
+ module.exports = class extends YoGenerator {
9
+ /**
10
+ * Run loop (Life cycle)
11
+ * https://yeoman.io/authoring/running-context.html#the-run-loop
12
+ *
13
+ * 1. initializing
14
+ * 2. prompting
15
+ * 3. configuring
16
+ * 4. default
17
+ * 5. writing
18
+ * 6. conflicts
19
+ * 7. install
20
+ * 8. end
21
+ */
22
+
23
+ /**
24
+ * Questions.
25
+ *
26
+ * https://www.alwaystwisted.com/post.php?s=using-lists-in-a-yeoman-generator
27
+ * https://github.com/SBoudrias/Inquirer.js
28
+ */
29
+ async prompting() {
30
+ const {
31
+ handleAnswers,
32
+ mergePromptOrOption,
33
+ promptChainLocator,
34
+ promptChain,
35
+ } = YoHelper(this);
36
+
37
+ const prompts = [
38
+ ...commonPrompt.mainName(this),
39
+ ...commonPrompt.babel(this),
40
+ ...commonPrompt.desc(this),
41
+ ...commonPrompt.author(this),
42
+ ...commonPrompt.repository(this),
43
+ ];
44
+
45
+ const answers = await mergePromptOrOption(prompts, (nextPrompts) =>
46
+ promptChain(promptChainLocator(nextPrompts))
47
+ );
48
+ handleAnswers(answers, (payload) => {
49
+ if (payload.isUseBabel) {
50
+ this.composeWith(require.resolve("../compile-sh"), payload);
51
+ }
52
+ });
53
+ }
54
+
55
+ writing() {
56
+ this.env.options.nodePackageManager = "yarn";
57
+ const { cp, chMainName, updateJSON } = YoHelper(this);
58
+
59
+ // handle change to new folder
60
+ chMainName(this.mainName);
61
+
62
+ // handle copy file
63
+ cp("src", null, this.payload);
64
+ cp("README.md", null, this.payload);
65
+ cp("Test.js", "src/__tests__/Test.js", this.payload);
66
+ cp("yarn.lock");
67
+
68
+ updateJSON("package.json", null, this.payload, (data) => {
69
+ data.repository = this.payload.repository;
70
+ data.homepage = this.payload.repositoryHomepage;
71
+ data.dependencies = {
72
+ ...data.dependencies,
73
+ ...this.payload.npmDependencies,
74
+ };
75
+ if (!this.payload.isUseBabel) {
76
+ delete data.devDependencies["@babel/cli"];
77
+ delete data.module;
78
+ delete data.scripts.clean;
79
+ delete data.scripts.build;
80
+ delete data.scripts["build:cjs"];
81
+ delete data.scripts["build:es"];
82
+ data.main = "./src/index.js";
83
+ data.bin[this.mainName] = "./src/index.js";
84
+ data.scripts.test = "npm run mocha";
85
+ data.scripts.mocha = "npm run mochaFor -- 'src/**/__tests__/*.js'";
86
+ data.files = data.files.filter((f) => f !== "build");
87
+ data.files.push("src");
88
+ }
89
+ return data;
90
+ });
91
+ }
92
+ };
@@ -0,0 +1,15 @@
1
+ # `<%= mainName %>`
2
+
3
+ > <%= description %>
4
+
5
+ ## Repository
6
+ * `GIT`
7
+ * <% repositoryHomepage %>
8
+ * `NPM`
9
+ * https://www.npmjs.com/package/<%= mainName %>
10
+
11
+ ## Usage
12
+
13
+ ```
14
+
15
+ ```
@@ -0,0 +1,10 @@
1
+ const {expect} = require("chai");
2
+ const {init} = require("../init");
3
+
4
+ describe("Test <%= mainName %>", () => {
5
+ it("basic testt", () => {
6
+ /*your test code*/
7
+ const actual = init();
8
+ expect(actual).to.equal('bar');
9
+ });
10
+ });
@@ -0,0 +1,34 @@
1
+ {
2
+ "version": "0.0.0",
3
+ "name": "<%= mainName %>",
4
+ "repository": {},
5
+ "homepage": "",
6
+ "description": "<%= description %>",
7
+ "keywords": [],
8
+ "author": "<%= authorName %> <<%= authorEmail %>>",
9
+ "license": "ISC",
10
+ "dependencies": {
11
+ "reshow-constant": "*"
12
+ },
13
+ "devDependencies": {
14
+ "@babel/cli": "^7.x",
15
+ "reshow-unit": "*"
16
+ },
17
+ "main": "./build/cjs/src/index.js",
18
+ "module": "./build/es/src/index.js",
19
+ "bin": {
20
+ "<%= mainName %>": "./build/cjs/src/index.js"
21
+ },
22
+ "scripts": {
23
+ "clean": "find ./build -name '*.*' | xargs rm -rf",
24
+ "build:cjs": "BABEL_ENV=cjs babel src -d build/cjs/src<%= babelRootMode %>",
25
+ "build:es": "BABEL_ENV=es babel src -d build/es/src<%= babelRootMode %>",
26
+ "build": "npm run clean && npm run build:cjs && npm run build:es",
27
+ "mochaFor": "mocha -r jsdom-global/register",
28
+ "mocha": "npm run mochaFor -- 'build/cjs/**/__tests__/*.js'",
29
+ "test": "npm run build && npm run mocha",
30
+ "prepublishOnly": "npm run test"
31
+ },
32
+ "files": ["build", "package.json", "README.md"],
33
+ "engines": { "node": ">=14" }
34
+ }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { init } = require("./init");
4
+
5
+ init();
@@ -0,0 +1,8 @@
1
+ const init = (props) => {
2
+ console.log("foo");
3
+ return "bar";
4
+ };
5
+
6
+ module.exports = {
7
+ init,
8
+ };