@docs.page/cli
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -85,2 +85,3 @@ #!/usr/bin/env node | ||
import chalk2 from "chalk"; | ||
import { confirm } from "@inquirer/prompts"; | ||
function registerInitCommand(program2) { | ||
@@ -90,14 +91,28 @@ program2.command("init").description("Initializes new docs.page files").argument("[path]", "Path to the relative directory to initilize in.").action((input, o) => __async(this, null, function* () { | ||
const absolutePath = path2.resolve(relativePath); | ||
if (!fs2.existsSync(absolutePath)) { | ||
console.log( | ||
chalk2.red( | ||
`Directory "${chalk2.yellow(absolutePath)}" does not exist.` | ||
) | ||
); | ||
const confirmSetup = yield confirm({ | ||
message: `Are you sure you want to setup and install docs.page in ${chalk2.yellow( | ||
absolutePath | ||
)}?`, | ||
default: true | ||
}); | ||
if (!confirmSetup) { | ||
console.log(chalk2.red("Initialization cancelled.")); | ||
process.exit(1); | ||
} | ||
console.log(chalk2.green("Initializing docs.page files...")); | ||
let confirmOverwrite = false; | ||
if (fs2.existsSync(absolutePath)) { | ||
confirmOverwrite = yield confirm({ | ||
message: `Directory "${chalk2.yellow( | ||
absolutePath | ||
)}" already exists. Do you want to overwrite any existing files?`, | ||
default: true | ||
}); | ||
} | ||
if (!fs2.existsSync) { | ||
fs2.mkdirSync(absolutePath, { recursive: true }); | ||
} | ||
const configurationFilePath = path2.join(absolutePath, "docs.json"); | ||
const documentationPath = path2.join(absolutePath, "docs"); | ||
if (fs2.existsSync(configurationFilePath)) { | ||
const docsDirectoryExists = fs2.existsSync(documentationPath); | ||
if (fs2.existsSync(configurationFilePath) && !confirmOverwrite) { | ||
console.log( | ||
@@ -108,2 +123,11 @@ chalk2.red("Configuration file 'docs.json' already exists.") | ||
} | ||
if (docsDirectoryExists && !confirmOverwrite) { | ||
console.log( | ||
chalk2.red("Documentation directory 'docs/' already exists.") | ||
); | ||
process.exit(1); | ||
} | ||
if (!docsDirectoryExists) { | ||
fs2.mkdirSync(documentationPath, { recursive: true }); | ||
} | ||
const createdFiles = [ | ||
@@ -114,35 +138,23 @@ ` - ${chalk2.green( | ||
]; | ||
const docsDirectoryExists = fs2.existsSync(documentationPath); | ||
if (docsDirectoryExists) { | ||
console.log( | ||
chalk2.yellow( | ||
"A 'docs/' directory already exists, this command will not overwrite existing files." | ||
) | ||
); | ||
} else { | ||
fs2.mkdirSync(documentationPath, { recursive: true }); | ||
} | ||
fs2.writeFileSync( | ||
configurationFilePath, | ||
jsonConfiguration({ | ||
sidebar: !docsDirectoryExists | ||
sidebar: true | ||
}) | ||
); | ||
if (!docsDirectoryExists) { | ||
fs2.writeFileSync(path2.join(documentationPath, "index.mdx"), indexPage); | ||
createdFiles.push( | ||
` - ${chalk2.green( | ||
"docs/index.mdx" | ||
)}: The home page of your documentation site` | ||
); | ||
fs2.writeFileSync( | ||
path2.join(documentationPath, "next-steps.mdx"), | ||
nextStepsPage | ||
); | ||
createdFiles.push( | ||
` - ${chalk2.green( | ||
"docs/next-steps.mdx" | ||
)}: A page to help you get started with docs.page` | ||
); | ||
} | ||
fs2.writeFileSync(path2.join(documentationPath, "index.mdx"), indexPage); | ||
fs2.writeFileSync( | ||
path2.join(documentationPath, "next-steps.mdx"), | ||
nextStepsPage | ||
); | ||
createdFiles.push( | ||
` - ${chalk2.green( | ||
"docs/index.mdx" | ||
)}: The home page of your documentation site` | ||
); | ||
createdFiles.push( | ||
` - ${chalk2.green( | ||
"docs/next-steps.mdx" | ||
)}: A page to help you get started with docs.page` | ||
); | ||
console.log(chalk2.green("Files created:")); | ||
@@ -152,5 +164,4 @@ console.log(createdFiles.join("\n")); | ||
console.log( | ||
chalk2.green( | ||
"Initialization complete. To preview your documentation site, vist https://docs.page/preview in your browser." | ||
) | ||
chalk2.green("Initialization complete."), | ||
"To preview your documentation site, vist https://docs.page/preview in your browser." | ||
); | ||
@@ -157,0 +168,0 @@ })); |
{ | ||
"name": "@docs.page/cli", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"author": "Invertase <oss@invertase.io> (http://invertase.io)", | ||
@@ -32,2 +32,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@inquirer/prompts": "^5.3.8", | ||
"chalk": "^5.3.0", | ||
@@ -34,0 +35,0 @@ "commander": "^12.1.0", |
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
28640
440
4
+ Added@inquirer/prompts@^5.3.8
+ Added@inquirer/confirm@3.2.0(transitive)
+ Added@inquirer/core@9.2.1(transitive)
+ Added@inquirer/editor@2.2.0(transitive)
+ Added@inquirer/expand@2.3.0(transitive)
+ Added@inquirer/figures@1.0.8(transitive)
+ Added@inquirer/input@2.3.0(transitive)
+ Added@inquirer/number@1.1.0(transitive)
+ Added@inquirer/password@2.2.0(transitive)
+ Added@inquirer/prompts@5.5.0(transitive)
+ Added@inquirer/rawlist@2.3.0(transitive)
+ Added@inquirer/search@1.1.0(transitive)
+ Added@inquirer/select@2.5.0(transitive)
+ Added@inquirer/type@1.5.52.0.0(transitive)
+ Added@types/mute-stream@0.0.4(transitive)
+ Added@types/node@22.10.0(transitive)
+ Added@types/wrap-ansi@3.0.0(transitive)
+ Addedansi-escapes@4.3.2(transitive)
+ Addedchardet@0.7.0(transitive)
+ Addedcli-width@4.1.0(transitive)
+ Addedexternal-editor@3.1.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedmute-stream@1.0.0(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtype-fest@0.21.3(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedyoctocolors-cjs@2.1.2(transitive)