create-miradocs 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +15 -2
- package/bin/create-miradocs.js +20 -0
- package/lib/starter.js +23 -0
- package/package.json +28 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 miradocs contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-miradocs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create a documentation site with your own content, configuration, and theme styles.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm create miradocs@latest my-docs
|
|
7
|
+
cd my-docs
|
|
8
|
+
npm install
|
|
9
|
+
npm run dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
See [Installation](../../docs/01-getting-started/01-installation.md) for pnpm, Yarn, and Bun commands.
|
|
13
|
+
|
|
14
|
+
The starter creates `package.json`, `miradocs.config.json`, `docs/index.md`, `theme/tokens.css`, and `.gitignore`. The destination must be empty. miradocs is installed as a dependency.
|
|
15
|
+
|
|
16
|
+
Use `--install` to install dependencies after generation, `--title` to choose a site name, or `--miradocs-version` to use a local framework tarball.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {parseArgs} from 'node:util';
|
|
3
|
+
import {createInterface} from 'node:readline/promises';
|
|
4
|
+
import {spawn} from 'node:child_process';
|
|
5
|
+
import {createStarter} from '../lib/starter.js';
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const {values,positionals}=parseArgs({allowPositionals:true,options:{help:{type:'boolean',short:'h'},install:{type:'boolean'},title:{type:'string'},'miradocs-version':{type:'string'}}});
|
|
9
|
+
if(values.help){console.log('npm create miradocs@latest [directory] [-- --install]\nOptions: --title "Project docs"');}
|
|
10
|
+
else {
|
|
11
|
+
if(positionals.length>1)throw Error('Provide one project directory.');
|
|
12
|
+
let directory=positionals[0];
|
|
13
|
+
if(!directory && process.stdin.isTTY){const input=createInterface({input:process.stdin,output:process.stdout});directory=(await input.question('Project directory (my-docs): ')).trim() || 'my-docs';input.close();}
|
|
14
|
+
const result=await createStarter(directory || 'my-docs',{version:values['miradocs-version'],title:values.title || 'Documentation'});
|
|
15
|
+
const agent=process.env.npm_config_user_agent || '';
|
|
16
|
+
const manager=agent.startsWith('pnpm')?'pnpm':agent.startsWith('yarn')?'yarn':agent.startsWith('bun')?'bun':'npm';
|
|
17
|
+
if(values.install)await new Promise((resolve,reject)=>{const child=spawn(manager,['install'],{cwd:result.root,stdio:'inherit',shell:process.platform==='win32'});child.on('error',reject);child.on('exit',code=>code===0?resolve():reject(Error(`Dependency installation exited with ${code}. The generated project is still available.`)));});
|
|
18
|
+
console.log(`\nCreated ${result.name}.\n\n cd ${directory || 'my-docs'}\n${values.install?'':` ${manager} install\n`} ${manager} run dev\n`);
|
|
19
|
+
}
|
|
20
|
+
}catch(error){console.error(`create-miradocs: ${error.message}`);process.exitCode=1;}
|
package/lib/starter.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
const packageVersion = JSON.parse(await fs.readFile(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
5
|
+
const defaultVersion = packageVersion.includes('-') ? packageVersion : '^' + packageVersion;
|
|
6
|
+
|
|
7
|
+
export async function createStarter(directory, { version=defaultVersion,title='Documentation' } = {}) {
|
|
8
|
+
const root=path.resolve(directory);
|
|
9
|
+
let entries=[];
|
|
10
|
+
try{entries=await fs.readdir(root);}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
11
|
+
if(entries.some(entry=>entry!=='.git'))throw Error('The destination must be empty; refusing to overwrite existing files.');
|
|
12
|
+
const name=path.basename(root).toLowerCase().replace(/[^a-z0-9-]/g,'-').replace(/^-+|-+$/g,'') || 'my-docs';
|
|
13
|
+
const files={
|
|
14
|
+
'package.json':JSON.stringify({name,private:true,type:'module',scripts:{dev:'miradocs dev',build:'miradocs build',preview:'miradocs serve'},devDependencies:{miradocs:version}},null,2)+'\n',
|
|
15
|
+
'miradocs.config.json':JSON.stringify({$schema:'./node_modules/miradocs/miradocs.schema.json',title,content:'docs',output:'site',theme:'theme',styles:['tokens.css']},null,2)+'\n',
|
|
16
|
+
'docs/index.md':'---\ntitle: Getting started\ndescription: Documentation for your project.\n---\n\nEdit `docs/index.md` to write your first page. Add Markdown files and folders to organize the rest of your documentation.\n',
|
|
17
|
+
'theme/tokens.css':'/* Override miradocs design tokens here. */\n:root {\n --radius: 8px;\n}\n',
|
|
18
|
+
'.gitignore':'node_modules/\nsite/\nsite.lock/\nsite.tmp-*/\nsite.previous-*/\n'
|
|
19
|
+
};
|
|
20
|
+
await fs.mkdir(root,{recursive:true});
|
|
21
|
+
for(const [file,contents]of Object.entries(files)) {await fs.mkdir(path.dirname(path.join(root,file)),{recursive:true});await fs.writeFile(path.join(root,file),contents,{flag:'wx'});}
|
|
22
|
+
return {root,name,files:Object.keys(files)};
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-miradocs",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create a minimal miradocs documentation project.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-miradocs": "bin/create-miradocs.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"lib",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prepack": "node build.js"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20.19"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org/"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/FatalMistake02/miradocs.git",
|
|
28
|
+
"directory": "packages/create-miradocs"
|
|
29
|
+
}
|
|
30
|
+
}
|