summaryrefslogtreecommitdiff
path: root/packages/create-astro/src/config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/create-astro/src/config.ts')
-rw-r--r--packages/create-astro/src/config.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/create-astro/src/config.ts b/packages/create-astro/src/config.ts
new file mode 100644
index 000000000..3d3c07912
--- /dev/null
+++ b/packages/create-astro/src/config.ts
@@ -0,0 +1,49 @@
+import type * as arg from 'arg';
+
+export interface ARG {
+ type: any;
+ description: string;
+ enum?: string[];
+ alias?: string;
+}
+
+export const ARGS: Record<string, ARG> = {
+ 'template': {
+ type: String,
+ description: 'specifies template to use'
+ },
+ 'use': {
+ type: String,
+ enum: ['npm', 'yarn'],
+ description: 'specifies package manager to use'
+ },
+ 'run': {
+ type: Boolean,
+ description: 'should dependencies be installed automatically?'
+ },
+ 'force': {
+ type: Boolean,
+ alias: 'f',
+ description: 'should existing files be overwritten?'
+ },
+ 'version': {
+ type: Boolean,
+ alias: 'v',
+ description: 'prints current version'
+ },
+ 'help': {
+ type: Boolean,
+ alias: 'h',
+ description: 'prints this message'
+ }
+}
+
+export const args = Object.entries(ARGS).reduce((acc, [name, info]) => {
+ const key = `--${name}`;
+ const spec = { ...acc, [key]: info.type };
+
+ if (info.alias) {
+ spec[`-${info.alias}`] = key;
+ }
+ return spec
+}, {} as arg.Spec);