Skip to content

Commit b0d18f7

Browse files
authored
feat: including xanoscript into the repo generation, minor docs updates (#145)
2 parents fa07980 + 574beeb commit b0d18f7

File tree

15 files changed

+127
-36
lines changed

15 files changed

+127
-36
lines changed

.changeset/calm-sheep-rest.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@calycode/core": patch
3+
"@calycode/cli": patch
4+
---
5+
6+
chore: updating and expanding on the documentation of each command

.changeset/fuzzy-bushes-battle.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@calycode/core": patch
3+
"@calycode/cli": patch
4+
---
5+
6+
feat: including xanoscript in the main repository generation (tables, functions, apis)

packages/cli/src/commands/backups.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ function registerExportBackupCommand(program, core) {
150150
function registerRestoreBackupCommand(program, core) {
151151
const cmd = program
152152
.command('restore-backup')
153-
.description('Restore a backup to a Xano Workspace via Metadata API');
153+
.description('Restore a backup to a Xano Workspace via Metadata API. DANGER! This action will override all business logic and restore the original v1 branch. Data will be also restored from the backup file.');
154154

155155
addPartialContextOptions(cmd);
156156

157-
cmd.option('--source-backup <file>', 'Path to the backup file to restore')
158-
.option('--force', 'Force restoration without confirmation')
157+
cmd.option('-S, --source-backup <file>', 'Local path to the backup file to restore.')
158+
.option('--force', 'Force restoration without confirmation, not advised to be specified, useful when ran from a CI/CD pipeline and consequences are acknowledged.')
159159
.action(
160160
withErrorHandler(async (options) => {
161161
await restorationWizard({

packages/cli/src/commands/generate-code.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from '../utils/index';
1313
import { runOpenApiGenerator } from '../features/code-gen/open-api-generator';
1414

15-
// [ ] CLI only feature
1615
async function generateCodeFromOas({
1716
instance,
1817
workspace,
@@ -131,7 +130,7 @@ function registerGenerateCodeCommand(program, core) {
131130
)
132131
.option(
133132
'--args <args>',
134-
'Additional arguments to pass to the generator. See https://openapi-generator.tech/docs/usage#generate'
133+
'Additional arguments to pass to the generator. For options for each generator see https://openapi-generator.tech/docs/usage#generate'
135134
)
136135
.option(
137136
'--debug',

packages/cli/src/commands/generate-oas.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ async function updateOasWizard({
6969
for (const { group, generatedItems } of allGroupResults) {
7070
const apiGroupNameNorm = normalizeApiGroupName(group);
7171

72-
// [x] This is going to be relative to the working dir, but we have to force the structure...
7372
const outputPath = replacePlaceholders(instanceConfig.openApiSpec.output, {
7473
'@': await findProjectRoot(),
7574
instance: instanceConfig.name,
@@ -96,7 +95,7 @@ async function updateOasWizard({
9695
function registerGenerateOasCommand(program, core) {
9796
const cmd = program
9897
.command('generate-oas')
99-
.description('Update and generate OpenAPI spec(s) for the current context.');
98+
.description('Update and generate OpenAPI spec(s) for the current context, or all API groups simultaneously. This generates an opinionated API documentation powered by Scalar API Reference. + this command brings the Swagger docs to OAS 3.1+ version.');
10099

101100
addFullContextOptions(cmd);
102101
addApiGroupOptions(cmd);

packages/cli/src/commands/generate-repo.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ async function generateRepo({
100100
const fileContents = await core.storage.readFile(inputFile, 'utf8');
101101
const jsonData = load(fileContents);
102102

103-
const plannedWrites: { path: string; content: string }[] = await core.generateRepo(jsonData);
103+
const plannedWrites: { path: string; content: string }[] = await core.generateRepo({
104+
jsonData,
105+
instance: instanceConfig.name,
106+
workspace: workspaceConfig.name,
107+
branch: branchConfig.label,
108+
});
104109
log.step(`Writing Repository to the output directory -> ${outputDir}`);
105110
await Promise.all(
106111
plannedWrites.map(async ({ path, content }) => {
@@ -120,14 +125,14 @@ async function generateRepo({
120125
function registerGenerateRepoCommand(program, core) {
121126
const cmd = program
122127
.command('generate-repo')
123-
.description('Process Xano workspace into repo structure')
124-
.option('--input <file>', 'workspace yaml file')
125-
.option('--output <dir>', 'output directory (overrides config)');
128+
.description('Process Xano workspace into repo structure. We use the export-schema metadata API to offer the full details. However that is enriched with the Xanoscripts after Xano 2.0 release.')
129+
.option('-I, --input <file>', 'Workspace yaml file from a local source, if present.')
130+
.option('-O, --output <dir>', 'Output directory (overrides default config), useful when ran from a CI/CD pipeline and want to ensure consistent output location.');
126131

127132
addFullContextOptions(cmd);
128133
addPrintOutputFlag(cmd);
129134

130-
cmd.option('--fetch', 'Specify this if you want to fetch the workspace schema from Xano').action(
135+
cmd.option('-F, --fetch', 'Forces fetching the workspace schema from the Xano instance via metadata API.').action(
131136
withErrorHandler(async (opts) => {
132137
await generateRepo({
133138
instance: opts.instance,

packages/cli/src/commands/generate-xanoscript-repo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function generateXanoscriptRepo({ instance, workspace, branch, core, print
8282
function registerBuildXanoscriptRepoCommand(program, core) {
8383
const cmd = program
8484
.command('generate-xs-repo')
85-
.description('Process Xano workspace into repo structure');
85+
.description('Process Xano workspace into repo structure. Supports table, function and apis as of know. Xano VSCode extension is the preferred solution over this command. Outputs of this process are also included in the default repo generation command.');
8686

8787
addFullContextOptions(cmd);
8888
addPrintOutputFlag(cmd);

packages/cli/src/commands/registry.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ async function installComponentToXano(file, resolvedContext, core) {
127127
function registerRegistryAddCommand(program, core) {
128128
const cmd = program
129129
.command('registry-add')
130-
.description('Add a prebuilt component to the current Xano context.');
130+
.description(
131+
'Add a prebuilt component to the current Xano context, essentially by pushing an item from the registry to the Xano instance.'
132+
);
131133

132134
addFullContextOptions(cmd);
133135
cmd.option('--components', 'Comma-separated list of components to add')
@@ -160,7 +162,7 @@ function registerRegistryScaffoldCommand(program, core) {
160162
.description(
161163
'Scaffold a Xano registry folder with a sample component. Xano registry can be used to share and reuse prebuilt components. In the registry you have to follow the [registry](https://calycode.com/schemas/registry/registry.json) and [registry item](https://calycode.com/schemas/registry/registry-item.json) schemas.'
162164
)
163-
.option('--output <path>', 'Output path for the registry')
165+
.option('--output <path>', 'Local output path for the registry')
164166
.option(
165167
'--instance <instance>',
166168
'The instance name. This is used to fetch the instance configuration. The value provided at the setup command.'

packages/cli/src/commands/run-tests.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,18 @@ ${'-'.repeat(60)}`
128128
);
129129
}
130130

131-
// [ ] CLI
132131
function registerRunTestCommand(program, core) {
133132
const cmd = program
134133
.command('run-test')
135-
.description('Run an API test suite via the OpenAPI spec. WIP...');
134+
.description(
135+
'Run an API test suite via the OpenAPI spec. To execute this command a specification is required. Find the schema here: https://calycode.com/schemas/testing/config.json '
136+
);
136137

137138
addFullContextOptions(cmd);
138139
addApiGroupOptions(cmd);
139140
addPrintOutputFlag(cmd);
140141

141-
cmd.option('--test-config-path <path>', 'Path to a test configuration file.').action(
142+
cmd.option('--test-config-path <path>', 'Local path to the test configuration file.').action(
142143
withErrorHandler(async (options) => {
143144
await runTest({
144145
...options,

packages/cli/src/commands/serve.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ function registerRegistryServeCommand(program) {
8484
program
8585
.command('serve-registry')
8686
.description(
87-
'Serve the registry locally. This allows you to actually use your registry without deploying it.'
87+
'Serve the registry locally. This allows you to actually use your registry without deploying it to any remote host.'
8888
)
89-
.option('--root <path>', 'Where did you put your registry?')
89+
.option('--root <path>', 'Where did you put your registry? (Local path to the registry directory)')
9090
.option(
9191
'--listen <port>',
9292
'The port where you want your registry to be served locally. By default it is 5000.'
@@ -104,7 +104,7 @@ function registerRegistryServeCommand(program) {
104104
function registerOasServeCommand(program, core) {
105105
const cmd = program
106106
.command('serve-oas')
107-
.description('Serve the Open API specification locally for quick visual check.');
107+
.description('Serve the Open API specification locally for quick visual check, or to test your APIs via the Scalar API reference.');
108108
addFullContextOptions(cmd);
109109
addApiGroupOptions(cmd);
110110
cmd.option(

0 commit comments

Comments
 (0)