@flarum/cli 1.0.0 → 2.0.0-beta.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.
- package/README.md +2 -2
- package/bin/run +5 -3
- package/boilerplate/skeleton/extension/.gitattributes +16 -3
- package/boilerplate/skeleton/extension/.github/workflows/backend.yml +15 -0
- package/boilerplate/skeleton/extension/.github/workflows/frontend.yml +20 -0
- package/boilerplate/skeleton/extension/.styleci.yml +14 -0
- package/boilerplate/skeleton/extension/LICENSE.md +1 -0
- package/boilerplate/skeleton/extension/README.md +7 -7
- package/boilerplate/skeleton/extension/composer.json +11 -9
- package/boilerplate/skeleton/extension/extend.php +10 -10
- package/boilerplate/skeleton/extension/js/admin.js +2 -1
- package/boilerplate/skeleton/extension/js/forum.js +2 -1
- package/boilerplate/skeleton/extension/js/package.json +13 -9
- package/boilerplate/skeleton/extension/js/src/admin/index.js +4 -2
- package/boilerplate/skeleton/extension/js/src/common/index.js +5 -0
- package/boilerplate/skeleton/extension/js/src/forum/index.js +4 -2
- package/boilerplate/skeleton/extension/js/tsconfig.json +6 -1
- package/boilerplate/skeleton/extension/locale/en.yml +1 -1
- package/boilerplate/stubs/migration.php +1 -1
- package/lib/base-command.d.ts +27 -6
- package/lib/base-command.js +131 -41
- package/lib/boilersmith/exposed-param-manager.d.ts +8 -0
- package/lib/boilersmith/exposed-param-manager.js +31 -0
- package/lib/boilersmith/io.d.ts +50 -0
- package/lib/boilersmith/io.js +72 -0
- package/lib/boilersmith/paths.d.ts +22 -0
- package/lib/boilersmith/paths.js +29 -0
- package/lib/boilersmith/scaffolding/audit-step-factory.d.ts +5 -0
- package/lib/boilersmith/scaffolding/audit-step-factory.js +54 -0
- package/lib/boilersmith/scaffolding/infra-step-factory.d.ts +5 -0
- package/lib/boilersmith/scaffolding/infra-step-factory.js +34 -0
- package/lib/boilersmith/scaffolding/init-step-factory.d.ts +5 -0
- package/lib/boilersmith/scaffolding/init-step-factory.js +34 -0
- package/lib/boilersmith/scaffolding/module.d.ts +68 -0
- package/lib/boilersmith/scaffolding/module.js +111 -0
- package/lib/boilersmith/scaffolding/scaffolder.d.ts +32 -0
- package/lib/boilersmith/scaffolding/scaffolder.js +203 -0
- package/lib/boilersmith/scaffolding/template-param.d.ts +23 -0
- package/lib/boilersmith/scaffolding/template-param.js +46 -0
- package/lib/boilersmith/step-manager.d.ts +85 -0
- package/lib/boilersmith/step-manager.js +234 -0
- package/lib/boilersmith/steps/stub-base.d.ts +53 -0
- package/lib/boilersmith/steps/stub-base.js +54 -0
- package/lib/{utils → boilersmith/utils}/clone-and-fill.d.ts +0 -0
- package/lib/{utils → boilersmith/utils}/clone-and-fill.js +2 -2
- package/lib/boilersmith/utils/cond-format.d.ts +1 -0
- package/lib/boilersmith/utils/cond-format.js +8 -0
- package/lib/boilersmith/utils/json-leaf-paths.d.ts +7 -0
- package/lib/boilersmith/utils/json-leaf-paths.js +17 -0
- package/lib/boilersmith/utils/read-tpl.d.ts +2 -0
- package/lib/boilersmith/utils/read-tpl.js +10 -0
- package/lib/boilersmith/utils/rename-keys.d.ts +1 -0
- package/lib/boilersmith/utils/rename-keys.js +7 -0
- package/lib/commands/audit/infra.d.ts +16 -0
- package/lib/commands/audit/infra.js +27 -0
- package/lib/commands/infra.d.ts +20 -0
- package/lib/commands/infra.js +55 -0
- package/lib/commands/init.d.ts +4 -3
- package/lib/commands/init.js +8 -6
- package/lib/commands/make/backend/api-controller.d.ts +4 -3
- package/lib/commands/make/backend/api-controller.js +3 -2
- package/lib/commands/make/backend/api-serializer-attributes.d.ts +4 -3
- package/lib/commands/make/backend/api-serializer-attributes.js +1 -1
- package/lib/commands/make/backend/api-serializer.d.ts +4 -3
- package/lib/commands/make/backend/api-serializer.js +3 -2
- package/lib/commands/make/backend/command.d.ts +4 -3
- package/lib/commands/make/backend/command.js +3 -2
- package/lib/commands/make/backend/event-listener.d.ts +4 -3
- package/lib/commands/make/backend/event-listener.js +3 -2
- package/lib/commands/make/backend/handler.d.ts +4 -3
- package/lib/commands/make/backend/handler.js +4 -3
- package/lib/commands/make/backend/integration-test.d.ts +4 -3
- package/lib/commands/make/backend/integration-test.js +3 -2
- package/lib/commands/make/backend/job.d.ts +4 -3
- package/lib/commands/make/backend/job.js +3 -2
- package/lib/commands/make/backend/migration.d.ts +4 -3
- package/lib/commands/make/backend/migration.js +3 -2
- package/lib/commands/make/backend/model.d.ts +4 -3
- package/lib/commands/make/backend/model.js +22 -21
- package/lib/commands/make/backend/policy.d.ts +4 -3
- package/lib/commands/make/backend/policy.js +3 -2
- package/lib/commands/make/backend/repository.d.ts +4 -3
- package/lib/commands/make/backend/repository.js +3 -2
- package/lib/commands/make/backend/route.d.ts +4 -3
- package/lib/commands/make/backend/route.js +1 -1
- package/lib/commands/make/backend/service-provider.d.ts +4 -3
- package/lib/commands/make/backend/service-provider.js +3 -2
- package/lib/commands/make/backend/validator.d.ts +4 -3
- package/lib/commands/make/backend/validator.js +3 -2
- package/lib/commands/make/frontend/component.d.ts +4 -3
- package/lib/commands/make/frontend/component.js +3 -2
- package/lib/commands/make/frontend/modal.d.ts +4 -3
- package/lib/commands/make/frontend/modal.js +3 -2
- package/lib/commands/make/frontend/model.d.ts +4 -3
- package/lib/commands/make/frontend/model.js +3 -2
- package/lib/commands/update/js-imports.d.ts +4 -3
- package/lib/commands/update/js-imports.js +1 -1
- package/lib/help.d.ts +5 -6
- package/lib/help.js +5 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -2
- package/lib/providers/index.d.ts +5 -0
- package/lib/providers/index.js +2 -0
- package/lib/{provider → providers}/php-provider.d.ts +0 -0
- package/lib/{provider → providers}/php-provider.js +2 -2
- package/lib/steps/extenders/api-serializer.js +2 -3
- package/lib/steps/extenders/base.d.ts +10 -10
- package/lib/steps/extenders/base.js +11 -11
- package/lib/steps/extenders/console-command.js +2 -3
- package/lib/steps/extenders/event.js +2 -3
- package/lib/steps/extenders/policy.js +2 -3
- package/lib/steps/extenders/route.js +2 -3
- package/lib/steps/extenders/service-provider.js +2 -3
- package/lib/steps/gen-ext-scaffolder.d.ts +6 -0
- package/lib/steps/gen-ext-scaffolder.js +508 -0
- package/lib/steps/js/base.d.ts +9 -9
- package/lib/steps/js/base.js +11 -11
- package/lib/steps/js/model.d.ts +5 -5
- package/lib/steps/js/model.js +8 -13
- package/lib/steps/misc/composer.d.ts +5 -6
- package/lib/steps/misc/composer.js +3 -3
- package/lib/steps/misc/git.d.ts +11 -0
- package/lib/steps/misc/git.js +20 -0
- package/lib/steps/misc/yarn.d.ts +5 -6
- package/lib/steps/misc/yarn.js +3 -3
- package/lib/steps/stubs/backend/api-controller.d.ts +1 -8
- package/lib/steps/stubs/backend/api-controller.js +2 -3
- package/lib/steps/stubs/backend/api-serializer.d.ts +4 -9
- package/lib/steps/stubs/backend/api-serializer.js +4 -4
- package/lib/steps/stubs/backend/command.d.ts +0 -5
- package/lib/steps/stubs/backend/command.js +1 -1
- package/lib/steps/stubs/backend/event-listener.d.ts +0 -5
- package/lib/steps/stubs/backend/event-listener.js +1 -1
- package/lib/steps/stubs/backend/handler-command.js +1 -1
- package/lib/steps/stubs/backend/handler.js +1 -1
- package/lib/steps/stubs/backend/migration.d.ts +4 -5
- package/lib/steps/stubs/backend/migration.js +8 -8
- package/lib/steps/stubs/backend/model.d.ts +4 -4
- package/lib/steps/stubs/backend/model.js +4 -4
- package/lib/steps/stubs/backend/policy.d.ts +0 -5
- package/lib/steps/stubs/backend/policy.js +1 -1
- package/lib/steps/stubs/backend/repository.d.ts +0 -5
- package/lib/steps/stubs/backend/repository.js +1 -1
- package/lib/steps/stubs/flarum-base.d.ts +9 -0
- package/lib/steps/stubs/flarum-base.js +10 -0
- package/lib/steps/stubs/frontend/component.js +0 -1
- package/lib/steps/stubs/frontend/modal.js +0 -1
- package/lib/steps/stubs/frontend/model.d.ts +4 -4
- package/lib/steps/stubs/frontend/model.js +3 -3
- package/lib/steps/stubs/js-base.d.ts +6 -7
- package/lib/steps/stubs/js-base.js +11 -16
- package/lib/steps/stubs/php-base.d.ts +7 -8
- package/lib/steps/stubs/php-base.js +12 -20
- package/lib/steps/update/js-imports.d.ts +5 -6
- package/lib/steps/update/js-imports.js +13 -17
- package/lib/utils/composer.d.ts +64 -0
- package/lib/utils/composer.js +8 -0
- package/lib/utils/migration.js +3 -3
- package/lib/utils/model-name.js +6 -6
- package/lib/utils/validation.d.ts +10 -7
- package/lib/utils/validation.js +9 -6
- package/oclif.manifest.json +1 -1
- package/package.json +53 -31
- package/php-subsystem/src/NodeVisitors/AddExtender.php +2 -1
- package/boilerplate/skeleton/extension/.github/workflows/build.yml +0 -32
- package/boilerplate/skeleton/extension/.github/workflows/lint.yml +0 -32
- package/boilerplate/skeleton/extension/.github/workflows/test.yml +0 -78
- package/lib/commands/infra/backend-testing.d.ts +0 -14
- package/lib/commands/infra/backend-testing.js +0 -26
- package/lib/provider/param-provider.d.ts +0 -15
- package/lib/provider/param-provider.js +0 -39
- package/lib/provider/path-provider.d.ts +0 -19
- package/lib/provider/path-provider.js +0 -24
- package/lib/steps/infra/backend-testing.d.ts +0 -8
- package/lib/steps/infra/backend-testing.js +0 -22
- package/lib/steps/infra/base.d.ts +0 -20
- package/lib/steps/infra/base.js +0 -36
- package/lib/steps/init/extension-skeleton.d.ts +0 -12
- package/lib/steps/init/extension-skeleton.js +0 -142
- package/lib/steps/step-manager.d.ts +0 -71
- package/lib/steps/step-manager.js +0 -173
- package/lib/steps/stubs/base.d.ts +0 -49
- package/lib/steps/stubs/base.js +0 -58
- package/lib/utils/extension-metadata.d.ts +0 -2
- package/lib/utils/extension-metadata.js +0 -21
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ $ npm install -g @flarum/cli
|
|
|
37
37
|
$ flarum-cli COMMAND
|
|
38
38
|
running command...
|
|
39
39
|
$ flarum-cli (-v|--version|version)
|
|
40
|
-
@flarum/cli/
|
|
40
|
+
@flarum/cli/2.0.0-beta.1 linux-x64 node-v16.13.0
|
|
41
41
|
$ flarum-cli --help [COMMAND]
|
|
42
42
|
USAGE
|
|
43
43
|
$ flarum-cli COMMAND
|
|
@@ -192,7 +192,7 @@ For example:
|
|
|
192
192
|
},
|
|
193
193
|
]);
|
|
194
194
|
})
|
|
195
|
-
.run(
|
|
195
|
+
.run(new Paths({...}), new PromptsIO(), {php: new PhpProvider(...)});
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|
|
package/bin/run
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
require('
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
require('module-alias').addAlias('boilersmith', `${__dirname}/../lib/boilersmith`);
|
|
4
|
+
|
|
5
|
+
const oclif = require('@oclif/core');
|
|
6
|
+
|
|
7
|
+
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'));
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
.
|
|
1
|
+
.gitattributes export-ignore
|
|
2
|
+
.gitignore export-ignore
|
|
3
|
+
.gitmodules export-ignore
|
|
4
|
+
.github export-ignore
|
|
5
|
+
.travis export-ignore
|
|
6
|
+
.travis.yml export-ignore
|
|
7
|
+
.editorconfig export-ignore
|
|
8
|
+
.styleci.yml export-ignore
|
|
3
9
|
|
|
4
|
-
|
|
10
|
+
phpunit.xml export-ignore
|
|
11
|
+
tests export-ignore
|
|
12
|
+
|
|
13
|
+
js/dist/* -diff
|
|
14
|
+
js/dist/* linguist-generated
|
|
15
|
+
js/dist-typings/* linguist-generated
|
|
16
|
+
|
|
17
|
+
* text=auto eol=lf
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: PHP
|
|
2
|
+
|
|
3
|
+
on: [workflow_dispatch, push, pull_request]
|
|
4
|
+
|
|
5
|
+
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
|
|
6
|
+
# This will break your current script.
|
|
7
|
+
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
run:
|
|
11
|
+
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
|
|
12
|
+
with:
|
|
13
|
+
enable_backend_testing: <%= modules.backendTesting %>
|
|
14
|
+
|
|
15
|
+
backend_directory: <%= params.backendDirectory %>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: JS
|
|
2
|
+
|
|
3
|
+
on: [workflow_dispatch, push, pull_request]
|
|
4
|
+
|
|
5
|
+
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
|
|
6
|
+
# This will break your current script.
|
|
7
|
+
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
run:
|
|
11
|
+
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
|
|
12
|
+
with:
|
|
13
|
+
enable_bundlewatch: <%= modules.bundlewatch %>
|
|
14
|
+
enable_prettier: <%= modules.prettier %>
|
|
15
|
+
enable_typescript: <%= modules.typescript %>
|
|
16
|
+
|
|
17
|
+
frontend_directory: <%= params.frontendDirectory %>
|
|
18
|
+
main_git_branch: <%= params.mainGitBranch %>
|
|
19
|
+
secrets:
|
|
20
|
+
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
preset: recommended
|
|
2
|
+
|
|
3
|
+
enabled:
|
|
4
|
+
- logical_not_operators_with_successor_space
|
|
5
|
+
|
|
6
|
+
disabled:
|
|
7
|
+
- align_double_arrow
|
|
8
|
+
- blank_line_after_opening_tag
|
|
9
|
+
- multiline_array_trailing_comma
|
|
10
|
+
- new_with_braces
|
|
11
|
+
- phpdoc_align
|
|
12
|
+
- phpdoc_order
|
|
13
|
+
- phpdoc_separation
|
|
14
|
+
- phpdoc_types
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= params.licenseText %>
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# <%= extensionName %>
|
|
1
|
+
# <%= params.extensionName %>
|
|
2
2
|
|
|
3
|
-
 [](https://packagist.org/packages/<%= packageName %>) [](https://packagist.org/packages/<%= packageName %>)
|
|
3
|
+
 [](https://packagist.org/packages/<%= params.packageName %>) [](https://packagist.org/packages/<%= params.packageName %>)
|
|
4
4
|
|
|
5
|
-
A [Flarum](http://flarum.org) extension. <%= packageDescription %>
|
|
5
|
+
A [Flarum](http://flarum.org) extension. <%= params.packageDescription %>
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
Install with composer:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
composer require <%= packageName %>:"*"
|
|
12
|
+
composer require <%= params.packageName %>:"*"
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Updating
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
|
-
composer update <%= packageName %>:"*"
|
|
18
|
+
composer update <%= params.packageName %>:"*"
|
|
19
19
|
php flarum migrate
|
|
20
20
|
php flarum cache:clear
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Links
|
|
24
24
|
|
|
25
|
-
- [Packagist](https://packagist.org/packages/<%= packageName %>)
|
|
26
|
-
- [GitHub](https://github.com/<%= packageName %>)
|
|
25
|
+
- [Packagist](https://packagist.org/packages/<%= params.packageName %>)
|
|
26
|
+
- [GitHub](https://github.com/<%= params.packageName %>)
|
|
27
27
|
- [Discuss](https://discuss.flarum.org/d/PUT_DISCUSS_SLUG_HERE)
|
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "<%= packageName %>",<% if (packageDescription) { %>
|
|
3
|
-
"description": "<%= packageDescription %>",<% } %>
|
|
2
|
+
"name": "<%= params.packageName %>",<% if (params.packageDescription) { %>
|
|
3
|
+
"description": "<%= params.packageDescription %>",<% } %>
|
|
4
4
|
"keywords": [
|
|
5
5
|
"flarum"
|
|
6
6
|
],
|
|
7
7
|
"type": "flarum-extension",
|
|
8
|
-
"license": "<%= licenseType %>",
|
|
8
|
+
"license": "<%= params.licenseType %>",
|
|
9
9
|
"require": {
|
|
10
10
|
"flarum/core": "^1.0.0"
|
|
11
11
|
},
|
|
12
12
|
"require-dev": {
|
|
13
13
|
"flarum/testing": "^1.0.0"
|
|
14
14
|
},
|
|
15
|
-
"authors": [<% if (authorName
|
|
15
|
+
"authors": [<% if (params.authorName) { %>
|
|
16
16
|
{
|
|
17
|
-
"name": "<%= authorName %>",<% if (authorEmail) { %>
|
|
18
|
-
"email": "<%= authorEmail %>",<% } %>
|
|
17
|
+
"name": "<%= params.authorName %>",<% if (params.authorEmail) { %>
|
|
18
|
+
"email": "<%= params.authorEmail %>",<% } %>
|
|
19
19
|
"role": "Developer"
|
|
20
20
|
}
|
|
21
21
|
<% } %>],
|
|
22
|
+
<% if (params.packageNamespace) { %>
|
|
22
23
|
"autoload": {
|
|
23
24
|
"psr-4": {
|
|
24
|
-
"<%=
|
|
25
|
+
"<%= params.packageNamespaceEscapedSlash %>\\": "src/"
|
|
25
26
|
}
|
|
26
27
|
},
|
|
28
|
+
<% } %>
|
|
27
29
|
"autoload-dev": {
|
|
28
30
|
"psr-4": {
|
|
29
|
-
"<%=
|
|
31
|
+
"<%= params.packageNamespaceEscapedSlash %>\\Tests\\": "tests/"
|
|
30
32
|
}
|
|
31
33
|
},
|
|
32
34
|
"extra": {
|
|
33
35
|
"flarum-extension": {
|
|
34
|
-
"title": "<%= extensionName %>",
|
|
36
|
+
"title": "<%= params.extensionName %>",
|
|
35
37
|
"category": "",
|
|
36
38
|
"icon": {
|
|
37
39
|
"name": "",
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
|
-
* This file is part of <%= packageName %>.
|
|
4
|
+
* This file is part of <%= params.packageName %>.
|
|
5
5
|
*
|
|
6
|
-
* Copyright (c) <%= year %> <%= authorName %>.
|
|
6
|
+
* Copyright (c) <%= params.year %> <%= params.authorName %>.
|
|
7
7
|
*
|
|
8
8
|
* For the full copyright and license information, please view the LICENSE.md
|
|
9
9
|
* file that was distributed with this source code.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
namespace <%=
|
|
12
|
+
namespace <%= params.packageNamespace %>;
|
|
13
13
|
|
|
14
14
|
use Flarum\Extend;
|
|
15
15
|
|
|
16
16
|
return [
|
|
17
|
-
<% if (
|
|
18
|
-
<% if (
|
|
19
|
-
<% if (
|
|
20
|
-
<% if (
|
|
21
|
-
<% if (
|
|
22
|
-
<% if (
|
|
23
|
-
<% if (
|
|
17
|
+
<% if (modules.js || modules.css) { %>(new Extend\Frontend('forum'))
|
|
18
|
+
<% if (modules.js) { %>->js(__DIR__.'/js/dist/forum.js')<% if (!modules.css) { %>,<% } %><% } %>
|
|
19
|
+
<% if (modules.css) { %>->css(__DIR__.'/less/forum.less'),<% } %><% } %>
|
|
20
|
+
<% if (modules.js || modules.css) { %>(new Extend\Frontend('admin'))
|
|
21
|
+
<% if (modules.js) { %>->js(__DIR__.'/js/dist/admin.js')<% if (!modules.css) { %>,<% } %><% } %>
|
|
22
|
+
<% if (modules.css) { %>->css(__DIR__.'/less/admin.less'),<% } %><% } %>
|
|
23
|
+
<% if (modules.locale) { %>new Extend\Locales(__DIR__.'/locale'),<% } %>
|
|
24
24
|
];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './src/
|
|
1
|
+
<% if (modules.jsCommon) { %>export * from './src/common';
|
|
2
|
+
<% } %>export * from './src/admin';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './src/
|
|
1
|
+
<% if (modules.jsCommon) { %>export * from './src/common';
|
|
2
|
+
<% } %>export * from './src/forum';
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@<%= packageName %>",
|
|
3
|
-
"version": "0.0.0",
|
|
2
|
+
"name": "@<%= params.packageName %>",
|
|
4
3
|
"private": true,
|
|
5
4
|
"prettier": "@flarum/prettier-config",
|
|
6
5
|
"dependencies": {
|
|
7
|
-
"flarum-webpack-config": "^1.0.0",
|
|
8
|
-
"flarum-tsconfig": "^1.0.0",
|
|
9
|
-
"@flarum/prettier-config": "^1.0.0",
|
|
10
|
-
"webpack": "^4.26.0",
|
|
11
|
-
"webpack-cli": "^3.0.7"
|
|
12
6
|
},
|
|
13
7
|
"devDependencies": {
|
|
14
|
-
"prettier": "^
|
|
8
|
+
"@flarum/prettier-config": "^1.0.0",
|
|
9
|
+
"flarum-tsconfig": "^1.0.2",
|
|
10
|
+
"flarum-webpack-config": "^2.0.0",
|
|
11
|
+
"prettier": "^2.4.1",
|
|
12
|
+
"typescript": "^4.4.4",
|
|
13
|
+
"typescript-coverage-report": "^0.6.1",
|
|
14
|
+
"webpack": "^5.61.0",
|
|
15
|
+
"webpack-cli": "^4.9.1"
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
18
|
"dev": "webpack --mode development --watch",
|
|
18
19
|
"build": "webpack --mode production",
|
|
20
|
+
"analyze": "cross-env ANALYZER=true yarn build",
|
|
19
21
|
"format": "prettier --write src",
|
|
20
|
-
"format-check": "prettier --check src"
|
|
22
|
+
"format-check": "prettier --check src",
|
|
23
|
+
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
|
|
24
|
+
"check-typings-coverage": "typescript-coverage-report"
|
|
21
25
|
}
|
|
22
26
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
app
|
|
2
|
-
|
|
1
|
+
import app from 'flarum/admin/app';
|
|
2
|
+
|
|
3
|
+
app.initializers.add('<%= params.packageName %>', () => {
|
|
4
|
+
console.log('[<%= params.packageName %>] Hello, admin!');
|
|
3
5
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
app
|
|
2
|
-
|
|
1
|
+
import app from 'flarum/forum/app';
|
|
2
|
+
|
|
3
|
+
app.initializers.add('<%= params.packageName %>', () => {
|
|
4
|
+
console.log('[<%= params.packageName %>] Hello, forum!');
|
|
3
5
|
});
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
+
// Use Flarum's tsconfig as a starting point
|
|
2
3
|
"extends": "flarum-tsconfig",
|
|
3
|
-
|
|
4
|
+
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder
|
|
5
|
+
// and also tells your Typescript server to read core's global typings for
|
|
6
|
+
// access to `dayjs` and `$` in the global namespace.
|
|
7
|
+
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*", "@types/**/*"],
|
|
4
8
|
"compilerOptions": {
|
|
9
|
+
// This will output typings to `dist-typings`
|
|
5
10
|
"declarationDir": "./dist-typings",
|
|
6
11
|
"baseUrl": ".",
|
|
7
12
|
"paths": {
|
|
@@ -5,7 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
|
|
|
5
5
|
use Illuminate\Database\Schema\Builder;
|
|
6
6
|
|
|
7
7
|
// HINT: you might want to use a `Flarum\Database\Migration` helper method for simplicity!
|
|
8
|
-
// See https://docs.flarum.org/extend/
|
|
8
|
+
// See https://docs.flarum.org/extend/models.html#migrations to learn more about migrations.
|
|
9
9
|
return [
|
|
10
10
|
'up' => function (Builder $schema) {
|
|
11
11
|
// up migration
|
package/lib/base-command.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { Command,
|
|
2
|
-
import { StepManager } from '
|
|
1
|
+
import { Command, Interfaces } from '@oclif/core';
|
|
2
|
+
import { StepManager } from 'boilersmith/step-manager';
|
|
3
|
+
import { FlarumProviders } from './providers';
|
|
4
|
+
export declare enum LocationType {
|
|
5
|
+
FLARUM_EXTENSION = 0,
|
|
6
|
+
FLARUM_CORE = 1,
|
|
7
|
+
FLARUM_MONOREPO = 2
|
|
8
|
+
}
|
|
3
9
|
export default abstract class BaseCommand extends Command {
|
|
4
|
-
|
|
10
|
+
protected STUB_PATH: string;
|
|
11
|
+
protected dry: boolean;
|
|
12
|
+
protected locationType?: LocationType;
|
|
13
|
+
protected args: Record<string, any>;
|
|
14
|
+
protected flags: any;
|
|
15
|
+
static flags: Interfaces.FlagInput<any>;
|
|
5
16
|
static args: {
|
|
6
17
|
name: string;
|
|
7
18
|
description: string;
|
|
@@ -11,8 +22,18 @@ export default abstract class BaseCommand extends Command {
|
|
|
11
22
|
protected welcomeMessage(): string;
|
|
12
23
|
protected goodbyeMessage(): string;
|
|
13
24
|
protected additionalPreRunChecks(_extRoot: string): Promise<void>;
|
|
14
|
-
protected abstract steps(stepManager: StepManager): StepManager
|
|
15
|
-
protected
|
|
25
|
+
protected abstract steps(stepManager: StepManager<FlarumProviders>): StepManager<FlarumProviders>;
|
|
26
|
+
protected monorepoPaths(options: {
|
|
27
|
+
includeCore: boolean;
|
|
28
|
+
includeExtensions: boolean;
|
|
29
|
+
includePhpPackages: boolean;
|
|
30
|
+
includeJSPackages: boolean;
|
|
31
|
+
}): string[];
|
|
32
|
+
protected isFlarumCore(path: string): boolean;
|
|
33
|
+
protected getFlarumExtensionRoot(currDir: string): Promise<{
|
|
34
|
+
path: string;
|
|
35
|
+
type: LocationType;
|
|
36
|
+
}>;
|
|
16
37
|
protected confirmExtDir(extRoot: string): Promise<void>;
|
|
17
38
|
protected ensureComposerInstallRan(extRoot: string): Promise<void>;
|
|
18
39
|
/**
|
|
@@ -20,6 +41,6 @@ export default abstract class BaseCommand extends Command {
|
|
|
20
41
|
* If true, files should be overriden.
|
|
21
42
|
* If user says no, will exit and not return anything.
|
|
22
43
|
*/
|
|
23
|
-
protected confirmOverrideFiles(dir: string, pattern: string, confirmationMessage: string): Promise<boolean>;
|
|
44
|
+
protected confirmOverrideFiles(dir: string, pattern: string | string[], confirmationMessage: string): Promise<boolean>;
|
|
24
45
|
protected deleteFiles(dir: string, pattern: string): Promise<void>;
|
|
25
46
|
}
|
package/lib/base-command.js
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocationType = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
5
|
-
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
6
|
-
const
|
|
7
|
-
const prompts_1 = tslib_1.__importDefault(require("prompts"));
|
|
8
|
-
const globby_1 = tslib_1.__importDefault(require("globby"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const step_manager_1 = require("
|
|
13
|
-
const
|
|
14
|
-
const php_provider_1 = require("./
|
|
15
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
16
|
-
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const prompts_1 = (0, tslib_1.__importDefault)(require("prompts"));
|
|
9
|
+
const globby_1 = (0, tslib_1.__importDefault)(require("globby"));
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const io_1 = require("boilersmith/io");
|
|
13
|
+
const step_manager_1 = require("boilersmith/step-manager");
|
|
14
|
+
const paths_1 = require("boilersmith/paths");
|
|
15
|
+
const php_provider_1 = require("./providers/php-provider");
|
|
16
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
17
|
+
var LocationType;
|
|
18
|
+
(function (LocationType) {
|
|
19
|
+
LocationType[LocationType["FLARUM_EXTENSION"] = 0] = "FLARUM_EXTENSION";
|
|
20
|
+
LocationType[LocationType["FLARUM_CORE"] = 1] = "FLARUM_CORE";
|
|
21
|
+
LocationType[LocationType["FLARUM_MONOREPO"] = 2] = "FLARUM_MONOREPO";
|
|
22
|
+
})(LocationType = exports.LocationType || (exports.LocationType = {}));
|
|
23
|
+
class BaseCommand extends core_1.Command {
|
|
17
24
|
constructor() {
|
|
18
25
|
super(...arguments);
|
|
26
|
+
this.STUB_PATH = (0, node_path_1.resolve)(__dirname, '../boilerplate/stubs/');
|
|
27
|
+
this.dry = false;
|
|
19
28
|
this.requireExistingExtension = true;
|
|
20
29
|
}
|
|
21
30
|
async run() {
|
|
22
|
-
const { args } = this.parse(this.constructor);
|
|
31
|
+
const { args, flags } = await this.parse(this.constructor);
|
|
32
|
+
this.args = args;
|
|
33
|
+
this.flags = flags;
|
|
23
34
|
const path = args.path;
|
|
24
35
|
const welcomeMessage = this.welcomeMessage();
|
|
25
36
|
if (welcomeMessage) {
|
|
@@ -27,24 +38,67 @@ class BaseCommand extends command_1.Command {
|
|
|
27
38
|
}
|
|
28
39
|
let extRoot;
|
|
29
40
|
if (this.requireExistingExtension) {
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
const rootData = await this.getFlarumExtensionRoot(path || process.cwd());
|
|
42
|
+
extRoot = rootData.path;
|
|
43
|
+
this.locationType = rootData.type;
|
|
44
|
+
if (!this.flags.defaults) {
|
|
45
|
+
await this.confirmExtDir(extRoot);
|
|
46
|
+
}
|
|
32
47
|
}
|
|
33
48
|
else {
|
|
34
49
|
extRoot = path || process.cwd();
|
|
35
50
|
}
|
|
36
51
|
await this.additionalPreRunChecks(extRoot);
|
|
37
|
-
const
|
|
52
|
+
const paths = new paths_1.NodePaths({
|
|
38
53
|
requestedDir: path,
|
|
39
|
-
|
|
54
|
+
package: extRoot,
|
|
40
55
|
});
|
|
41
|
-
const phpProvider = new php_provider_1.PhpSubsystemProvider(
|
|
42
|
-
const
|
|
43
|
-
.run(
|
|
56
|
+
const phpProvider = new php_provider_1.PhpSubsystemProvider((0, node_path_1.resolve)(__dirname, '../php-subsystem/index.php'));
|
|
57
|
+
const out = await this.steps(new step_manager_1.StepManager())
|
|
58
|
+
.run(paths, new io_1.PromptsIO(), { php: phpProvider }, this.dry);
|
|
59
|
+
const errorMessages = out.messages.filter(m => m.type === 'error');
|
|
44
60
|
this.log('\n\n');
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
if (out.succeeded && errorMessages.length === 0) {
|
|
62
|
+
this.log(chalk_1.default.bold(chalk_1.default.underline(chalk_1.default.green('Success! The following steps were completed:'))));
|
|
63
|
+
}
|
|
64
|
+
else if (out.succeeded) {
|
|
65
|
+
this.log(chalk_1.default.bold(chalk_1.default.underline(chalk_1.default.yellow('All steps completed, but with some errors:'))));
|
|
66
|
+
for (const message of errorMessages) {
|
|
67
|
+
this.log(chalk_1.default.dim(chalk_1.default.red(message.message)));
|
|
68
|
+
}
|
|
69
|
+
this.log(chalk_1.default.bold(chalk_1.default.yellow('The steps that completed were:')));
|
|
70
|
+
}
|
|
71
|
+
else if (out.error === 'EEXIT: 0') {
|
|
72
|
+
this.log(chalk_1.default.bold(chalk_1.default.underline(chalk_1.default.red('Exiting.'))));
|
|
73
|
+
if (out.stepsRan.length > 0) {
|
|
74
|
+
this.log(chalk_1.default.bold(chalk_1.default.yellow('Before the exit, the following steps were completed:')));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.log(chalk_1.default.bold(chalk_1.default.underline(chalk_1.default.red('Error occurred, and could not complete:'))));
|
|
79
|
+
this.log(chalk_1.default.red(out.error));
|
|
80
|
+
if (out.errorTrace) {
|
|
81
|
+
this.log(chalk_1.default.dim(chalk_1.default.red(out.errorTrace)));
|
|
82
|
+
}
|
|
83
|
+
if (out.stepsRan.length > 0) {
|
|
84
|
+
this.log('');
|
|
85
|
+
this.log(chalk_1.default.bold(chalk_1.default.yellow('Before the error, the following steps were completed:')));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const stepName of out.stepsRan)
|
|
89
|
+
this.log(`- ${chalk_1.default.dim(stepName)}`);
|
|
47
90
|
this.log('');
|
|
91
|
+
const nonErrorMessages = out.messages.filter(m => m.type !== 'error');
|
|
92
|
+
if (nonErrorMessages.length > 0) {
|
|
93
|
+
this.log('');
|
|
94
|
+
this.log('The following messages were generated during execution:');
|
|
95
|
+
for (const message of nonErrorMessages) {
|
|
96
|
+
this.log(message.message);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!out.succeeded || errorMessages.length > 0) {
|
|
100
|
+
this.exit(1);
|
|
101
|
+
}
|
|
48
102
|
const goodbyeMessage = this.goodbyeMessage();
|
|
49
103
|
if (goodbyeMessage) {
|
|
50
104
|
this.log(goodbyeMessage);
|
|
@@ -62,43 +116,77 @@ class BaseCommand extends command_1.Command {
|
|
|
62
116
|
// ----------------------------------------------------------------
|
|
63
117
|
// Confirmation
|
|
64
118
|
// ----------------------------------------------------------------
|
|
119
|
+
monorepoPaths(options) {
|
|
120
|
+
try {
|
|
121
|
+
const monorepoConfig = (0, node_fs_1.readFileSync)((0, node_path_1.resolve)(process.cwd(), 'flarum-monorepo.json'));
|
|
122
|
+
const contents = JSON.parse(monorepoConfig.toString());
|
|
123
|
+
return [
|
|
124
|
+
...(options.includeCore ? [contents.packages.core] : []),
|
|
125
|
+
...(options.includeExtensions ? contents.packages.extensions : []),
|
|
126
|
+
...(options.includePhpPackages ? contents.packages.composerPackages : []),
|
|
127
|
+
...(options.includeJSPackages ? contents.packages.npmPackages : []),
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
catch (_a) {
|
|
131
|
+
this.error('Could not run monorepo command: `flarum-monorepo.json` file is missing or invalid.');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
isFlarumCore(path) {
|
|
135
|
+
try {
|
|
136
|
+
const composerJsonPath = (0, node_path_1.resolve)(path, 'composer.json');
|
|
137
|
+
const val = JSON.parse((0, node_fs_1.readFileSync)(composerJsonPath, 'utf8'));
|
|
138
|
+
return val.name === 'flarum/core';
|
|
139
|
+
}
|
|
140
|
+
catch (_a) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
65
144
|
async getFlarumExtensionRoot(currDir) {
|
|
66
|
-
let currPath =
|
|
145
|
+
let currPath = (0, node_path_1.resolve)(currDir);
|
|
67
146
|
while (currPath !== '/') {
|
|
68
|
-
if (
|
|
69
|
-
return currPath;
|
|
147
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(currPath, 'flarum-monorepo.json'))) {
|
|
148
|
+
return { path: currPath, type: LocationType.FLARUM_MONOREPO };
|
|
149
|
+
}
|
|
150
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(currPath, 'composer.json')) && (0, node_fs_1.existsSync)((0, node_path_1.resolve)(currPath, 'extend.php'))) {
|
|
151
|
+
return { path: currPath, type: LocationType.FLARUM_EXTENSION };
|
|
152
|
+
}
|
|
153
|
+
if (this.isFlarumCore(currPath)) {
|
|
154
|
+
return { path: currPath, type: LocationType.FLARUM_CORE };
|
|
70
155
|
}
|
|
71
|
-
currPath =
|
|
156
|
+
currPath = (0, node_path_1.resolve)(currPath, '..');
|
|
72
157
|
}
|
|
73
|
-
this.error(`${
|
|
158
|
+
this.error(`${(0, node_path_1.resolve)(currDir)} is not located in a valid Flarum package!
|
|
159
|
+
- Flarum extensions must contain (at a minimum) 'extend.php' and 'composer.json' files.
|
|
160
|
+
- Flarum core must contain a 'composer.json' file with the name 'flarum/core'.
|
|
161
|
+
- Flarum monorepos must have a valid 'flarum-monorepo.json' file`);
|
|
74
162
|
}
|
|
75
163
|
async confirmExtDir(extRoot) {
|
|
76
|
-
const response = await prompts_1.default([
|
|
164
|
+
const response = await (0, prompts_1.default)([
|
|
77
165
|
{
|
|
78
166
|
name: 'verify',
|
|
79
167
|
type: 'confirm',
|
|
80
|
-
message: `Work in Flarum
|
|
168
|
+
message: `Work in Flarum package located at ${(0, node_path_1.resolve)(extRoot)}?`,
|
|
81
169
|
initial: true,
|
|
82
170
|
},
|
|
83
|
-
],
|
|
171
|
+
], io_1.PROMPTS_OPTIONS);
|
|
84
172
|
if (!response.verify)
|
|
85
173
|
this.exit();
|
|
86
174
|
}
|
|
87
175
|
async ensureComposerInstallRan(extRoot) {
|
|
88
|
-
if (
|
|
176
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(extRoot, 'vendor/flarum/core/composer.json')))
|
|
89
177
|
return;
|
|
90
178
|
this.log("This command requires `composer install` to have been ran in your extension's root directory.");
|
|
91
|
-
const response = await prompts_1.default([
|
|
179
|
+
const response = await (0, prompts_1.default)([
|
|
92
180
|
{
|
|
93
181
|
name: 'composer',
|
|
94
182
|
type: 'confirm',
|
|
95
183
|
message: 'Would you like me to take care of that for you?',
|
|
96
184
|
initial: true,
|
|
97
185
|
},
|
|
98
|
-
],
|
|
186
|
+
], io_1.PROMPTS_OPTIONS);
|
|
99
187
|
if (response.composer) {
|
|
100
188
|
cli_ux_1.default.action.start('Installing composer packages');
|
|
101
|
-
|
|
189
|
+
(0, node_child_process_1.execSync)('composer install', { cwd: extRoot });
|
|
102
190
|
cli_ux_1.default.action.stop();
|
|
103
191
|
}
|
|
104
192
|
else {
|
|
@@ -111,29 +199,31 @@ class BaseCommand extends command_1.Command {
|
|
|
111
199
|
* If user says no, will exit and not return anything.
|
|
112
200
|
*/
|
|
113
201
|
async confirmOverrideFiles(dir, pattern, confirmationMessage) {
|
|
114
|
-
const
|
|
202
|
+
const paths = Array.isArray(pattern) ? pattern : [pattern];
|
|
203
|
+
const files = await (0, globby_1.default)(paths.map(p => (0, node_path_1.resolve)(dir, p)));
|
|
115
204
|
const empty = files.length === 0 || (files.length === 1 && files[0] === '.git');
|
|
116
205
|
if (empty)
|
|
117
206
|
return false;
|
|
118
|
-
const response = await prompts_1.default([
|
|
207
|
+
const response = await (0, prompts_1.default)([
|
|
119
208
|
{
|
|
120
209
|
name: 'overwrite',
|
|
121
210
|
type: 'confirm',
|
|
122
211
|
message: confirmationMessage,
|
|
123
212
|
},
|
|
124
|
-
],
|
|
213
|
+
], io_1.PROMPTS_OPTIONS);
|
|
125
214
|
if (response.overwrite === false)
|
|
126
215
|
this.exit();
|
|
127
216
|
return true;
|
|
128
217
|
}
|
|
129
218
|
async deleteFiles(dir, pattern) {
|
|
130
|
-
const pathsToDelete = await globby_1.default(
|
|
131
|
-
pathsToDelete.forEach(
|
|
219
|
+
const pathsToDelete = await (0, globby_1.default)((0, node_path_1.resolve)(dir, pattern));
|
|
220
|
+
pathsToDelete.forEach(node_fs_1.unlinkSync);
|
|
132
221
|
}
|
|
133
222
|
}
|
|
134
223
|
exports.default = BaseCommand;
|
|
135
224
|
BaseCommand.flags = {
|
|
136
|
-
|
|
225
|
+
defaults: core_1.Flags.boolean({ char: 'd', description: 'Assume default responses to prompts where possible.', default: false }),
|
|
226
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
137
227
|
};
|
|
138
228
|
BaseCommand.args = [
|
|
139
229
|
{
|