@grafana/create-plugin 0.0.1

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 (105) hide show
  1. package/.eslintrc +6 -0
  2. package/.github/workflows/create-release.yml +49 -0
  3. package/.github/workflows/npm-bump-version.yml +51 -0
  4. package/.github/workflows/test.yml +31 -0
  5. package/.prettierrc +10 -0
  6. package/CONTRIBUTING.md +42 -0
  7. package/README.md +143 -0
  8. package/dist/bin/run.js +17 -0
  9. package/dist/commands/generate.command.js +56 -0
  10. package/dist/commands/generate.plopfile.js +119 -0
  11. package/dist/commands/index.js +19 -0
  12. package/dist/commands/migrate.command.js +133 -0
  13. package/dist/commands/update.command.js +101 -0
  14. package/dist/constants.js +74 -0
  15. package/dist/utils/tests/utils.files.test.js +30 -0
  16. package/dist/utils/tests/utils.handlebars.test.js +26 -0
  17. package/dist/utils/tests/utils.npm.test.js +138 -0
  18. package/dist/utils/tests/utils.plugin.test.js +20 -0
  19. package/dist/utils/tests/utils.templates.test.js +32 -0
  20. package/dist/utils/utils.console.js +41 -0
  21. package/dist/utils/utils.files.js +61 -0
  22. package/dist/utils/utils.handlebars.js +73 -0
  23. package/dist/utils/utils.npm.js +162 -0
  24. package/dist/utils/utils.plugin.js +14 -0
  25. package/dist/utils/utils.templates.js +77 -0
  26. package/docs/example.mp4 +0 -0
  27. package/jest.config.js +20 -0
  28. package/package.json +69 -0
  29. package/src/bin/run.ts +15 -0
  30. package/src/commands/generate.command.ts +15 -0
  31. package/src/commands/generate.plopfile.ts +151 -0
  32. package/src/commands/index.ts +3 -0
  33. package/src/commands/migrate.command.ts +99 -0
  34. package/src/commands/update.command.ts +66 -0
  35. package/src/constants.ts +99 -0
  36. package/src/utils/tests/utils.files.test.ts +41 -0
  37. package/src/utils/tests/utils.handlebars.test.ts +35 -0
  38. package/src/utils/tests/utils.npm.test.ts +193 -0
  39. package/src/utils/tests/utils.plugin.test.ts +22 -0
  40. package/src/utils/tests/utils.templates.test.ts +44 -0
  41. package/src/utils/utils.console.ts +41 -0
  42. package/src/utils/utils.files.ts +65 -0
  43. package/src/utils/utils.handlebars.ts +47 -0
  44. package/src/utils/utils.npm.ts +189 -0
  45. package/src/utils/utils.plugin.ts +9 -0
  46. package/src/utils/utils.templates.ts +76 -0
  47. package/templates/_partials/backend-getting-started.md +20 -0
  48. package/templates/_partials/frontend-getting-started.md +59 -0
  49. package/templates/app/README.md +20 -0
  50. package/templates/app/src/components/App/App.test.tsx +32 -0
  51. package/templates/app/src/components/App/App.tsx +8 -0
  52. package/templates/app/src/components/App/index.tsx +1 -0
  53. package/templates/app/src/components/AppConfig/AppConfig.test.tsx +51 -0
  54. package/templates/app/src/components/AppConfig/AppConfig.tsx +92 -0
  55. package/templates/app/src/components/AppConfig/index.tsx +1 -0
  56. package/templates/app/src/module.ts +12 -0
  57. package/templates/app/src/plugin.json +33 -0
  58. package/templates/backend/Magefile.go +12 -0
  59. package/templates/backend/go.mod +5 -0
  60. package/templates/backend/go.sum +568 -0
  61. package/templates/backend/pkg/main.go +24 -0
  62. package/templates/backend/pkg/plugin/datasource.go +111 -0
  63. package/templates/backend/pkg/plugin/datasource_test.go +28 -0
  64. package/templates/common/.config/.eslintrc +12 -0
  65. package/templates/common/.config/.prettierrc.js +16 -0
  66. package/templates/common/.config/Dockerfile +15 -0
  67. package/templates/common/.config/README.md +115 -0
  68. package/templates/common/.config/jest-setup.js +24 -0
  69. package/templates/common/.config/jest.config.js +31 -0
  70. package/templates/common/.config/tsconfig.json +17 -0
  71. package/templates/common/.config/types/custom.d.ts +37 -0
  72. package/templates/common/.config/webpack/constants.ts +3 -0
  73. package/templates/common/.config/webpack/tsconfig.webpack.json +9 -0
  74. package/templates/common/.config/webpack/utils.ts +17 -0
  75. package/templates/common/.config/webpack/webpack.config.ts +187 -0
  76. package/templates/common/.eslintrc +3 -0
  77. package/templates/common/.nvmrc +1 -0
  78. package/templates/common/.prettierrc.js +4 -0
  79. package/templates/common/CHANGELOG.md +5 -0
  80. package/templates/common/LICENSE +201 -0
  81. package/templates/common/cypress/integration/01-smoke.spec.ts +10 -0
  82. package/templates/common/docker-compose.yaml +14 -0
  83. package/templates/common/jest-setup.js +2 -0
  84. package/templates/common/jest.config.js +4 -0
  85. package/templates/common/package.json +67 -0
  86. package/templates/common/src/README.md +5 -0
  87. package/templates/common/src/img/logo.svg +1 -0
  88. package/templates/common/tsconfig.json +3 -0
  89. package/templates/datasource/README.md +20 -0
  90. package/templates/datasource/src/components/ConfigEditor.tsx +83 -0
  91. package/templates/datasource/src/components/QueryEditor.tsx +50 -0
  92. package/templates/datasource/src/datasource.ts +46 -0
  93. package/templates/datasource/src/module.ts +9 -0
  94. package/templates/datasource/src/plugin.json +37 -0
  95. package/templates/datasource/src/types.ts +24 -0
  96. package/templates/github/ci/.github/workflows/ci.yml +76 -0
  97. package/templates/github/ci/.github/workflows/release.yml +165 -0
  98. package/templates/github/is-compatible/.github/workflows/is-compatible.yml +17 -0
  99. package/templates/panel/README.md +22 -0
  100. package/templates/panel/src/components/SimplePanel.tsx +62 -0
  101. package/templates/panel/src/module.test.ts +6 -0
  102. package/templates/panel/src/module.ts +40 -0
  103. package/templates/panel/src/plugin.json +33 -0
  104. package/templates/panel/src/types.ts +7 -0
  105. package/tsconfig.json +17 -0
package/.eslintrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": ["@grafana/eslint-config"],
3
+ "rules": {
4
+ "react/prop-types": "off"
5
+ }
6
+ }
@@ -0,0 +1,49 @@
1
+ on:
2
+ push:
3
+ tags:
4
+ - 'v*'
5
+
6
+ name: Create Release
7
+
8
+ jobs:
9
+ publish:
10
+ name: Publish to npm
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+
15
+ - name: Setup environment
16
+ uses: actions/setup-node@v2.5.1
17
+ with:
18
+ node-version: '16'
19
+ registry-url: 'https://registry.npmjs.org'
20
+ cache: 'yarn'
21
+
22
+ - name: Install dependencies
23
+ run: yarn install --immutable
24
+
25
+ - name: Build package
26
+ run: yarn build
27
+
28
+ - name: Publish
29
+ run: npm publish --access public
30
+ env:
31
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32
+
33
+ create-github-release:
34
+ name: Create GitHub Release
35
+ runs-on: ubuntu-latest
36
+ needs: publish
37
+ steps:
38
+ - name: Checkout code
39
+ uses: actions/checkout@v3
40
+
41
+ - name: Create Release Notes
42
+ uses: actions/github-script@v4.0.2
43
+ with:
44
+ github-token: ${{secrets.GH_TOKEN}}
45
+ script: |
46
+ await github.request(`POST /repos/${{ github.repository }}/releases`, {
47
+ tag_name: "${{ github.ref }}",
48
+ generate_release_notes: true
49
+ });
@@ -0,0 +1,51 @@
1
+ name: NPM bump version
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: 'Semver type of new version (major / minor / patch)'
8
+ required: true
9
+ type: choice
10
+ options:
11
+ - patch
12
+ - minor
13
+ - major
14
+
15
+ jobs:
16
+ bump-version:
17
+ runs-on: ubuntu-latest
18
+
19
+ steps:
20
+ - uses: actions/checkout@v3
21
+ with:
22
+ token: ${{ secrets.GH_BOT_ACCESS_TOKEN }}
23
+
24
+ - name: Setup environment
25
+ uses: actions/setup-node@v3.1.1
26
+ with:
27
+ node-version: '16'
28
+ cache: 'yarn'
29
+
30
+ - name: Install dependencies
31
+ run: yarn install --immutable
32
+
33
+ - name: Check types
34
+ run: yarn typecheck
35
+
36
+ - name: Lint
37
+ run: yarn lint
38
+
39
+ - name: Unit tests
40
+ run: yarn jest
41
+
42
+ - name: Setup Git
43
+ run: |
44
+ git config user.name 'grafanabot'
45
+ git config user.email 'bot@grafana.com'
46
+
47
+ - name: bump version
48
+ run: npm version ${{ github.event.inputs.version }}
49
+
50
+ - name: Push latest version
51
+ run: git push origin main --follow-tags
@@ -0,0 +1,31 @@
1
+ name: test
2
+ on: push
3
+
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ name: Run unit tests
8
+ steps:
9
+ - name: Checkout repository
10
+ uses: actions/checkout@v2
11
+ with:
12
+ ref: ${{ github.ref }}
13
+ - name: Setup .npmrc file for NPM registry
14
+ uses: actions/setup-node@v2
15
+ with:
16
+ node-version: '16'
17
+ registry-url: 'https://registry.npmjs.org'
18
+ - name: Install dependencies
19
+ run: yarn
20
+ - name: Check types
21
+ run: yarn typecheck
22
+ - name: Lint
23
+ run: yarn lint
24
+ - name: Unit tests
25
+ run: yarn jest
26
+ - name: test an app plugin generation
27
+ run: yarn generate-app && (cd generated && yarn && yarn build && yarn lint)
28
+ - name: test panel plugin generation
29
+ run: yarn generate-panel && (cd generated && yarn && yarn build && yarn lint)
30
+ - name: test datasource plugin generation
31
+ run: yarn generate-datasource && (cd generated && yarn && yarn build && yarn lint)
package/.prettierrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "endOfLine": "auto",
3
+ "printWidth": 120,
4
+ "trailingComma": "es5",
5
+ "semi": true,
6
+ "jsxSingleQuote": false,
7
+ "singleQuote": true,
8
+ "useTabs": false,
9
+ "tabWidth": 2
10
+ }
@@ -0,0 +1,42 @@
1
+ # Contributing to Grafana / Create Plugin
2
+
3
+ We are always grateful to receive contribution!<br />
4
+ The following guidelines help you on how to start with the codebase and how to submit your work.
5
+
6
+ ## Installation
7
+
8
+ ### Prerequisites
9
+
10
+ You need to have `npm` or `yarn` installed.
11
+
12
+ ### Installing
13
+
14
+ ```bash
15
+ git clone git@github.com:grafana/create-plugin.git
16
+ cd create-plugin
17
+ yarn install
18
+ ```
19
+
20
+ ## Overview
21
+
22
+ ### Technologies
23
+
24
+ - [**`Plop`**](https://github.com/plopjs/plop) - we are using Plop for the CLI tool and for scaffolding
25
+
26
+ ### Folder structure
27
+
28
+ _Work in progress._
29
+
30
+ ## Development
31
+
32
+ ### Conventions
33
+
34
+ _Work in progress._
35
+
36
+ ### Developing the templates
37
+
38
+ _Work in progress._
39
+
40
+ ### Submitting a Pull Request
41
+
42
+ _Work in progress._
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # Grafana / Create Plugin
2
+
3
+ Create Grafana plugins with ease.
4
+
5
+ **ToC**
6
+
7
+ - [Create a new plugin](#create-a-new-plugin)
8
+ - [Migrate your existing plugin](#migrate-your-existing-plugin)
9
+ - [Update your plugin build config](#update-your-plugin-build-config)
10
+ - [Start developing your plugin](#start-developing-your-plugin)
11
+ - [Contributing](#contributing)
12
+
13
+ **Links**
14
+
15
+ - [Plugin developer docs](https://grafana.com/docs/grafana/latest/developers/plugins/)
16
+ - [Plugin migration guide](https://grafana.com/docs/grafana/latest/developers/plugins/migration-guide/)
17
+
18
+ **`@grafana/create-plugin`** works on macOS, Windows and Linux.<br />
19
+ If something doesn’t work, please [file an issue](https://github.com/grafana/create-plugin/issues/new).<br />
20
+ If you have questions or need help, please ask in [GitHub Discussions](https://github.com/grafana/create-plugin/discussions).
21
+
22
+ ## Create a new plugin
23
+
24
+ ### Quick overview
25
+
26
+ The following commands scaffold a Grafana plugin inside the `./my-plugin` folder:
27
+
28
+ ```bash
29
+ mkdir my-plugin && cd my-plugin
30
+ yarn create @grafana/plugin
31
+ yarn install
32
+ yarn dev
33
+ ```
34
+
35
+ Alterntives:
36
+
37
+ #### [`npx`](https://github.com/npm/npx)
38
+
39
+ ```bash
40
+ npx @grafana/create-plugin
41
+ ```
42
+
43
+ #### [`npm`](https://docs.npmjs.com/cli/v7/commands/npm-init)
44
+
45
+ ```bash
46
+ npm init @grafana/plugin
47
+ ```
48
+
49
+ #### [`yarn`](https://classic.yarnpkg.com/blog/2017/05/12/introducing-yarn/) (1.x)
50
+
51
+ ```bash
52
+ yarn create @grafana/plugin
53
+ ```
54
+
55
+ #### [`yarn`](https://yarnpkg.com/cli/dlx) (> 2.x)
56
+
57
+ ```bash
58
+ yarn dlx @grafana/create-plugin
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Migrate your existing plugin
64
+
65
+ In case you have an existing plugin previously created using the `@grafana/toolkit` you can use the
66
+ following command to migrate it to the new build tooling:
67
+
68
+ ```bash
69
+ # Run this command from the root of your plugin
70
+ cd ./my-plugin
71
+
72
+ npx @grafana/create-plugin migrate
73
+ ```
74
+
75
+ ### Things to check after migration
76
+
77
+ - If you have a custom webpack configuration you might need to migrate it. You can read more about customizing or extending the basic configuration [here](templates/common/.config/README.md)
78
+ - Build your plugin. Run `yarn build` to check your plugin builds as intended.
79
+ - Test your plugin. Test your plugin inside grafana to confirm it is working as intended.
80
+
81
+ ---
82
+
83
+ ## Update your plugin build config
84
+
85
+ **In case your plugin was using `@grafana/toolkit` before make sure to migrate it first using `npx @grafana/create-plugin migrate`.**
86
+
87
+ As new Grafana versions come out we keep updating our plugin build tooling as well to stay compatible and to make it more performant.
88
+ In order to receive these changes and to make sure your plugin is compatible with the most recent Grafana versions you can use the `update` command,
89
+ that automatically updates the build configuration for you:
90
+
91
+ ```bash
92
+ # Run this command from the root of your plugin
93
+ cd ./my-plugin
94
+
95
+ npx @grafana/create-plugin update
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Start developing your plugin
101
+
102
+ We have put together the following dev scripts for you, so you can start coding right away:
103
+
104
+ #### `yarn dev`
105
+
106
+ Starts the build in watch mode.
107
+ The build output (plugin bundle) is going to be exported to `./dist`.
108
+
109
+ #### `yarn build`
110
+
111
+ Creates a production build for your plugin.
112
+ The build output is going to be exported to `./dist`.
113
+
114
+ #### `yarn test`
115
+
116
+ Runs the tests under `./src` directory in watch mode.
117
+ Give your test files a `.test.tsx` or `.test.ts` extension.
118
+
119
+ #### `yarn test:ci`
120
+
121
+ Runs the tests and returns with either a zero or a non-zero exit status.
122
+
123
+ #### `yarn typecheck`
124
+
125
+ Runs the Typescript compiler against the codebase in a dry-run mode to highlight any type errors or warnings.
126
+
127
+ #### `yarn lint`
128
+
129
+ Runs ESLint against the codebase.
130
+
131
+ #### `yarn lint:fix`
132
+
133
+ Runs ESLint against the codebase and attempts to fix the simpler errors.
134
+
135
+ ---
136
+
137
+ ## Customizing or extending the basic configs
138
+
139
+ You can read more about customizing or extending the basic configuration [here](templates/common/.config/README.md)
140
+
141
+ ## Contributing
142
+
143
+ We are always grateful for contribution! See the [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ exports.__esModule = true;
7
+ var minimist_1 = __importDefault(require("minimist"));
8
+ var commands_1 = require("../commands");
9
+ var args = process.argv.slice(2);
10
+ var argv = (0, minimist_1["default"])(args);
11
+ var commands = {
12
+ migrate: commands_1.migrate,
13
+ generate: commands_1.generate,
14
+ update: commands_1.update
15
+ };
16
+ var command = commands[argv._[0]] || commands.generate;
17
+ command(argv);
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ exports.__esModule = true;
42
+ exports.generate = void 0;
43
+ var path_1 = __importDefault(require("path"));
44
+ var plop_1 = require("plop");
45
+ var generate = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
46
+ return __generator(this, function (_a) {
47
+ plop_1.Plop.launch({
48
+ cwd: argv.cwd,
49
+ configPath: path_1["default"].join(__dirname, 'generate.plopfile.js'),
50
+ require: argv.require,
51
+ completion: argv.completion
52
+ }, function (env) { return (0, plop_1.run)(env, undefined, true); });
53
+ return [2];
54
+ });
55
+ }); };
56
+ exports.generate = generate;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ exports.__esModule = true;
15
+ var glob_1 = __importDefault(require("glob"));
16
+ var path_1 = __importDefault(require("path"));
17
+ var fs_1 = __importDefault(require("fs"));
18
+ var utils_handlebars_1 = require("../utils/utils.handlebars");
19
+ var constants_1 = require("../constants");
20
+ function default_1(plop) {
21
+ plop.setHelper('if_eq', utils_handlebars_1.ifEq);
22
+ plop.setHelper('normalize_id', utils_handlebars_1.normalizeId);
23
+ plop.setGenerator('create-plugin', {
24
+ description: 'used to scaffold a grafana plugin',
25
+ prompts: [
26
+ {
27
+ name: 'pluginName',
28
+ type: 'input',
29
+ message: 'What is going to be the name of your plugin?'
30
+ },
31
+ {
32
+ name: 'orgName',
33
+ type: 'input',
34
+ message: 'What is the organization name of your plugin?',
35
+ "default": 'my-org'
36
+ },
37
+ {
38
+ name: 'pluginDescription',
39
+ type: 'input',
40
+ message: 'How would you describe your plugin?',
41
+ "default": '<plugin description>'
42
+ },
43
+ {
44
+ name: 'pluginType',
45
+ type: 'list',
46
+ choices: [constants_1.PLUGIN_TYPES.app, constants_1.PLUGIN_TYPES.datasource, constants_1.PLUGIN_TYPES.panel],
47
+ message: 'What kind of plugin would you like? '
48
+ },
49
+ {
50
+ name: 'hasBackend',
51
+ type: 'confirm',
52
+ message: 'Do you want a backend part of your plugin?',
53
+ "default": false
54
+ },
55
+ {
56
+ name: 'hasGithubWorkflows',
57
+ type: 'confirm',
58
+ message: 'Do you want to add Github CI and Release workflows?',
59
+ "default": false
60
+ },
61
+ {
62
+ name: 'hasGithubLevitateWorkflow',
63
+ type: 'confirm',
64
+ message: 'Do you want to add a Github workflow for automatically checking "Grafana API compatibility" on PRs?',
65
+ "default": false
66
+ },
67
+ ],
68
+ actions: function (_a) {
69
+ var pluginType = _a.pluginType, hasBackend = _a.hasBackend, hasGithubWorkflows = _a.hasGithubWorkflows, hasGithubLevitateWorkflow = _a.hasGithubLevitateWorkflow;
70
+ var commonActions = getActionsForTemplateFolder(constants_1.TEMPLATE_PATHS.common);
71
+ var pluginTypeSpecificActions = getActionsForTemplateFolder(constants_1.TEMPLATE_PATHS[pluginType]);
72
+ var backendActions = hasBackend ? getActionsForTemplateFolder(constants_1.TEMPLATE_PATHS.backend) : [];
73
+ var ciWorkflowActions = hasGithubWorkflows ? getActionsForTemplateFolder(constants_1.TEMPLATE_PATHS.ciWorkflows) : [];
74
+ var isCompatibleWorkflowActions = hasGithubLevitateWorkflow
75
+ ? getActionsForTemplateFolder(constants_1.TEMPLATE_PATHS.isCompatibleWorkflow)
76
+ : [];
77
+ var readmeActions = getActionsForReadme();
78
+ return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], commonActions, true), pluginTypeSpecificActions, true), backendActions, true), ciWorkflowActions, true), readmeActions, true), isCompatibleWorkflowActions, true);
79
+ }
80
+ });
81
+ }
82
+ exports["default"] = default_1;
83
+ function getActionsForReadme() {
84
+ return [
85
+ replacePatternWithTemplateInReadme('-- INSERT FRONTEND GETTING STARTED --', 'frontend-getting-started.md'),
86
+ replacePatternWithTemplateInReadme('-- INSERT BACKEND GETTING STARTED --', 'backend-getting-started.md'),
87
+ ];
88
+ }
89
+ function replacePatternWithTemplateInReadme(pattern, partialsFile) {
90
+ return {
91
+ type: 'modify',
92
+ path: path_1["default"].join(constants_1.EXPORT_PATH_PREFIX, 'README.md'),
93
+ pattern: pattern,
94
+ template: undefined,
95
+ templateFile: path_1["default"].join(constants_1.PARTIALS_DIR, partialsFile),
96
+ data: constants_1.EXTRA_TEMPLATE_VARIABLES
97
+ };
98
+ }
99
+ function getActionsForTemplateFolder(folderPath) {
100
+ var files = glob_1["default"].sync("".concat(folderPath, "/**"), { dot: true });
101
+ var getExportFileName = function (f) { return (path_1["default"].extname(f) === '.hbs' ? path_1["default"].basename(f, '.hbs') : path_1["default"].basename(f)); };
102
+ var getExportPath = function (f) { return path_1["default"].relative(folderPath, path_1["default"].dirname(f)); };
103
+ return files.filter(isFile).map(function (f) { return ({
104
+ type: 'add',
105
+ templateFile: f,
106
+ path: path_1["default"].join(constants_1.EXPORT_PATH_PREFIX, getExportPath(f), getExportFileName(f)),
107
+ force: constants_1.IS_DEV,
108
+ abortOnFail: false,
109
+ data: constants_1.EXTRA_TEMPLATE_VARIABLES
110
+ }); });
111
+ }
112
+ function isFile(path) {
113
+ try {
114
+ return fs_1["default"].lstatSync(path).isFile();
115
+ }
116
+ catch (e) {
117
+ return false;
118
+ }
119
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ exports.__esModule = true;
17
+ __exportStar(require("./generate.command"), exports);
18
+ __exportStar(require("./update.command"), exports);
19
+ __exportStar(require("./migrate.command"), exports);