Skip to content

Commit

Permalink
refactor(setup): use template placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed Oct 15, 2024
1 parent b8f3ccd commit dc173bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions README.template.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# @wopjs/template
# {{pkgName}}

[![Docs](https://img.shields.io/badge/Docs-read-%23fdf9f5)](https://wopjs.github.io/template)
[![Build Status](https://github.com/wopjs/template/actions/workflows/build.yml/badge.svg)](https://github.com/wopjs/template/actions/workflows/build.yml)
[![npm-version](https://img.shields.io/npm/v/@wopjs/template.svg)](https://www.npmjs.com/package/@wopjs/template)
[![Coverage Status](https://img.shields.io/coverallsCoverage/github/wopjs/template)](https://coveralls.io/github/wopjs/template)
[![minified-size](https://img.shields.io/bundlephobia/minzip/@wopjs/template)](https://bundlephobia.com/package/@wopjs/template)
[![Docs](https://img.shields.io/badge/Docs-read-%23fdf9f5)](https://{{author}}.github.io/{{repoName}})
[![Build Status](https://github.com/{{author}}/{{repoName}}/actions/workflows/build.yml/badge.svg)](https://github.com/{{author}}/{{repoName}}/actions/workflows/build.yml)
[![npm-version](https://img.shields.io/npm/v/{{pkgName}}.svg)](https://www.npmjs.com/package/{{pkgName}})
[![Coverage Status](https://img.shields.io/coverallsCoverage/github/{{author}}/{{repoName}})](https://coveralls.io/github/{{author}}/{{repoName}})
[![minified-size](https://img.shields.io/bundlephobia/minzip/{{pkgName}})](https://bundlephobia.com/package/{{pkgName}})

Collection of common utilities.
{{description}}

## Install

```
npm add @wopjs/template
npm add {{pkgName}}
```
20 changes: 10 additions & 10 deletions scripts/setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ let repo = (argv("repo") || exec("git remote get-url origin"))
.trim()
.toLowerCase();

let user = (path.basename(path.dirname(repo)) || "wopjs").toLowerCase();
let author = (path.basename(path.dirname(repo)) || "wopjs").toLowerCase();

let repoName = (
path.basename(repo, ".git") || path.basename(process.cwd())
).toLowerCase();

let isWop = user === "wopjs";
let isWop = author === "wopjs";

let pkgName = argv("name") || `@${user}/${repoName}`;
let docsURL = `https://${user}.github.io/${repoName}`;
let pkgName = argv("name") || `@${author}/${repoName}`;
let description = argv("description") || repoName;

let pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
pkg.name = pkgName;
pkg.description = argv("description") || repoName;
pkg.description = description;
pkg.keywords = [];
pkg.repository = repo || `${user}/${repoName}`;
pkg.repository = repo || `${author}/${repoName}`;
if (!isWop) {
pkg.maintainers = void 0;
}

let readme = fs.readFileSync("README.template.md", "utf8");
readme = readme.replace(/@wopjs\/template/g, pkgName);
readme = readme.replace(/wopjs\/template/g, `${user}/${repoName}`);
readme = readme.replace("https://wopjs.github.io/template", docsURL);
readme = readme.replace("Collection of common utilities.", `${repoName}.`);
readme = readme.replaceAll("{{pkgName}}", pkgName);
readme = readme.replaceAll("{{author}}", author);
readme = readme.replaceAll("{{repoName}}", repoName);
readme = readme.replaceAll("{{description}}", description);

if (isWop) {
readme += "\n## License\n\nMIT @ [wopjs](https://github.com/wopjs)\n";
Expand Down

0 comments on commit dc173bf

Please sign in to comment.