create-yamlresume 0.9.1 → 0.10.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/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/package.json +4 -8
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {Command}from'commander';import p from'fs';import d from'path';import n from'chalk';import r from'consola';import F from'prompts';import {joinNonEmptyString}from'@yamlresume/core';import {execa}from'execa';import {fileURLToPath}from'url';var w={version:"0.
|
|
2
|
+
import {Command}from'commander';import p from'fs';import d from'path';import n from'chalk';import r from'consola';import F from'prompts';import {joinNonEmptyString}from'@yamlresume/core';import {execa}from'execa';import {fileURLToPath}from'url';var w={version:"0.10.0"};async function E(){try{return await execa("git",["--version"],{timeout:5e3}),!0}catch{return false}}async function v(e){if(!await E()){r.warn("Git is not available on your system. Skipping git initialization."),r.info("You can initialize git manually later by running: git init");return}r.start("Initializing git repository...");try{await execa("git",["init"],{cwd:e,stdio:"inherit"}),r.success("Git repository initialized!"),await execa("git",["add","."],{cwd:e,stdio:"inherit"}),await execa("git",["commit","-m","init a new YAMLResume project"],{cwd:e,stdio:"inherit"}),r.success("Initial commit created!");}catch{r.warn(joinNonEmptyString(["Failed to initialize git repository.","You can run `git init` manually if needed."]," "));}}var j=[{name:"npm",lockFile:"package-lock.json"},{name:"yarn",lockFile:"yarn.lock"},{name:"pnpm",lockFile:"pnpm-lock.yaml"},{name:"bun",lockFile:"bun.lockb"}];function T(e){if(!e)return;let t=e.split(" ")[0]?.split("/")?.[0]?.toLowerCase();return j.find(i=>i.name===t)}function b(){let e=process.env.npm_config_user_agent,t=T(e);return t||j[0]}async function $(e,t){r.start(`Installing dependencies with ${e.name}...`);try{await execa(e.name,["install"],{cwd:t,stdio:"inherit"}),r.success("Dependencies installed successfully!");}catch{r.warn(joinNonEmptyString(["Failed to install dependencies automatically.",`Please run ${n.cyan(e.name)} install manually.`]," "));}}async function M(e,t){r.start(`Creating resume file ${e}...`);try{await execa("npx",["yamlresume","new",e],{cwd:t,stdio:"inherit"});}catch{r.warn(joinNonEmptyString(["Failed to create resume file automatically.","Please run",`${n.cyan(`npx yamlresume new ${e}`)} manually.`]," "));}}var _=d.dirname(fileURLToPath(import.meta.url));function f(e,t,i){let a=p.readdirSync(e);for(let m of a){let o=d.join(e,m),l=z(t,m),s=p.statSync(o);if(s.isFile()){let y=p.readFileSync(o,"utf8");for(let[A,C]of Object.entries(i))y=y.replace(new RegExp(`{{${A}}}`,"g"),C);p.writeFileSync(l,y);}else s.isDirectory()&&(p.mkdirSync(l,{recursive:true}),f(o,l,i));}}function z(e,t){switch(t){case "gitignore":return d.join(e,".gitignore");default:return d.join(e,t)}}function R(){return d.join(_,"templates")}function G(e){return e.trim()?true:"Project name is required"}function O(e){return e.trim()?true:"Resume filename is required"}async function L(e){let t;if(e)t=e;else {let s=await F({type:"text",name:"projectName",message:"What is your project name?",initial:"yamlresume",validate:G});if(!s.projectName){r.info("Operation cancelled.");return}t=s.projectName.trim();}let i=d.resolve(process.cwd(),t);if(p.existsSync(i))try{if(p.readdirSync(i).length>0){r.warn(`Target directory ${n.cyan(t)} exists and is not empty.`);return}}catch{r.warn(`Target path ${n.cyan(t)} exists and cannot be accessed.`);return}let a=b();r.info(`${n.bold(`Using ${a.name}.`)}
|
|
3
3
|
`);let{resumeFilename:m}=await F({type:"text",name:"resumeFilename",message:"What should your resume file be called? (without .yml extension)",initial:"resume",validate:O});if(!m){r.info("Operation cancelled.");return}let o=`${m.trim()}.yml`;r.start(`Creating YAMLResume project in ${n.cyan(i)}...`),p.mkdirSync(i,{recursive:true});let l=R();f(l,i,{projectName:t,resumeFile:o}),await $(a,i),await M(o,i),await v(i),U(t,a,o);}function U(e,t,i){let a=t.name;r.info(`
|
|
4
4
|
${n.green("\u2728 Project created successfully!")}`),r.info(`
|
|
5
5
|
Next steps:`),r.info(` 1. ${n.cyan(`cd ${e}`)}`),r.info(` 2. Edit your resume: ${n.cyan(i)}`),r.info(` 3. Build your resume: ${n.cyan(`${a} run build`)}`),r.info(` 4. Watch for changes: ${n.cyan(`${a} run dev`)}`),r.info(` 5. Show all commands: ${n.cyan(`${a} run yamlresume help`)}`),r.info(`
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/git.ts","../src/package-manager.ts","../src/template.ts","../src/project.ts","../src/program.ts","../src/cli.ts"],"names":["package_default","isGitAvailable","execa","initializeGitRepository","projectPath","consola","joinNonEmptyString","packageManagers","detectPackageManagerFromUserAgent","userAgent","name","pm","detectPackageManager","detected","installDependencies","packageManager","chalk","createResumeFile","resumeFile","__dirname","path","fileURLToPath","copyTemplateFiles","templatesDir","targetDir","variables","files","fs","file","sourcePath","targetPath","getTargetPath","stats","content","key","value","getTemplatesDir","validateProjectName","validateResumeFilename","createYamlResumeProject","projectName","finalProjectName","response","prompts","resumeFilename","showProjectHelp","pmName","createProjectAction","error","createProgram","program","Command"],"mappings":";qPAAA,IAAAA,CAAAA,CAAA,CAEE,OAAA,CAAW,OAoEb,CAAA,CCrCA,eAAsBC,GAAmC,CACvD,GAAI,CACF,OAAA,MAAMC,KAAAA,CAAM,KAAA,CAAO,CAAC,WAAW,CAAA,CAAG,CAAE,QAAS,GAAK,CAAC,EAC5C,CAAA,CACT,CAAA,KAAQ,CACN,OAAO,MACT,CACF,CAQA,eAAsBC,EACpBC,CAAAA,CACe,CAGf,GAAI,CAFiB,MAAMH,CAAAA,EAAe,CAEvB,CACjBI,CAAAA,CAAQ,IAAA,CACN,mEACF,CAAA,CACAA,CAAAA,CAAQ,KAAK,4DAA4D,CAAA,CACzE,MACF,CAEAA,CAAAA,CAAQ,MAAM,gCAAgC,CAAA,CAE9C,GAAI,CACF,MAAMH,MAAM,KAAA,CAAO,CAAC,MAAM,CAAA,CAAG,CAC3B,GAAA,CAAKE,CAAAA,CACL,MAAO,SACT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AA,EAAG8B,CAAM,CAAA,QAAA,CAAU,CAAC,CAAA,CAAE,EACzEzC,CAAAA,CAAQ,IAAA,CACN,CAAA,wBAAA,EAA2BW,CAAAA,CAAM,IAAA,CAAK,CAAA,EAAG8B,CAAM,CAAA,oBAAA,CAAsB,CAAC,CAAA,CACxE,CAAA,CACAzC,CAAAA,CAAQ,IAAA,CAAK;AAAA,WAAA,CAAe,EAC5BA,CAAAA,CAAQ,IAAA,CAAK,8CAAuC,CAAA,CACpDA,EAAQ,IAAA,CAAK,yDAAkD,CAAA,CAC/DA,CAAAA,CAAQ,KAAK,0DAAmD,CAAA,CAChEA,CAAAA,CAAQ,IAAA,CAAK,wDAAiD,CAAA,CAC9DA,CAAAA,CAAQ,IAAA,CAAK,iEAA0D,EACzE,CCvJA,eAAsB0C,CAAAA,CAAoBP,CAAAA,CAAqB,CAC7D,GAAI,CACF,MAAMD,CAAAA,CAAwBC,CAAW,EAC3C,CAAA,MAASQ,EAAO,CACd,OAAA,CAAQ,MACN,yBAAA,CACAA,CAAAA,EAAO,OAAA,EAAWA,CAAAA,EAAS,eAC7B,CAAA,CACA,OAAA,CAAQ,IAAA,CAAK,CAAC,EAChB,CACF,CAOO,SAASC,CAAAA,EAAyB,CACvC,IAAMC,CAAAA,CAAU,IAAIC,OAAAA,CAEpB,OAAAD,EACG,IAAA,CAAK,mBAAmB,CAAA,CACxB,WAAA,CAAY,iCAAiC,CAAA,CAC7C,OAAA,CAAQlD,CAAAA,CAAY,OAAO,EAC3B,QAAA,CAAS,gBAAA,CAAkB,+BAA+B,CAAA,CAC1D,OAAO+C,CAAmB,CAAA,CAEtBG,CACT,CClCAD,CAAAA,GAAgB,KAAA,EAAM","file":"cli.js","sourcesContent":["{\n \"name\": \"create-yamlresume\",\n \"version\": \"0.9.1\",\n \"description\": \"Create a new YAMLResume project\",\n \"license\": \"MIT\",\n \"author\": {\n \"name\": \"YAMLResume\",\n \"email\": \"support@yamlresume.com\",\n \"url\": \"https://yamlresume.dev\"\n },\n \"keywords\": [\n \"YAMLResume\",\n \"CV\",\n \"Resume\",\n \"YAML\",\n \"CLI\",\n \"create\"\n ],\n \"type\": \"module\",\n \"bin\": {\n \"create-yamlresume\": \"./dist/cli.js\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"build:watch\": \"tsup --watch\",\n \"build:clean\": \"rm -rf dist\",\n \"build:prod\": \"tsup --dts --minify --sourcemap\",\n \"prepublishOnly\": \"pnpm test\",\n \"dev\": \"tsx src/cli.ts\",\n \"test\": \"vitest --run\",\n \"test:cov\": \"vitest --coverage --run\",\n \"test:watch\": \"vitest\"\n },\n \"dependencies\": {\n \"@yamlresume/core\": \"workspace:*\",\n \"chalk\": \"^5.6.0\",\n \"commander\": \"^14.0.1\",\n \"consola\": \"^3.4.2\",\n \"execa\": \"^9.6.1\",\n \"prompts\": \"^2.4.2\",\n \"tslib\": \"^2.6.2\",\n \"yamlresume\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/prompts\": \"^2.4.9\",\n \"@vitest/coverage-v8\": \"^3.2.4\",\n \"tsx\": \"^4.20.5\",\n \"vite-tsconfig-paths\": \"^5.1.4\",\n \"vitest\": \"^3.2.4\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/yamlresume/yamlresume.git\",\n \"directory\": \"packages/create-yamlresume\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/yamlresume/yamlresume/issues\"\n },\n \"homepage\": \"https://yamlresume.dev/docs/ecosystem/create-yamlresume\",\n \"engines\": {\n \"node\": \">=20.0.0\"\n }\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { joinNonEmptyString } from '@yamlresume/core'\nimport consola from 'consola'\nimport { execa } from 'execa'\n\n/**\n * Check if git is available on the system.\n *\n * @returns A promise that resolves to true if git is available, false otherwise.\n */\nexport async function isGitAvailable(): Promise<boolean> {\n try {\n await execa('git', ['--version'], { timeout: 5000 })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Initialize git repository and create initial commit.\n *\n * @param projectPath - The path to the project.\n * @returns A promise that resolves when the git repository is initialized.\n */\nexport async function initializeGitRepository(\n projectPath: string\n): Promise<void> {\n const gitAvailable = await isGitAvailable()\n\n if (!gitAvailable) {\n consola.warn(\n 'Git is not available on your system. Skipping git initialization.'\n )\n consola.info('You can initialize git manually later by running: git init')\n return\n }\n\n consola.start('Initializing git repository...')\n\n try {\n await execa('git', ['init'], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n consola.success('Git repository initialized!')\n\n // Add all files to git\n await execa('git', ['add', '.'], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n\n // Create initial commit\n await execa('git', ['commit', '-m', 'init a new YAMLResume project'], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n consola.success('Initial commit created!')\n } catch (_error) {\n consola.warn(\n joinNonEmptyString(\n [\n 'Failed to initialize git repository.',\n 'You can run `git init` manually if needed.',\n ],\n ' '\n )\n )\n }\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { joinNonEmptyString } from '@yamlresume/core'\nimport chalk from 'chalk'\nimport consola from 'consola'\nimport { execa } from 'execa'\n\n/**\n * The package manager interface.\n *\n * @property name - The name of the package manager.\n * @property lockFile - The name of the lock file.\n */\nexport interface PackageManager {\n name: string\n lockFile: string\n}\n\nexport const packageManagers: PackageManager[] = [\n { name: 'npm', lockFile: 'package-lock.json' },\n { name: 'yarn', lockFile: 'yarn.lock' },\n { name: 'pnpm', lockFile: 'pnpm-lock.yaml' },\n { name: 'bun', lockFile: 'bun.lockb' },\n]\n\n/**\n * Detect a package manager from an npm-style user agent string.\n *\n * @param userAgent - The user agent string (e.g. \"pnpm/9.0.0 npm/? node/v20\").\n * @returns The detected package manager, or undefined if not recognized.\n */\nexport function detectPackageManagerFromUserAgent(\n userAgent?: string\n): PackageManager | undefined {\n if (!userAgent) return undefined\n const name = userAgent.split(' ')[0]?.split('/')?.[0]?.toLowerCase()\n return packageManagers.find((pm) => pm.name === name)\n}\n\n/**\n * Detect the package manager from the current process environment.\n *\n * Uses the npm_config_user_agent env var which is set by npm, pnpm and yarn.\n * Falls back to npm if not recognized.\n */\nexport function detectPackageManager(): PackageManager {\n const userAgent = process.env.npm_config_user_agent\n const detected = detectPackageManagerFromUserAgent(userAgent)\n\n if (detected) return detected\n // Default to npm if nothing detected\n return packageManagers[0]\n}\n\n/**\n * Install dependencies using the selected package manager.\n *\n * @param packageManager - The package manager to use.\n * @param projectPath - The path to the project.\n * @returns A promise that resolves when the dependencies are installed.\n */\nexport async function installDependencies(\n packageManager: PackageManager,\n projectPath: string\n): Promise<void> {\n consola.start(`Installing dependencies with ${packageManager.name}...`)\n\n try {\n await execa(packageManager.name, ['install'], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n consola.success('Dependencies installed successfully!')\n } catch (_error) {\n consola.warn(\n joinNonEmptyString(\n [\n 'Failed to install dependencies automatically.',\n `Please run ${chalk.cyan(packageManager.name)} install manually.`,\n ],\n ' '\n )\n )\n }\n}\n\n/**\n * Create the resume file using yamlresume CLI.\n *\n * @param resumeFile - The name of the resume file.\n * @param projectPath - The path to the project.\n * @returns A promise that resolves when the resume file is created.\n */\nexport async function createResumeFile(\n resumeFile: string,\n projectPath: string\n): Promise<void> {\n consola.start(`Creating resume file ${resumeFile}...`)\n\n try {\n await execa('npx', ['yamlresume', 'new', resumeFile], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n } catch (_error) {\n consola.warn(\n joinNonEmptyString(\n [\n 'Failed to create resume file automatically.',\n 'Please run',\n `${chalk.cyan(`npx yamlresume new ${resumeFile}`)} manually.`,\n ],\n ' '\n )\n )\n }\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\n/**\n * Copy template files and replace placeholders.\n *\n * @param templatesDir - The directory containing the template files.\n * @param targetDir - The directory to copy the template files to.\n * @param variables - The variables to replace in the template files.\n */\nexport function copyTemplateFiles(\n templatesDir: string,\n targetDir: string,\n variables: Record<string, string>\n): void {\n const files = fs.readdirSync(templatesDir)\n\n for (const file of files) {\n const sourcePath = path.join(templatesDir, file)\n const targetPath = getTargetPath(targetDir, file)\n\n const stats = fs.statSync(sourcePath)\n\n if (stats.isFile()) {\n let content = fs.readFileSync(sourcePath, 'utf8')\n\n // Replace template variables\n for (const [key, value] of Object.entries(variables)) {\n content = content.replace(new RegExp(`{{${key}}}`, 'g'), value)\n }\n\n fs.writeFileSync(targetPath, content)\n } else if (stats.isDirectory()) {\n fs.mkdirSync(targetPath, { recursive: true })\n copyTemplateFiles(sourcePath, targetPath, variables)\n }\n }\n}\n\n/**\n * Get proper target path for files in templates\n *\n * @param targetDir - The directory to copy the template files to.\n * @param file - The file to be checked\n * @returns - The target path for the template file to be copied to.\n */\nexport function getTargetPath(targetDir: string, file: string) {\n switch (file) {\n // `npm publish` will by default exclude `.gitignore`, super weird behavior,\n // this is just a workaround\n case 'gitignore':\n return path.join(targetDir, '.gitignore')\n default:\n return path.join(targetDir, file)\n }\n}\n\n/**\n * Get the templates directory path.\n *\n * @returns The path to the templates directory.\n */\nexport function getTemplatesDir(): string {\n return path.join(__dirname, 'templates')\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport chalk from 'chalk'\nimport consola from 'consola'\nimport prompts from 'prompts'\n\nimport { initializeGitRepository } from './git.js'\nimport {\n createResumeFile,\n detectPackageManager,\n installDependencies,\n type PackageManager,\n} from './package-manager.js'\nimport { copyTemplateFiles, getTemplatesDir } from './template.js'\n\n/**\n * Validate that a project name is not empty.\n *\n * @param value - The project name to validate.\n * @returns True if valid, error message if invalid.\n */\nexport function validateProjectName(value: string): true | string {\n return value.trim() ? true : 'Project name is required'\n}\n\n/**\n * Validate that a resume filename is not empty.\n *\n * @param value - The resume filename to validate.\n * @returns True if valid, error message if invalid.\n */\nexport function validateResumeFilename(value: string): true | string {\n return value.trim() ? true : 'Resume filename is required'\n}\n\n/**\n * Create a new YAMLResume project.\n *\n * @param projectName - The name of the project.\n * @returns A promise that resolves when the project is created.\n */\nexport async function createYamlResumeProject(\n projectName?: string\n): Promise<void> {\n let finalProjectName: string\n\n // Get project name if not provided\n if (!projectName) {\n const response = await prompts({\n type: 'text',\n name: 'projectName',\n message: 'What is your project name?',\n initial: 'yamlresume',\n validate: validateProjectName,\n })\n\n if (!response.projectName) {\n consola.info('Operation cancelled.')\n return\n }\n\n finalProjectName = response.projectName.trim()\n } else {\n finalProjectName = projectName\n }\n\n const projectPath = path.resolve(process.cwd(), finalProjectName)\n\n // Check if directory already exists\n if (fs.existsSync(projectPath)) {\n try {\n const files = fs.readdirSync(projectPath)\n if (files.length > 0) {\n consola.warn(\n `Target directory ${chalk.cyan(finalProjectName)} exists and is not empty.`\n )\n return\n }\n } catch {\n consola.warn(\n `Target path ${chalk.cyan(finalProjectName)} exists and cannot be accessed.`\n )\n return\n }\n }\n\n const packageManager = detectPackageManager()\n\n consola.info(`${chalk.bold(`Using ${packageManager.name}.`)}\\n`)\n\n // Get resume filename\n const { resumeFilename } = await prompts({\n type: 'text',\n name: 'resumeFilename',\n message: 'What should your resume file be called? (without .yml extension)',\n initial: 'resume',\n validate: validateResumeFilename,\n })\n\n if (!resumeFilename) {\n consola.info('Operation cancelled.')\n return\n }\n\n const resumeFile = `${resumeFilename.trim()}.yml`\n\n consola.start(`Creating YAMLResume project in ${chalk.cyan(projectPath)}...`)\n\n // Create project directory\n fs.mkdirSync(projectPath, { recursive: true })\n\n // Copy template files\n const templatesDir = getTemplatesDir()\n copyTemplateFiles(templatesDir, projectPath, {\n projectName: finalProjectName,\n resumeFile,\n })\n\n // Install dependencies\n await installDependencies(packageManager, projectPath)\n\n // Create resume file\n await createResumeFile(resumeFile, projectPath)\n\n // Initialize git repository\n await initializeGitRepository(projectPath)\n\n // Show help\n showProjectHelp(finalProjectName, packageManager, resumeFile)\n}\n\n/**\n * Show help information after project creation.\n *\n * @param projectName - The name of the project.\n * @param packageManager - The package manager used in the project.\n * @param resumeFile - The name of the resume file.\n */\nexport function showProjectHelp(\n projectName: string,\n packageManager: PackageManager,\n resumeFile: string\n): void {\n const pmName = packageManager.name\n\n consola.info(`\\n${chalk.green('✨ Project created successfully!')}`)\n consola.info('\\nNext steps:')\n consola.info(` 1. ${chalk.cyan(`cd ${projectName}`)}`)\n consola.info(` 2. Edit your resume: ${chalk.cyan(resumeFile)}`)\n consola.info(` 3. Build your resume: ${chalk.cyan(`${pmName} run build`)}`)\n consola.info(` 4. Watch for changes: ${chalk.cyan(`${pmName} run dev`)}`)\n consola.info(\n ` 5. Show all commands: ${chalk.cyan(`${pmName} run yamlresume help`)}`\n )\n consola.info('\\nLearn more:')\n consola.info(' 🏠 Homepage: https://yamlresume.dev')\n consola.info(' 📖 Documentation: https://yamlresume.dev/docs/')\n consola.info(' 🎨 Layouts: https://yamlresume.dev/docs/layouts')\n consola.info(' 🌐 Locale: https://yamlresume.dev/docs/locale')\n consola.info(' 📝 Schema: https://yamlresume.dev/docs/compiler/schema')\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Command } from 'commander'\nimport packageJson from '../package.json' with { type: 'json' }\nimport { createYamlResumeProject } from './project'\n\n/**\n * Create a new YAMLResume project action handler.\n *\n * @param projectName - The name of the project.\n */\nexport async function createProjectAction(projectName: string) {\n try {\n await createYamlResumeProject(projectName)\n } catch (error) {\n console.error(\n 'Error creating project:',\n error?.message || error || 'Unknown error'\n )\n process.exit(1)\n }\n}\n\n/**\n * Create the CLI program.\n *\n * @returns The CLI program.\n */\nexport function createProgram(): Command {\n const program = new Command()\n\n program\n .name('create-yamlresume')\n .description('Create a new YAMLResume project')\n .version(packageJson.version)\n .argument('[project-name]', 'name of the project directory')\n .action(createProjectAction)\n\n return program\n}\n","#!/usr/bin/env node\n/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { createProgram } from './program'\n\ncreateProgram().parse()\n"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/git.ts","../src/package-manager.ts","../src/template.ts","../src/project.ts","../src/program.ts","../src/cli.ts"],"names":["package_default","isGitAvailable","execa","initializeGitRepository","projectPath","consola","joinNonEmptyString","packageManagers","detectPackageManagerFromUserAgent","userAgent","name","pm","detectPackageManager","detected","installDependencies","packageManager","chalk","createResumeFile","resumeFile","__dirname","path","fileURLToPath","copyTemplateFiles","templatesDir","targetDir","variables","files","fs","file","sourcePath","targetPath","getTargetPath","stats","content","key","value","getTemplatesDir","validateProjectName","validateResumeFilename","createYamlResumeProject","projectName","finalProjectName","response","prompts","resumeFilename","showProjectHelp","pmName","createProjectAction","error","createProgram","program","Command"],"mappings":";qPAAA,IAAAA,CAAAA,CAAA,CAEE,OAAA,CAAW,QAgEb,CAAA,CCjCA,eAAsBC,GAAmC,CACvD,GAAI,CACF,OAAA,MAAMC,KAAAA,CAAM,MAAO,CAAC,WAAW,EAAG,CAAE,OAAA,CAAS,GAAK,CAAC,EAC5C,CAAA,CACT,CAAA,KAAQ,CACN,OAAO,MACT,CACF,CAQA,eAAsBC,EACpBC,CAAAA,CACe,CAGf,GAAI,CAFiB,MAAMH,GAAe,CAEvB,CACjBI,EAAQ,IAAA,CACN,mEACF,CAAA,CACAA,CAAAA,CAAQ,KAAK,4DAA4D,CAAA,CACzE,MACF,CAEAA,CAAAA,CAAQ,MAAM,gCAAgC,CAAA,CAE9C,GA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,CAAA,CAEtBG,CACT,CClCAD,CAAAA,GAAgB,KAAA,EAAM","file":"cli.js","sourcesContent":["{\n \"name\": \"create-yamlresume\",\n \"version\": \"0.10.0\",\n \"description\": \"Create a new YAMLResume project\",\n \"license\": \"MIT\",\n \"author\": {\n \"name\": \"YAMLResume\",\n \"email\": \"support@yamlresume.com\",\n \"url\": \"https://yamlresume.dev\"\n },\n \"keywords\": [\n \"YAMLResume\",\n \"CV\",\n \"Resume\",\n \"YAML\",\n \"CLI\",\n \"create\"\n ],\n \"type\": \"module\",\n \"bin\": {\n \"create-yamlresume\": \"./dist/cli.js\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"build:watch\": \"tsup --watch\",\n \"build:clean\": \"rm -rf dist\",\n \"build:prod\": \"tsup --dts --minify --sourcemap\",\n \"prepublishOnly\": \"pnpm test\",\n \"dev\": \"tsx src/cli.ts\",\n \"test\": \"vitest --run\",\n \"test:cov\": \"vitest --coverage --run\",\n \"test:watch\": \"vitest\"\n },\n \"dependencies\": {\n \"@yamlresume/core\": \"workspace:*\",\n \"chalk\": \"^5.6.0\",\n \"commander\": \"^14.0.1\",\n \"consola\": \"^3.4.2\",\n \"execa\": \"^9.6.1\",\n \"prompts\": \"^2.4.2\",\n \"tslib\": \"^2.6.2\",\n \"yamlresume\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/prompts\": \"^2.4.9\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/yamlresume/yamlresume.git\",\n \"directory\": \"packages/create-yamlresume\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/yamlresume/yamlresume/issues\"\n },\n \"homepage\": \"https://yamlresume.dev/docs/ecosystem/create-yamlresume\",\n \"engines\": {\n \"node\": \">=20.0.0\"\n }\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { joinNonEmptyString } from '@yamlresume/core'\nimport consola from 'consola'\nimport { execa } from 'execa'\n\n/**\n * Check if git is available on the system.\n *\n * @returns A promise that resolves to true if git is available, false otherwise.\n */\nexport async function isGitAvailable(): Promise<boolean> {\n try {\n await execa('git', ['--version'], { timeout: 5000 })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Initialize git repository and create initial commit.\n *\n * @param projectPath - The path to the project.\n * @returns A promise that resolves when the git repository is initialized.\n */\nexport async function initializeGitRepository(\n projectPath: string\n): Promise<void> {\n const gitAvailable = await isGitAvailable()\n\n if (!gitAvailable) {\n consola.warn(\n 'Git is not available on your system. Skipping git initialization.'\n )\n consola.info('You can initialize git manually later by running: git init')\n return\n }\n\n consola.start('Initializing git repository...')\n\n try {\n await execa('git', ['init'], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n consola.success('Git repository initialized!')\n\n // Add all files to git\n await execa('git', ['add', '.'], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n\n // Create initial commit\n await execa('git', ['commit', '-m', 'init a new YAMLResume project'], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n consola.success('Initial commit created!')\n } catch (_error) {\n consola.warn(\n joinNonEmptyString(\n [\n 'Failed to initialize git repository.',\n 'You can run `git init` manually if needed.',\n ],\n ' '\n )\n )\n }\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { joinNonEmptyString } from '@yamlresume/core'\nimport chalk from 'chalk'\nimport consola from 'consola'\nimport { execa } from 'execa'\n\n/**\n * The package manager interface.\n *\n * @property name - The name of the package manager.\n * @property lockFile - The name of the lock file.\n */\nexport interface PackageManager {\n name: string\n lockFile: string\n}\n\nexport const packageManagers: PackageManager[] = [\n { name: 'npm', lockFile: 'package-lock.json' },\n { name: 'yarn', lockFile: 'yarn.lock' },\n { name: 'pnpm', lockFile: 'pnpm-lock.yaml' },\n { name: 'bun', lockFile: 'bun.lockb' },\n]\n\n/**\n * Detect a package manager from an npm-style user agent string.\n *\n * @param userAgent - The user agent string (e.g. \"pnpm/9.0.0 npm/? node/v20\").\n * @returns The detected package manager, or undefined if not recognized.\n */\nexport function detectPackageManagerFromUserAgent(\n userAgent?: string\n): PackageManager | undefined {\n if (!userAgent) return undefined\n const name = userAgent.split(' ')[0]?.split('/')?.[0]?.toLowerCase()\n return packageManagers.find((pm) => pm.name === name)\n}\n\n/**\n * Detect the package manager from the current process environment.\n *\n * Uses the npm_config_user_agent env var which is set by npm, pnpm and yarn.\n * Falls back to npm if not recognized.\n */\nexport function detectPackageManager(): PackageManager {\n const userAgent = process.env.npm_config_user_agent\n const detected = detectPackageManagerFromUserAgent(userAgent)\n\n if (detected) return detected\n // Default to npm if nothing detected\n return packageManagers[0]\n}\n\n/**\n * Install dependencies using the selected package manager.\n *\n * @param packageManager - The package manager to use.\n * @param projectPath - The path to the project.\n * @returns A promise that resolves when the dependencies are installed.\n */\nexport async function installDependencies(\n packageManager: PackageManager,\n projectPath: string\n): Promise<void> {\n consola.start(`Installing dependencies with ${packageManager.name}...`)\n\n try {\n await execa(packageManager.name, ['install'], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n consola.success('Dependencies installed successfully!')\n } catch (_error) {\n consola.warn(\n joinNonEmptyString(\n [\n 'Failed to install dependencies automatically.',\n `Please run ${chalk.cyan(packageManager.name)} install manually.`,\n ],\n ' '\n )\n )\n }\n}\n\n/**\n * Create the resume file using yamlresume CLI.\n *\n * @param resumeFile - The name of the resume file.\n * @param projectPath - The path to the project.\n * @returns A promise that resolves when the resume file is created.\n */\nexport async function createResumeFile(\n resumeFile: string,\n projectPath: string\n): Promise<void> {\n consola.start(`Creating resume file ${resumeFile}...`)\n\n try {\n await execa('npx', ['yamlresume', 'new', resumeFile], {\n cwd: projectPath,\n stdio: 'inherit',\n })\n } catch (_error) {\n consola.warn(\n joinNonEmptyString(\n [\n 'Failed to create resume file automatically.',\n 'Please run',\n `${chalk.cyan(`npx yamlresume new ${resumeFile}`)} manually.`,\n ],\n ' '\n )\n )\n }\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\n/**\n * Copy template files and replace placeholders.\n *\n * @param templatesDir - The directory containing the template files.\n * @param targetDir - The directory to copy the template files to.\n * @param variables - The variables to replace in the template files.\n */\nexport function copyTemplateFiles(\n templatesDir: string,\n targetDir: string,\n variables: Record<string, string>\n): void {\n const files = fs.readdirSync(templatesDir)\n\n for (const file of files) {\n const sourcePath = path.join(templatesDir, file)\n const targetPath = getTargetPath(targetDir, file)\n\n const stats = fs.statSync(sourcePath)\n\n if (stats.isFile()) {\n let content = fs.readFileSync(sourcePath, 'utf8')\n\n // Replace template variables\n for (const [key, value] of Object.entries(variables)) {\n content = content.replace(new RegExp(`{{${key}}}`, 'g'), value)\n }\n\n fs.writeFileSync(targetPath, content)\n } else if (stats.isDirectory()) {\n fs.mkdirSync(targetPath, { recursive: true })\n copyTemplateFiles(sourcePath, targetPath, variables)\n }\n }\n}\n\n/**\n * Get proper target path for files in templates\n *\n * @param targetDir - The directory to copy the template files to.\n * @param file - The file to be checked\n * @returns - The target path for the template file to be copied to.\n */\nexport function getTargetPath(targetDir: string, file: string) {\n switch (file) {\n // `npm publish` will by default exclude `.gitignore`, super weird behavior,\n // this is just a workaround\n case 'gitignore':\n return path.join(targetDir, '.gitignore')\n default:\n return path.join(targetDir, file)\n }\n}\n\n/**\n * Get the templates directory path.\n *\n * @returns The path to the templates directory.\n */\nexport function getTemplatesDir(): string {\n return path.join(__dirname, 'templates')\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport chalk from 'chalk'\nimport consola from 'consola'\nimport prompts from 'prompts'\n\nimport { initializeGitRepository } from './git.js'\nimport {\n createResumeFile,\n detectPackageManager,\n installDependencies,\n type PackageManager,\n} from './package-manager.js'\nimport { copyTemplateFiles, getTemplatesDir } from './template.js'\n\n/**\n * Validate that a project name is not empty.\n *\n * @param value - The project name to validate.\n * @returns True if valid, error message if invalid.\n */\nexport function validateProjectName(value: string): true | string {\n return value.trim() ? true : 'Project name is required'\n}\n\n/**\n * Validate that a resume filename is not empty.\n *\n * @param value - The resume filename to validate.\n * @returns True if valid, error message if invalid.\n */\nexport function validateResumeFilename(value: string): true | string {\n return value.trim() ? true : 'Resume filename is required'\n}\n\n/**\n * Create a new YAMLResume project.\n *\n * @param projectName - The name of the project.\n * @returns A promise that resolves when the project is created.\n */\nexport async function createYamlResumeProject(\n projectName?: string\n): Promise<void> {\n let finalProjectName: string\n\n // Get project name if not provided\n if (!projectName) {\n const response = await prompts({\n type: 'text',\n name: 'projectName',\n message: 'What is your project name?',\n initial: 'yamlresume',\n validate: validateProjectName,\n })\n\n if (!response.projectName) {\n consola.info('Operation cancelled.')\n return\n }\n\n finalProjectName = response.projectName.trim()\n } else {\n finalProjectName = projectName\n }\n\n const projectPath = path.resolve(process.cwd(), finalProjectName)\n\n // Check if directory already exists\n if (fs.existsSync(projectPath)) {\n try {\n const files = fs.readdirSync(projectPath)\n if (files.length > 0) {\n consola.warn(\n `Target directory ${chalk.cyan(finalProjectName)} exists and is not empty.`\n )\n return\n }\n } catch {\n consola.warn(\n `Target path ${chalk.cyan(finalProjectName)} exists and cannot be accessed.`\n )\n return\n }\n }\n\n const packageManager = detectPackageManager()\n\n consola.info(`${chalk.bold(`Using ${packageManager.name}.`)}\\n`)\n\n // Get resume filename\n const { resumeFilename } = await prompts({\n type: 'text',\n name: 'resumeFilename',\n message: 'What should your resume file be called? (without .yml extension)',\n initial: 'resume',\n validate: validateResumeFilename,\n })\n\n if (!resumeFilename) {\n consola.info('Operation cancelled.')\n return\n }\n\n const resumeFile = `${resumeFilename.trim()}.yml`\n\n consola.start(`Creating YAMLResume project in ${chalk.cyan(projectPath)}...`)\n\n // Create project directory\n fs.mkdirSync(projectPath, { recursive: true })\n\n // Copy template files\n const templatesDir = getTemplatesDir()\n copyTemplateFiles(templatesDir, projectPath, {\n projectName: finalProjectName,\n resumeFile,\n })\n\n // Install dependencies\n await installDependencies(packageManager, projectPath)\n\n // Create resume file\n await createResumeFile(resumeFile, projectPath)\n\n // Initialize git repository\n await initializeGitRepository(projectPath)\n\n // Show help\n showProjectHelp(finalProjectName, packageManager, resumeFile)\n}\n\n/**\n * Show help information after project creation.\n *\n * @param projectName - The name of the project.\n * @param packageManager - The package manager used in the project.\n * @param resumeFile - The name of the resume file.\n */\nexport function showProjectHelp(\n projectName: string,\n packageManager: PackageManager,\n resumeFile: string\n): void {\n const pmName = packageManager.name\n\n consola.info(`\\n${chalk.green('✨ Project created successfully!')}`)\n consola.info('\\nNext steps:')\n consola.info(` 1. ${chalk.cyan(`cd ${projectName}`)}`)\n consola.info(` 2. Edit your resume: ${chalk.cyan(resumeFile)}`)\n consola.info(` 3. Build your resume: ${chalk.cyan(`${pmName} run build`)}`)\n consola.info(` 4. Watch for changes: ${chalk.cyan(`${pmName} run dev`)}`)\n consola.info(\n ` 5. Show all commands: ${chalk.cyan(`${pmName} run yamlresume help`)}`\n )\n consola.info('\\nLearn more:')\n consola.info(' 🏠 Homepage: https://yamlresume.dev')\n consola.info(' 📖 Documentation: https://yamlresume.dev/docs/')\n consola.info(' 🎨 Layouts: https://yamlresume.dev/docs/layouts')\n consola.info(' 🌐 Locale: https://yamlresume.dev/docs/locale')\n consola.info(' 📝 Schema: https://yamlresume.dev/docs/compiler/schema')\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Command } from 'commander'\nimport packageJson from '../package.json' with { type: 'json' }\nimport { createYamlResumeProject } from './project'\n\n/**\n * Create a new YAMLResume project action handler.\n *\n * @param projectName - The name of the project.\n */\nexport async function createProjectAction(projectName: string) {\n try {\n await createYamlResumeProject(projectName)\n } catch (error) {\n console.error(\n 'Error creating project:',\n error?.message || error || 'Unknown error'\n )\n process.exit(1)\n }\n}\n\n/**\n * Create the CLI program.\n *\n * @returns The CLI program.\n */\nexport function createProgram(): Command {\n const program = new Command()\n\n program\n .name('create-yamlresume')\n .description('Create a new YAMLResume project')\n .version(packageJson.version)\n .argument('[project-name]', 'name of the project directory')\n .action(createProjectAction)\n\n return program\n}\n","#!/usr/bin/env node\n/**\n * MIT License\n *\n * Copyright (c) 2023–Present PPResume (https://ppresume.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { createProgram } from './program'\n\ncreateProgram().parse()\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-yamlresume",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Create a new YAMLResume project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -32,15 +32,11 @@
|
|
|
32
32
|
"execa": "^9.6.1",
|
|
33
33
|
"prompts": "^2.4.2",
|
|
34
34
|
"tslib": "^2.6.2",
|
|
35
|
-
"@yamlresume/core": "0.
|
|
36
|
-
"yamlresume": "0.
|
|
35
|
+
"@yamlresume/core": "0.10.0",
|
|
36
|
+
"yamlresume": "0.10.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/prompts": "^2.4.9"
|
|
40
|
-
"@vitest/coverage-v8": "^3.2.4",
|
|
41
|
-
"tsx": "^4.20.5",
|
|
42
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
43
|
-
"vitest": "^3.2.4"
|
|
39
|
+
"@types/prompts": "^2.4.9"
|
|
44
40
|
},
|
|
45
41
|
"publishConfig": {
|
|
46
42
|
"access": "public"
|