create-umi 0.27.0 → 4.0.0-beta.14

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 (103) hide show
  1. package/README.md +2 -89
  2. package/bin/create-umi.js +3 -0
  3. package/dist/cli.d.ts +1 -0
  4. package/dist/cli.js +31 -0
  5. package/dist/index.d.ts +6 -0
  6. package/dist/index.js +105 -0
  7. package/package.json +18 -40
  8. package/templates/app/.gitignore.tpl +8 -0
  9. package/templates/app/.npmrc.tpl +1 -0
  10. package/templates/app/.umirc.ts.tpl +3 -0
  11. package/templates/app/layouts/index.tsx +22 -0
  12. package/templates/app/package.json.tpl +17 -0
  13. package/templates/app/pages/index.tsx +5 -0
  14. package/templates/app/pages/users/foo.tsx +3 -0
  15. package/templates/app/pages/users.tsx +9 -0
  16. package/templates/plugin/.fatherrc.ts +5 -0
  17. package/templates/plugin/.gitignore.tpl +2 -0
  18. package/templates/plugin/.npmrc.tpl +1 -0
  19. package/templates/plugin/README.md.tpl +38 -0
  20. package/templates/plugin/package.json.tpl +24 -0
  21. package/templates/plugin/src/index.ts.tpl +5 -0
  22. package/CHANGELOG.md +0 -44
  23. package/cli.js +0 -37
  24. package/index.js +0 -3
  25. package/lib/BasicGenerator.js +0 -70
  26. package/lib/generators/ant-design-pro/.babelrc +0 -10
  27. package/lib/generators/ant-design-pro/README.md +0 -57
  28. package/lib/generators/ant-design-pro/filterPkg.js +0 -15
  29. package/lib/generators/ant-design-pro/index.js +0 -183
  30. package/lib/generators/ant-design-pro/meta.json +0 -3
  31. package/lib/generators/app/index.js +0 -69
  32. package/lib/generators/app/meta.json +0 -3
  33. package/lib/generators/app/templates/.editorconfig +0 -16
  34. package/lib/generators/app/templates/.env +0 -2
  35. package/lib/generators/app/templates/.eslintrc +0 -3
  36. package/lib/generators/app/templates/.prettierignore +0 -7
  37. package/lib/generators/app/templates/.prettierrc +0 -11
  38. package/lib/generators/app/templates/.umirc.js +0 -37
  39. package/lib/generators/app/templates/.umirc.ts +0 -40
  40. package/lib/generators/app/templates/_gitignore +0 -18
  41. package/lib/generators/app/templates/mock/.gitkeep +0 -0
  42. package/lib/generators/app/templates/package.json +0 -60
  43. package/lib/generators/app/templates/src/app.js +0 -8
  44. package/lib/generators/app/templates/src/app.ts +0 -8
  45. package/lib/generators/app/templates/src/assets/welcomeImgs/0.jpg +0 -0
  46. package/lib/generators/app/templates/src/assets/welcomeImgs/1.jpg +0 -0
  47. package/lib/generators/app/templates/src/global.css +0 -7
  48. package/lib/generators/app/templates/src/layouts/__tests__/index.test.js +0 -14
  49. package/lib/generators/app/templates/src/layouts/__tests__/index.test.tsx +0 -16
  50. package/lib/generators/app/templates/src/layouts/index.css +0 -15
  51. package/lib/generators/app/templates/src/layouts/index.js +0 -12
  52. package/lib/generators/app/templates/src/layouts/index.tsx +0 -13
  53. package/lib/generators/app/templates/src/locales/en-US.js +0 -3
  54. package/lib/generators/app/templates/src/locales/en-US.ts +0 -3
  55. package/lib/generators/app/templates/src/models/.gitkeep +0 -0
  56. package/lib/generators/app/templates/src/pages/__tests__/__mocks__/umi-plugin-locale.js +0 -1
  57. package/lib/generators/app/templates/src/pages/__tests__/__mocks__/umi-plugin-locale.ts +0 -1
  58. package/lib/generators/app/templates/src/pages/__tests__/index.test.js +0 -19
  59. package/lib/generators/app/templates/src/pages/__tests__/index.test.tsx +0 -21
  60. package/lib/generators/app/templates/src/pages/index.css +0 -23
  61. package/lib/generators/app/templates/src/pages/index.js +0 -18
  62. package/lib/generators/app/templates/src/pages/index.tsx +0 -19
  63. package/lib/generators/app/templates/tsconfig.json +0 -18
  64. package/lib/generators/app/templates/typings.d.ts +0 -2
  65. package/lib/generators/app/templates/webpack.config.js +0 -12
  66. package/lib/generators/plugin/index.js +0 -81
  67. package/lib/generators/plugin/meta.json +0 -3
  68. package/lib/generators/plugin/templates/.editorconfig +0 -16
  69. package/lib/generators/plugin/templates/.fatherrc.js +0 -35
  70. package/lib/generators/plugin/templates/.fatherrc.ts +0 -35
  71. package/lib/generators/plugin/templates/.gitignore +0 -8
  72. package/lib/generators/plugin/templates/.prettierignore +0 -8
  73. package/lib/generators/plugin/templates/.prettierrc +0 -14
  74. package/lib/generators/plugin/templates/CONTRIBUTING.md +0 -40
  75. package/lib/generators/plugin/templates/README.md +0 -51
  76. package/lib/generators/plugin/templates/example/.gitignore +0 -5
  77. package/lib/generators/plugin/templates/example/.umirc.js +0 -8
  78. package/lib/generators/plugin/templates/example/.umirc.ts +0 -8
  79. package/lib/generators/plugin/templates/example/app.jsx +0 -3
  80. package/lib/generators/plugin/templates/example/app.tsx +0 -3
  81. package/lib/generators/plugin/templates/example/package.json +0 -3
  82. package/lib/generators/plugin/templates/example/pages/index.css +0 -17
  83. package/lib/generators/plugin/templates/example/pages/index.jsx +0 -8
  84. package/lib/generators/plugin/templates/example/pages/index.tsx +0 -8
  85. package/lib/generators/plugin/templates/example/tsconfig.json +0 -37
  86. package/lib/generators/plugin/templates/example/typing.d.ts +0 -2
  87. package/lib/generators/plugin/templates/jest.config.js +0 -8
  88. package/lib/generators/plugin/templates/package.json +0 -66
  89. package/lib/generators/plugin/templates/src/index.js +0 -26
  90. package/lib/generators/plugin/templates/src/index.ts +0 -29
  91. package/lib/generators/plugin/templates/test/fixtures/normal/.umirc.js +0 -4
  92. package/lib/generators/plugin/templates/test/fixtures/normal/.umirc.ts +0 -4
  93. package/lib/generators/plugin/templates/test/fixtures/normal/pages/index.css +0 -4
  94. package/lib/generators/plugin/templates/test/fixtures/normal/pages/index.jsx +0 -10
  95. package/lib/generators/plugin/templates/test/fixtures/normal/pages/index.tsx +0 -11
  96. package/lib/generators/plugin/templates/test/fixtures/normal/test.js +0 -10
  97. package/lib/generators/plugin/templates/test/fixtures/normal/test.ts +0 -10
  98. package/lib/generators/plugin/templates/test/index.e2e.js +0 -5
  99. package/lib/generators/plugin/templates/test/index.e2e.ts +0 -5
  100. package/lib/generators/plugin/templates/tsconfig.json +0 -23
  101. package/lib/generators/plugin/templates/ui/index.jsx +0 -28
  102. package/lib/generators/plugin/templates/ui/index.tsx +0 -29
  103. package/lib/run.js +0 -76
@@ -1,29 +0,0 @@
1
- // ref:
2
- // - https://umijs.org/plugins/api
3
- <% if (withUmiUI) { -%>
4
- import { join } from 'path';
5
- <% } -%>
6
- import { IApi } from '@umijs/types';
7
-
8
- export default function (api: IApi) {
9
- api.logger.info('use plugin');
10
-
11
- api.modifyHTML(($) => {
12
- $('body').prepend(`<h1>hello umi plugin</h1>`);
13
- return $;
14
- });
15
-
16
- <% if (withUmiUI) { -%>
17
- // @ts-ignore
18
- api.addUIPlugin(() => join(__dirname, '../dist/index.umd.js'));
19
-
20
- // @ts-ignore
21
- api.onUISocket(({ action, failure, success }) => {
22
- if (action.type === 'org.xiaohuoni.demo.test') {
23
- success({
24
- data: 'demo.test',
25
- });
26
- }
27
- });
28
- <% } -%>
29
- }
@@ -1,4 +0,0 @@
1
-
2
- export default {
3
- plugins: [require.resolve('../../../lib')]
4
- }
@@ -1,4 +0,0 @@
1
-
2
- export default {
3
- plugins: [require.resolve('../../../lib')]
4
- }
@@ -1,4 +0,0 @@
1
-
2
- .normal {
3
- background: #7F79F2;
4
- }
@@ -1,10 +0,0 @@
1
-
2
- import styles from './index.css';
3
-
4
- export default function() {
5
- return (
6
- <div className={styles.normal}>
7
- <h1>hello umi plugin</h1>
8
- </div>
9
- );
10
- }
@@ -1,11 +0,0 @@
1
-
2
- import React from 'react';
3
- import styles from './index.css';
4
-
5
- export default function() {
6
- return (
7
- <div className={styles.normal}>
8
- <h1>hello umi plugin</h1>
9
- </div>
10
- );
11
- }
@@ -1,10 +0,0 @@
1
-
2
- export default async function ({ page, host }) {
3
- await page.goto(`${host}/`, {
4
- waitUntil: 'networkidle2',
5
- });
6
- const text = await page.evaluate(
7
- () => document.querySelector('h1').innerHTML,
8
- );
9
- expect(text).toEqual('hello umi plugin');
10
- };
@@ -1,10 +0,0 @@
1
-
2
- export default async function ({ page, host }) {
3
- await page.goto(`${host}/`, {
4
- waitUntil: 'networkidle2',
5
- });
6
- const text = await page.evaluate(
7
- () => document.querySelector('h1').innerHTML,
8
- );
9
- expect(text).toEqual('hello umi plugin');
10
- };
@@ -1,5 +0,0 @@
1
- const { join } = require('path');
2
-
3
- require('test-umi-plugin')({
4
- fixtures: join(__dirname, 'fixtures'),
5
- });
@@ -1,5 +0,0 @@
1
- const { join } = require('path');
2
-
3
- require('test-umi-plugin')({
4
- fixtures: join(__dirname, 'fixtures'),
5
- });
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "moduleResolution": "node",
5
- "jsx": "preserve",
6
- "allowJs": true,
7
- "esModuleInterop": true,
8
- "experimentalDecorators": true,
9
- "strict": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "noImplicitReturns": true,
12
- "suppressImplicitAnyIndexErrors": true,
13
- "declaration": true
14
- },
15
- "exclude": [
16
- "node_modules",
17
- "dist",
18
- "**/*.spec.ts",
19
- "lib",
20
- "fixtures",
21
- "examples"
22
- ]
23
- }
@@ -1,28 +0,0 @@
1
- import { Button } from 'antd';
2
-
3
- export default (api) => {
4
- const { callRemote } = api;
5
-
6
- function PluginPanel() {
7
- return (
8
- <div style={{ padding: 20 }}>
9
- <Button
10
- type="primary"
11
- onClick={async () => {
12
- const { data } = await callRemote({
13
- type: 'org.xiaohuoni.demo.test',
14
- });
15
- alert(data);
16
- }}
17
- >Test</Button>
18
- </div>
19
- );
20
- }
21
-
22
- api.addPanel({
23
- title: 'demo',
24
- path: '/demo',
25
- icon: 'home',
26
- component: PluginPanel,
27
- });
28
- }
@@ -1,29 +0,0 @@
1
- import { Button } from 'antd';
2
- import { IUiApi } from '@umijs/ui-types';
3
-
4
- export default (api: IUiApi) => {
5
- const { callRemote } = api;
6
-
7
- function PluginPanel() {
8
- return (
9
- <div style={{ padding: 20 }}>
10
- <Button
11
- type="primary"
12
- onClick={async () => {
13
- const { data } = await callRemote({
14
- type: 'org.xiaohuoni.demo.test',
15
- });
16
- alert(data);
17
- }}
18
- >Test</Button>
19
- </div>
20
- );
21
- }
22
-
23
- api.addPanel({
24
- title: 'demo',
25
- path: '/demo',
26
- icon: 'home',
27
- component: PluginPanel,
28
- });
29
- }
package/lib/run.js DELETED
@@ -1,76 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const chalk = require('chalk');
4
- const mkdirp = require('mkdirp');
5
- const inquirer = require('inquirer');
6
- const clipboardy = require('clipboardy');
7
- const yeoman = require('yeoman-environment');
8
-
9
- const generators = fs
10
- .readdirSync(`${__dirname}/generators`)
11
- .filter(f => !f.startsWith('.'))
12
- .map(f => {
13
- return {
14
- name: `${f.padEnd(15)} - ${chalk.gray(require(`./generators/${f}/meta.json`).description)}`,
15
- value: f,
16
- short: f,
17
- };
18
- });
19
-
20
- const runGenerator = async (generatorPath, { name = '', cwd = process.cwd(), args = {} }) => {
21
- return new Promise(resolve => {
22
- if (name) {
23
- mkdirp.sync(name);
24
- cwd = path.join(cwd, name);
25
- }
26
-
27
- const Generator = require(generatorPath);
28
- const env = yeoman.createEnv([], {
29
- cwd,
30
- });
31
- const generator = new Generator({
32
- name,
33
- env,
34
- resolved: require.resolve(generatorPath),
35
- args,
36
- });
37
-
38
- return generator.run(() => {
39
- if (name) {
40
- if (process.platform !== `linux` || process.env.DISPLAY) {
41
- clipboardy.writeSync(`cd ${name}`);
42
- console.log('📋 Copied to clipboard, just use Ctrl+V');
43
- }
44
- }
45
- console.log('✨ File Generate Done');
46
- resolve(true);
47
- });
48
- });
49
- };
50
-
51
- const run = async config => {
52
- process.send && process.send({ type: 'prompt' });
53
- process.emit('message', { type: 'prompt' });
54
-
55
- let { type } = config;
56
- if (!type) {
57
- const answers = await inquirer.prompt([
58
- {
59
- name: 'type',
60
- message: 'Select the boilerplate type',
61
- type: 'list',
62
- choices: generators,
63
- },
64
- ]);
65
- type = answers.type;
66
- }
67
-
68
- try {
69
- return runGenerator(`./generators/${type}`, config);
70
- } catch (e) {
71
- console.error(chalk.red(`> Generate failed`), e);
72
- process.exit(1);
73
- }
74
- };
75
-
76
- module.exports = run;