Skip to content

Commit 385dc31

Browse files
authored
Fix CLI commands (#214)
1 parent 65f4fa3 commit 385dc31

26 files changed

+134
-736
lines changed

.core/.cli/commands/reactium/component/index.js

+20-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
arcli.Reactium = require('@atomic-reactor/reactium-sdk-core').default;
1+
import Reactium from '@atomic-reactor/reactium-sdk-core';
22

3-
const { ActionSequence, ora, path, Reactium } = arcli;
3+
arcli.Reactium = Reactium;
4+
5+
const { ActionSequence, ora, path } = arcli;
46

57
const ENUMS = {
68
CANCELED: 'component canceled!',
@@ -39,6 +41,8 @@ const ENUMS = {
3941
NAME: 'component',
4042
};
4143

44+
export const NAME = ENUMS.NAME;
45+
4246
// prettier-ignore
4347
const HELP = () => console.log(`
4448
Example:
@@ -53,19 +57,19 @@ Example:
5357

5458
const ACTION = async ({ opt, props }) => {
5559
// load hooks
56-
arcli
57-
.globby(
58-
[
59-
'./.core/**/reactium-arcli.js',
60-
'./src/**/reactium-arcli.js',
61-
'./reactium_modules/**/reactium-arcli.js',
62-
'./node_modules/**/reactium-arcli.js',
63-
],
64-
{
65-
dot: true,
66-
},
67-
)
68-
.forEach(file => require(path.resolve(file)));
60+
for (const file of arcli.globby(
61+
[
62+
'./.core/**/reactium-arcli.js',
63+
'./src/**/reactium-arcli.js',
64+
'./reactium_modules/**/reactium-arcli.js',
65+
'./node_modules/**/reactium-arcli.js',
66+
],
67+
{
68+
dot: true,
69+
},
70+
)) {
71+
await import(path.resolve(file));
72+
}
6973

7074
let params = arcli.flagsToParams({ opt, flags: Object.keys(ENUMS.FLAGS) });
7175

@@ -180,7 +184,7 @@ const ACTION = async ({ opt, props }) => {
180184
});
181185
};
182186

183-
const COMMAND = ({ program, props }) => {
187+
export const COMMAND = ({ program, props }) => {
184188
program
185189
.command(ENUMS.NAME)
186190
.description(ENUMS.DESC)
@@ -197,8 +201,3 @@ const COMMAND = ({ program, props }) => {
197201

198202
return program;
199203
};
200-
201-
module.exports = {
202-
COMMAND,
203-
NAME: ENUMS.NAME,
204-
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "reactium-component-cmd",
3+
"type": "module"
4+
}

.core/.cli/commands/reactium/component/reactium-arcli.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
const componentGen = require('./componentGen');
2-
3-
const formatRoute = require('./formatRoute');
4-
const formatDestination = require('./formatDestination');
5-
const selectDestination = require('./selectDestination');
6-
const { selectStyle, styleTypes } = require('./selectStyle');
7-
8-
const camelcase = require('camelcase');
9-
1+
import formatRoute from './formatRoute.cjs';
2+
import componentGen from './componentGen.cjs';
3+
import formatDestination from './formatDestination.cjs';
4+
import selectDestination from './selectDestination.cjs';
5+
import selectStyleDefault from './selectStyle.cjs';
6+
import camelcase from 'camelcase';
7+
8+
const { selectStyle, styleTypes } = selectStyleDefault;
109
const { _, chalk, prefix, Reactium } = arcli;
1110

1211
const cc = str => camelcase(str, { pascalCase: true });

.core/.cli/commands/reactium/component/selectStyle.js renamed to .core/.cli/commands/reactium/component/selectStyle.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { _, chalk, prefix } = arcli;
22
const suffix = chalk.magenta(': ');
3-
const styleTypes = require('./styleTypes');
3+
const styleTypes = require('./styleTypes.cjs');
44

55
const selectStyle = props => ({
66
prefix,

.core/.cli/commands/reactium/domain/index.js

+17-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
arcli.Reactium = require('@atomic-reactor/reactium-sdk-core').default;
2-
3-
const { ActionSequence, ora, path, Reactium } = arcli;
1+
import Reactium from '@atomic-reactor/reactium-sdk-core';
2+
const { ActionSequence, ora, path } = arcli;
43

54
const ENUMS = {
65
CANCELED: 'domain canceled!',
@@ -26,19 +25,19 @@ Example:
2625

2726
const ACTION = async ({ opt, props }) => {
2827
// load hooks
29-
arcli
30-
.globby(
31-
[
32-
'./.core/**/reactium-arcli.js',
33-
'./src/**/reactium-arcli.js',
34-
'./reactium_modules/**/reactium-arcli.js',
35-
'./node_modules/**/reactium-arcli.js',
36-
],
37-
{
38-
dot: true,
39-
},
40-
)
41-
.forEach(file => require(path.resolve(file)));
28+
for (const file of arcli.globby(
29+
[
30+
'./.core/**/reactium-arcli.js',
31+
'./src/**/reactium-arcli.js',
32+
'./reactium_modules/**/reactium-arcli.js',
33+
'./node_modules/**/reactium-arcli.js',
34+
],
35+
{
36+
dot: true,
37+
},
38+
)) {
39+
await import(path.resolve(file));
40+
}
4241

4342
let params = arcli.flagsToParams({ opt, flags: Object.keys(ENUMS.FLAGS) });
4443

@@ -118,7 +117,7 @@ const ACTION = async ({ opt, props }) => {
118117
});
119118
};
120119

121-
const COMMAND = ({ program, props }) => {
120+
export const COMMAND = ({ program, props }) => {
122121
program
123122
.command(ENUMS.NAME)
124123
.description(ENUMS.DESC)
@@ -136,7 +135,4 @@ const COMMAND = ({ program, props }) => {
136135
return program;
137136
};
138137

139-
module.exports = {
140-
COMMAND,
141-
NAME: ENUMS.NAME,
142-
};
138+
export const NAME = ENUMS.NAME;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "reactium-domain-cmd",
3+
"type": "module"
4+
}

.core/.cli/commands/reactium/domain/reactium-arcli.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const componentGen = require('../component/componentGen');
2-
const selectDestination = require('../component/selectDestination');
3-
const formatDestination = require('../component/formatDestination');
1+
import componentGen from '../component/componentGen.cjs';
2+
import formatDestination from '../component/formatDestination.cjs';
3+
import selectDestination from '../component/selectDestination.cjs';
44

55
const { _, chalk, path, prefix, Reactium } = arcli;
66

.core/.cli/commands/reactium/hook/index.js

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
arcli.Reactium = require('@atomic-reactor/reactium-sdk-core').default;
1+
import Reactium from '@atomic-reactor/reactium-sdk-core';
22

3-
const { ActionSequence, ora, path, Reactium } = arcli;
3+
const { ActionSequence, ora, path } = arcli;
44

55
const ENUMS = {
66
CANCELED: 'hook canceled!',
@@ -26,19 +26,19 @@ Example:
2626

2727
const ACTION = async ({ opt, props }) => {
2828
// load hooks
29-
arcli
30-
.globby(
31-
[
32-
'./.core/**/reactium-arcli.js',
33-
'./src/**/reactium-arcli.js',
34-
'./reactium_modules/**/reactium-arcli.js',
35-
'./node_modules/**/reactium-arcli.js',
36-
],
37-
{
38-
dot: true,
39-
},
40-
)
41-
.forEach(file => require(path.resolve(file)));
29+
for (const file of arcli.globby(
30+
[
31+
'./.core/**/reactium-arcli.js',
32+
'./src/**/reactium-arcli.js',
33+
'./reactium_modules/**/reactium-arcli.js',
34+
'./node_modules/**/reactium-arcli.js',
35+
],
36+
{
37+
dot: true,
38+
},
39+
)) {
40+
await import(path.resolve(file));
41+
}
4242

4343
let params = arcli.flagsToParams({ opt, flags: Object.keys(ENUMS.FLAGS) });
4444

@@ -118,7 +118,7 @@ const ACTION = async ({ opt, props }) => {
118118
});
119119
};
120120

121-
const COMMAND = ({ program, props }) => {
121+
export const COMMAND = ({ program, props }) => {
122122
program
123123
.command(ENUMS.NAME)
124124
.description(ENUMS.DESC)
@@ -136,7 +136,4 @@ const COMMAND = ({ program, props }) => {
136136
return program;
137137
};
138138

139-
module.exports = {
140-
COMMAND,
141-
NAME: ENUMS.NAME,
142-
};
139+
export const NAME = ENUMS.NAME;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "reactium-hook-cmd",
3+
"type": "module"
4+
}

.core/.cli/commands/reactium/hook/reactium-arcli.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const componentGen = require('../component/componentGen');
2-
const selectDestination = require('../component/selectDestination');
3-
const formatDestination = require('../component/formatDestination');
1+
import componentGen from '../component/componentGen.cjs';
2+
import formatDestination from '../component/formatDestination.cjs';
3+
import selectDestination from '../component/selectDestination.cjs';
44

55
const { _, chalk, path, prefix, Reactium } = arcli;
66

.core/.cli/commands/reactium/icons/actions.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import hb from 'handlebars';
44
import cc from 'camelcase';
55
import op from 'object-path';
66
import path from 'node:path';
7+
import { dirname } from '@atomic-reactor/dirname';
78

8-
// import { fileURLToPath } from 'node:url';
9-
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
10-
11-
import dirname from '../dirname.mjs';
129
const __dirname = dirname(import.meta.url);
1310

1411
const handlebars = hb.compile;

0 commit comments

Comments
 (0)