@magidoc/cli
Advanced tools
Comparing version 0.14.2 to 0.15.0
@@ -6,2 +6,3 @@ import { Option } from 'commander'; | ||
import chalk from 'chalk'; | ||
import { PACKAGE_MANAGER_TYPES } from '../../node/packageManager.js'; | ||
@@ -14,5 +15,6 @@ const DEFAULT_CONFIG_FILE = './magidoc.mjs'; | ||
.addOption(new Option('-f|--file <file.js|file.mjs|file.cjs>', 'The magidoc configuration file location. By default, Magidoc looks for an ESModule Javascript file (mjs), but cjs is supported as well.').default(DEFAULT_CONFIG_FILE)) | ||
.addOption(new Option('-p|--package-manager <package-manager>', 'Selects a different Package Manager. By default, Magidoc will try to use any package manager available in order of preference. Recommended is pnpm.').choices(PACKAGE_MANAGER_TYPES)) | ||
.addOption(new Option('-c|--clean', 'Clean install, so delete the local copy of the template if there is one and fetch it again.').default(false)) | ||
.addOption(new Option('-s|--stacktrace', 'Useful to debug errors. Will print the whole exception to the terminal in case the error message is not precise enough.').default(false)) | ||
.action(async ({ file, stacktrace, clean }) => { | ||
.action(async ({ packageManager, file, stacktrace, clean, }) => { | ||
const fileConfiguration = await loadFileConfiguration(file); | ||
@@ -26,2 +28,3 @@ if (!fileConfiguration) { | ||
...fileConfiguration, | ||
packageManager, | ||
clean, | ||
@@ -28,0 +31,0 @@ }); |
@@ -0,4 +1,6 @@ | ||
import type { PackageManagerType } from '../../node/packageManager'; | ||
import type { MagidocConfiguration } from './config/types'; | ||
export declare type GenerationConfig = MagidocConfiguration & { | ||
packageManager?: PackageManagerType; | ||
clean: boolean; | ||
}; |
@@ -9,13 +9,13 @@ import z from 'zod'; | ||
}, "strip", z.ZodTypeAny, { | ||
query?: string | undefined; | ||
headers?: Record<string, string> | undefined; | ||
type: "url"; | ||
url: string; | ||
query?: string | undefined; | ||
method: "GET" | "POST" | "PUT" | "DELETE"; | ||
headers?: Record<string, string> | undefined; | ||
}, { | ||
type: "url"; | ||
url: string; | ||
query?: string | undefined; | ||
method?: "GET" | "POST" | "PUT" | "DELETE" | undefined; | ||
headers?: Record<string, string> | undefined; | ||
type: "url"; | ||
url: string; | ||
}> | z.ZodObject<{ | ||
@@ -55,11 +55,11 @@ type: z.ZodLiteral<"sdl">; | ||
}, "strip", z.ZodTypeAny, { | ||
options: Record<string, unknown>; | ||
template: "carbon-multi-page"; | ||
templateVersion: string; | ||
output: string; | ||
options: Record<string, unknown>; | ||
}, { | ||
template: "carbon-multi-page"; | ||
templateVersion?: string | undefined; | ||
output?: string | undefined; | ||
options: Record<string, unknown>; | ||
template: "carbon-multi-page"; | ||
}>; | ||
@@ -74,13 +74,13 @@ export declare const ZMagidocConfiguration: z.ZodObject<{ | ||
}, "strip", z.ZodTypeAny, { | ||
query?: string | undefined; | ||
headers?: Record<string, string> | undefined; | ||
type: "url"; | ||
url: string; | ||
query?: string | undefined; | ||
method: "GET" | "POST" | "PUT" | "DELETE"; | ||
headers?: Record<string, string> | undefined; | ||
}, { | ||
type: "url"; | ||
url: string; | ||
query?: string | undefined; | ||
method?: "GET" | "POST" | "PUT" | "DELETE" | undefined; | ||
headers?: Record<string, string> | undefined; | ||
type: "url"; | ||
url: string; | ||
}> | z.ZodObject<{ | ||
@@ -120,19 +120,19 @@ type: z.ZodLiteral<"sdl">; | ||
}, "strip", z.ZodTypeAny, { | ||
options: Record<string, unknown>; | ||
template: "carbon-multi-page"; | ||
templateVersion: string; | ||
output: string; | ||
options: Record<string, unknown>; | ||
}, { | ||
template: "carbon-multi-page"; | ||
templateVersion?: string | undefined; | ||
output?: string | undefined; | ||
options: Record<string, unknown>; | ||
template: "carbon-multi-page"; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
introspection: { | ||
query?: string | undefined; | ||
headers?: Record<string, string> | undefined; | ||
type: "url"; | ||
url: string; | ||
query?: string | undefined; | ||
method: "GET" | "POST" | "PUT" | "DELETE"; | ||
headers?: Record<string, string> | undefined; | ||
} | { | ||
@@ -149,14 +149,14 @@ type: "sdl"; | ||
website: { | ||
options: Record<string, unknown>; | ||
template: "carbon-multi-page"; | ||
templateVersion: string; | ||
output: string; | ||
options: Record<string, unknown>; | ||
}; | ||
}, { | ||
introspection: { | ||
type: "url"; | ||
url: string; | ||
query?: string | undefined; | ||
method?: "GET" | "POST" | "PUT" | "DELETE" | undefined; | ||
headers?: Record<string, string> | undefined; | ||
type: "url"; | ||
url: string; | ||
} | { | ||
@@ -173,6 +173,6 @@ type: "sdl"; | ||
website: { | ||
template: "carbon-multi-page"; | ||
templateVersion?: string | undefined; | ||
output?: string | undefined; | ||
options: Record<string, unknown>; | ||
template: "carbon-multi-page"; | ||
}; | ||
@@ -179,0 +179,0 @@ }>; |
@@ -19,3 +19,3 @@ import { clean } from './tasks/clean.js'; | ||
clean(config), | ||
selectPackageManagerTask(), | ||
selectPackageManagerTask(config), | ||
fetchTemplateTask(config), | ||
@@ -22,0 +22,0 @@ unzipTemplateTask(), |
import { GenerateTask } from '../task'; | ||
export declare function selectPackageManagerTask(): GenerateTask; | ||
import type { GenerationConfig } from '../config'; | ||
export declare function selectPackageManagerTask(config: GenerationConfig): GenerateTask; |
import { newTask } from '../task.js'; | ||
import { selectPackageManager } from '../../../node/packageManager.js'; | ||
import { getPackageManager, selectPackageManager } from '../../../node/packageManager.js'; | ||
function selectPackageManagerTask() { | ||
function selectPackageManagerTask(config) { | ||
return newTask({ | ||
title: 'Select Package Manager', | ||
executor: async (ctx, task) => { | ||
ctx.packageManager = await selectPackageManager(); | ||
if (config.packageManager) { | ||
ctx.packageManager = getPackageManager(config.packageManager); | ||
} | ||
else { | ||
ctx.packageManager = await selectPackageManager(); | ||
} | ||
task.output = `Selected ${ctx.packageManager.type}`; | ||
@@ -10,0 +15,0 @@ }, |
@@ -5,3 +5,3 @@ { | ||
"private": false, | ||
"version": "0.14.2", | ||
"version": "0.15.0", | ||
"type": "module", | ||
@@ -20,5 +20,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"@magidoc/plugin-starter-variables": "^0.14.2", | ||
"@magidoc/rollup-plugin-fetch-gql-schema": "^0.14.2", | ||
"@magidoc/rollup-plugin-parse-gql-schema": "^0.14.2", | ||
"@magidoc/plugin-starter-variables": "^0.15.0", | ||
"@magidoc/rollup-plugin-fetch-gql-schema": "^0.15.0", | ||
"@magidoc/rollup-plugin-parse-gql-schema": "^0.15.0", | ||
"axios": "^0.27.2", | ||
@@ -32,3 +32,3 @@ "chalk": "^5.0.1", | ||
"sirv": "^2.0.2", | ||
"zod": "^3.15.1" | ||
"zod": "^3.16.0" | ||
}, | ||
@@ -38,9 +38,9 @@ "devDependencies": { | ||
"@types/fs-extra": "^9.0.13", | ||
"@types/jest": "^27.5.0", | ||
"@types/jest": "^27.5.1", | ||
"@types/lodash": "^4.14.182", | ||
"jest": "^28.1.0", | ||
"jest-extended": "^2.0.0", | ||
"rollup": "^2.72.0", | ||
"rollup": "^2.72.1", | ||
"rollup-plugin-preserve-shebang": "^1.0.1", | ||
"ts-jest": "^28.0.1", | ||
"ts-jest": "^28.0.2", | ||
"tslib": "^2.4.0", | ||
@@ -47,0 +47,0 @@ "typescript": "^4.6.4" |
@@ -7,5 +7,10 @@ import { Command, Option } from 'commander' | ||
import type { MagidocConfiguration } from './config/types' | ||
import { | ||
PackageManagerType, | ||
PACKAGE_MANAGER_TYPES, | ||
} from '../../node/packageManager' | ||
type GenerateCommandOptions = { | ||
file: string | ||
packageManager?: PackageManagerType | ||
stacktrace: boolean | ||
@@ -31,2 +36,8 @@ clean: boolean | ||
new Option( | ||
'-p|--package-manager <package-manager>', | ||
'Selects a different Package Manager. By default, Magidoc will try to use any package manager available in order of preference. Recommended is pnpm.', | ||
).choices(PACKAGE_MANAGER_TYPES), | ||
) | ||
.addOption( | ||
new Option( | ||
'-c|--clean', | ||
@@ -42,18 +53,26 @@ 'Clean install, so delete the local copy of the template if there is one and fetch it again.', | ||
) | ||
.action(async ({ file, stacktrace, clean }: GenerateCommandOptions) => { | ||
const fileConfiguration = await loadFileConfiguration(file) | ||
if (!fileConfiguration) { | ||
process.exitCode = 1 | ||
return | ||
} | ||
.action( | ||
async ({ | ||
packageManager, | ||
file, | ||
stacktrace, | ||
clean, | ||
}: GenerateCommandOptions) => { | ||
const fileConfiguration = await loadFileConfiguration(file) | ||
if (!fileConfiguration) { | ||
process.exitCode = 1 | ||
return | ||
} | ||
await withStacktrace(stacktrace, async () => { | ||
await generate({ | ||
...fileConfiguration, | ||
clean, | ||
await withStacktrace(stacktrace, async () => { | ||
await generate({ | ||
...fileConfiguration, | ||
packageManager, | ||
clean, | ||
}) | ||
printPostExecution(file, fileConfiguration) | ||
}) | ||
printPostExecution(file, fileConfiguration) | ||
}) | ||
}) | ||
}, | ||
) | ||
} | ||
@@ -60,0 +79,0 @@ |
@@ -0,5 +1,7 @@ | ||
import type { PackageManagerType } from '../../node/packageManager' | ||
import type { MagidocConfiguration } from './config/types' | ||
export type GenerationConfig = MagidocConfiguration & { | ||
packageManager?: PackageManagerType | ||
clean: boolean | ||
} |
@@ -20,3 +20,3 @@ import { clean as cleanTask } from './tasks/clean' | ||
cleanTask(config), | ||
selectPackageManagerTask(), | ||
selectPackageManagerTask(config), | ||
fetchTemplateTask(config), | ||
@@ -23,0 +23,0 @@ unzipTemplateTask(), |
import { newTask, GenerateTask } from '../task' | ||
import { selectPackageManager } from '../../../node/packageManager' | ||
import { | ||
getPackageManager, | ||
selectPackageManager, | ||
} from '../../../node/packageManager' | ||
import type { GenerationConfig } from '../config' | ||
export function selectPackageManagerTask(): GenerateTask { | ||
export function selectPackageManagerTask( | ||
config: GenerationConfig, | ||
): GenerateTask { | ||
return newTask({ | ||
title: 'Select Package Manager', | ||
executor: async (ctx, task) => { | ||
ctx.packageManager = await selectPackageManager() | ||
if (config.packageManager) { | ||
ctx.packageManager = getPackageManager(config.packageManager) | ||
} else { | ||
ctx.packageManager = await selectPackageManager() | ||
} | ||
task.output = `Selected ${ctx.packageManager.type}` | ||
@@ -10,0 +21,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132604
2676
+ Added@magidoc/plugin-starter-variables@0.15.1(transitive)
+ Added@magidoc/rollup-plugin-fetch-gql-schema@0.15.1(transitive)
+ Added@magidoc/rollup-plugin-parse-gql-schema@0.15.1(transitive)
- Removed@magidoc/plugin-starter-variables@0.14.2(transitive)
- Removed@magidoc/rollup-plugin-fetch-gql-schema@0.14.2(transitive)
- Removed@magidoc/rollup-plugin-parse-gql-schema@0.14.2(transitive)
Updatedzod@^3.16.0