@stacksjs/actions 0.72.77 → 0.72.79
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/dist/make-command.js +27 -36
- package/package.json +20 -20
package/dist/make-command.js
CHANGED
|
@@ -1,44 +1,35 @@
|
|
|
1
|
-
import{log}from"@stacksjs/logging";import*as p from"@stacksjs/path";import{get,writeFile}from"@stacksjs/storage";export async function makeCommand(options){const name=options.name;if(!name){log.error("Command name is required");return!1}const commandName=toPascalCase(name),content=generateCommandContent(commandName,options),filePath=p.commandsPath(`${commandName}.ts`);try{await writeFile(filePath,content);log.success(`Created command: ${filePath}`);if(options.register
|
|
2
|
-
import { log } from '@stacksjs/cli'
|
|
1
|
+
import{log}from"@stacksjs/logging";import*as p from"@stacksjs/path";import{get,writeFile}from"@stacksjs/storage";export async function makeCommand(options){const name=options.name;if(!name){log.error("Command name is required");return!1}const commandName=toPascalCase(name),content=generateCommandContent(commandName,options),filePath=p.commandsPath(`${commandName}.ts`),signature=options.signature||toKebabCase(name);try{await writeFile(filePath,content);log.success(`Created command: ${filePath}`);if(options.register)await registerCommand(commandName,signature);else log.info(`Run it with: buddy ${signature}`);return!0}catch(error){log.error(`Failed to create command: ${error.message}`);return!1}}function generateCommandContent(name,options){const signature=options.signature||toKebabCase(name),description=options.description||`The ${signature} command`;return`import { defineCommand, log } from '@stacksjs/cli'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* ${name} Command
|
|
6
5
|
*
|
|
7
6
|
* ${description}
|
|
7
|
+
*
|
|
8
|
+
* Registered automatically - every file in app/Commands is a command.
|
|
8
9
|
*/
|
|
10
|
+
export default defineCommand({
|
|
11
|
+
name: '${signature}',
|
|
12
|
+
description: '${description}',
|
|
13
|
+
options: {
|
|
14
|
+
'--verbose': { description: 'Enable verbose output', default: false },
|
|
15
|
+
// Add more options here. Their types flow into \`handle\`:
|
|
16
|
+
// '--name <name>': 'Who to greet',
|
|
17
|
+
},
|
|
18
|
+
async handle(options) {
|
|
19
|
+
try {
|
|
20
|
+
if (options.verbose)
|
|
21
|
+
log.info('Running ${signature} command...')
|
|
9
22
|
|
|
10
|
-
|
|
11
|
-
verbose: boolean
|
|
12
|
-
// Add your command options here
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default function (cli: CLI) {
|
|
16
|
-
cli
|
|
17
|
-
.command('${signature}', '${description}')
|
|
18
|
-
.option('--verbose', 'Enable verbose output', { default: false })
|
|
19
|
-
// Add more options here
|
|
20
|
-
// .option('-n, --name <name>', 'Your name')
|
|
21
|
-
.action(async (options: ${name}Options) => {
|
|
22
|
-
try {
|
|
23
|
-
if (options.verbose) {
|
|
24
|
-
log.info('Running ${signature} command...')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
log.info('No command logic implemented yet. Update this command action to add behavior.')
|
|
28
|
-
|
|
29
|
-
log.success('${signature} completed successfully!')
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
log.error('${signature} failed:', error)
|
|
33
|
-
throw error
|
|
34
|
-
}
|
|
35
|
-
})
|
|
23
|
+
log.info('No command logic implemented yet. Update this command to add behavior.')
|
|
36
24
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
log.success('${signature} completed successfully!')
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
log.error('${signature} failed:', error)
|
|
29
|
+
throw error
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
`}async function registerCommand(name,signature){const commandsPath=p.appPath("Commands.ts"),patterns=[{match:/export default \{([\s\S]*)\} satisfies/,open:"export default {",close:"} satisfies"},{match:/export default defineCommands\(\{([\s\S]*)\}\)/,open:"export default defineCommands({",close:"})"}];try{const content=await get(commandsPath),pattern=patterns.find((candidate)=>candidate.match.test(content));if(!pattern){log.info(`Command '${signature}' is live without a registry entry.`);return}const existingCommands=content.match(pattern.match)?.[1]??"";if(existingCommands.includes(`'${signature}'`)){log.info(`Command '${signature}' already registered in Commands.ts`);return}const updatedCommands=`${existingCommands.trimEnd()}
|
|
34
|
+
'${signature}': '${name}',
|
|
35
|
+
`;await writeFile(commandsPath,content.replace(pattern.match,`${pattern.open}${updatedCommands}${pattern.close}`));log.success(`Registered command '${signature}' in Commands.ts`)}catch{log.info(`Command '${signature}' is live without a registry entry.`)}}function toPascalCase(str){return str.replace(/[-_](.)/g,(_,char)=>char.toUpperCase()).replace(/^(.)/,(_,char)=>char.toUpperCase())}function toKebabCase(str){return str.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.72.
|
|
5
|
+
"version": "0.72.79",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -60,35 +60,35 @@
|
|
|
60
60
|
"prepublishOnly": "bun run build"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@stacksjs/config": "0.72.
|
|
63
|
+
"@stacksjs/config": "0.72.79",
|
|
64
64
|
"@stacksjs/bumpx": "^0.2.6",
|
|
65
65
|
"@stacksjs/bunpress": "^0.2.8",
|
|
66
66
|
"@stacksjs/logsmith": "^0.2.3",
|
|
67
|
-
"@stacksjs/registry": "0.72.
|
|
67
|
+
"@stacksjs/registry": "0.72.79",
|
|
68
68
|
"@stacksjs/stx": "^0.2.230",
|
|
69
69
|
"@stacksjs/ts-cloud": "^0.12.4",
|
|
70
70
|
"@stacksjs/ts-md": "^0.1.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@stacksjs/api": "0.72.
|
|
74
|
-
"@stacksjs/cli": "0.72.
|
|
75
|
-
"@stacksjs/database": "0.72.
|
|
73
|
+
"@stacksjs/api": "0.72.79",
|
|
74
|
+
"@stacksjs/cli": "0.72.79",
|
|
75
|
+
"@stacksjs/database": "0.72.79",
|
|
76
76
|
"@stacksjs/tlsx": "^0.13.2",
|
|
77
77
|
"better-dx": "^0.2.24",
|
|
78
|
-
"@stacksjs/dns": "0.72.
|
|
79
|
-
"@stacksjs/enums": "0.72.
|
|
80
|
-
"@stacksjs/env": "0.72.
|
|
81
|
-
"@stacksjs/error-handling": "0.72.
|
|
82
|
-
"@stacksjs/image": "0.72.
|
|
83
|
-
"@stacksjs/logging": "0.72.
|
|
84
|
-
"@stacksjs/path": "0.72.
|
|
85
|
-
"@stacksjs/security": "0.72.
|
|
86
|
-
"@stacksjs/cms": "0.72.
|
|
87
|
-
"@stacksjs/sites": "0.72.
|
|
88
|
-
"@stacksjs/storage": "0.72.
|
|
89
|
-
"@stacksjs/strings": "0.72.
|
|
90
|
-
"@stacksjs/utils": "0.72.
|
|
91
|
-
"@stacksjs/validation": "0.72.
|
|
78
|
+
"@stacksjs/dns": "0.72.79",
|
|
79
|
+
"@stacksjs/enums": "0.72.79",
|
|
80
|
+
"@stacksjs/env": "0.72.79",
|
|
81
|
+
"@stacksjs/error-handling": "0.72.79",
|
|
82
|
+
"@stacksjs/image": "0.72.79",
|
|
83
|
+
"@stacksjs/logging": "0.72.79",
|
|
84
|
+
"@stacksjs/path": "0.72.79",
|
|
85
|
+
"@stacksjs/security": "0.72.79",
|
|
86
|
+
"@stacksjs/cms": "0.72.79",
|
|
87
|
+
"@stacksjs/sites": "0.72.79",
|
|
88
|
+
"@stacksjs/storage": "0.72.79",
|
|
89
|
+
"@stacksjs/strings": "0.72.79",
|
|
90
|
+
"@stacksjs/utils": "0.72.79",
|
|
91
|
+
"@stacksjs/validation": "0.72.79"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"pickier": "^0.1.58",
|