Skip to content

Commit

Permalink
improve setup.js, change template variable syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
LankyMoose committed Oct 10, 2024
1 parent bf10547 commit 7f62e4e
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ These owners will be the default owners for everything in
the repo. Unless a later match takes precedence, they will
be requested for review when someone opens a PR.

- @!!MY-GITHUB!!
- @%GITHUB-USERNAME%

Order is important; the last matching pattern takes the most
precedence. When someone opens a PR that only modifies
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at **!!MY-EMAIL!!**. All
reported by contacting the project team at **%EMAIL-ADDRESS%**. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ _Pull requests, bug reports, and all other forms of contribution are welcomed an
## :book: Code of Conduct

Please review our [Code of Conduct](https://github.com/!!MY-GITHUB!!/!!MY-PACKAGE!!/blob/main/CODE_OF_CONDUCT.md). It is in effect at all times. We expect it to be honored by everyone who contributes to this project. Acting like an asshole will not be tolerated.
Please review our [Code of Conduct](https://github.com/%GITHUB-USERNAME%/%PACKAGE-NAME%/blob/main/CODE_OF_CONDUCT.md). It is in effect at all times. We expect it to be honored by everyone who contributes to this project. Acting like an asshole will not be tolerated.

## :bulb: Asking Questions

See our [Support Guide](https://github.com/!!MY-GITHUB!!/!!MY-PACKAGE!!/blob/main/SUPPORT.md). In short, GitHub issues are not the appropriate place to debug your specific project, but should be reserved for filing bugs and feature requests.
See our [Support Guide](https://github.com/%GITHUB-USERNAME%/%PACKAGE-NAME%/blob/main/SUPPORT.md). In short, GitHub issues are not the appropriate place to debug your specific project, but should be reserved for filing bugs and feature requests.

## :inbox_tray: Opening an Issue

Before [creating an issue](https://help.github.com/en/github/managing-your-work-on-github/creating-an-issue), check if you are using the latest version of the project. If you are not up-to-date, see if updating fixes your issue first.

### :lock: Reporting Security Issues

Review our [Security Policy](https://github.com/!!MY-GITHUB!!/!!MY-PACKAGE!!/blob/main/SECURITY.md). **Do not** file a public issue for security vulnerabilities.
Review our [Security Policy](https://github.com/%GITHUB-USERNAME%/%PACKAGE-NAME%/blob/main/SECURITY.md). **Do not** file a public issue for security vulnerabilities.

### :beetle: Bug Reports and Other Issues

A great way to contribute to the project is to send a detailed issue when you encounter a problem. We always appreciate a well-written, thorough bug report. :v:

In short, since you are most likely a developer, **provide a ticket that you would like to receive**.

- **Review the documentation and [Support Guide](https://github.com/!!MY-GITHUB!!/!!MY-PACKAGE!!/blob/main/SUPPORT.md)** before opening a new issue.
- **Review the documentation and [Support Guide](https://github.com/%GITHUB-USERNAME%/%PACKAGE-NAME%/blob/main/SUPPORT.md)** before opening a new issue.

- **Do not open a duplicate issue!** Search through existing issues to see if your issue has previously been reported. If your issue exists, comment with any additional information you have. You may simply note "I have this problem too", which helps prioritize the most common problems and requests.

Expand Down Expand Up @@ -181,7 +181,7 @@ To confirm that you have read this guide and are following it as best as possibl

## :pray: Credits

Written by [@!!MY-GITHUB!!](https://github.com/!!MY-GITHUB!!).
Written by [@%GITHUB-USERNAME%](https://github.com/%GITHUB-USERNAME%).

**Please feel free to adopt this guide in your own projects. Fork it wholesale or remix it for your needs.**

Expand Down
2 changes: 1 addition & 1 deletion FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Funding
# https://help.github.com/en/github/administering-a-repository/displaying-a-sponsor-button-in-your-repository

github: !!MY-GITHUB!!
github: %GITHUB-USERNAME%
custom: []
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ISC License

Copyright (c) 2024-present, !!MY-GITHUB!!
Copyright (c) 2024-present, %GITHUB-USERNAME%

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# !!MY-PACKAGE!!
# %PACKAGE-NAME%

Development monorepo template for **!!MY-PACKAGE!!**.
Development monorepo template for **%PACKAGE-NAME%**.

Get started by running

Expand All @@ -16,7 +16,7 @@ node setup --package packagename --github mygithubusername --email [email protected]
- Contains workflows used by GitHub Actions.
- `packages`
- Contains the individual packages managed in the monorepo.
- [!!MY-PACKAGE!!](https://github.com/!!MY-GITHUB!!/!!MY-PACKAGE!!/blob/main/packages/lib)
- [%PACKAGE-NAME%](https://github.com/%GITHUB-USERNAME%/%PACKAGE-NAME%/blob/main/packages/lib)
- `sandbox`
- Contains example applications and random tidbits.

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ If you discover a security issue, please bring it to our attention right away!

## Reporting a Vulnerability

Please **DO NOT** file a public issue to report a security vulberability, instead send your report privately to **!!MY-EMAIL!!**. This will help ensure that any vulnerabilities that are found can be [disclosed responsibly](https://en.wikipedia.org/wiki/Responsible_disclosure) to any affected parties.
Please **DO NOT** file a public issue to report a security vulberability, instead send your report privately to **%EMAIL-ADDRESS%**. This will help ensure that any vulnerabilities that are found can be [disclosed responsibly](https://en.wikipedia.org/wiki/Responsible_disclosure) to any affected parties.

## Supported Versions

Expand Down
2 changes: 1 addition & 1 deletion SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Please seek support in the following ways:

1. :bulb: **Search for answers and ask questions on [Stack Overflow](https://stackoverflow.com).** This is the most appropriate place for debugging issues specific to your use of the project, or figuring out how to use the project in a specific way.

1. :memo: As a **last resort**, you may open an issue on GitHub to ask for help. However, please clearly explain what you are trying to do, and list what you have already attempted to solve the problem. Provide code samples, but **do not** attach your entire project for someone else to debug. Review our [contributing guidelines](https://github.com/!!MY-GITHUB!!/!!MY-PACKAGE!!/blob/main/CONTRIBUTING.md).
1. :memo: As a **last resort**, you may open an issue on GitHub to ask for help. However, please clearly explain what you are trying to do, and list what you have already attempted to solve the problem. Provide code samples, but **do not** attach your entire project for someone else to debug. Review our [contributing guidelines](https://github.com/%GITHUB-USERNAME%/%PACKAGE-NAME%/blob/main/CONTRIBUTING.md).

## What NOT to do

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ISC License

Copyright (c) 2024-present, !!MY-GITHUB!!
Copyright (c) 2024-present, %GITHUB-USERNAME%

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# **!!MY-PACKAGE!!**
# **%PACKAGE-NAME%**

#### _An awesome new package._

Expand Down
6 changes: 3 additions & 3 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "!!MY-PACKAGE!!",
"name": "%PACKAGE-NAME%",
"version": "1.0.0",
"description": "An awesome new package",
"main": "dist/index.js",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/Robby6Strings/[repo-name]"
"url": "https://github.com/%GITHUB-USERNAME%/%PACKAGE-NAME%"
},
"scripts": {
"test": "echo \"Error: no test specified\"",
"build": "tsc"
},
"keywords": [],
"author": "!!MY-GITHUB!!",
"author": "%GITHUB-USERNAME%",
"license": "ISC"
}
2 changes: 1 addition & 1 deletion sandbox/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"!!MY-PACKAGE!!": "workspace:^"
"%PACKAGE-NAME%": "workspace:^"
}
}
2 changes: 1 addition & 1 deletion sandbox/node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { add } from "!!MY-PACKAGE!!"
import { add } from "%PACKAGE-NAME%"

function main() {
console.log(add(1, 2))
Expand Down
25 changes: 15 additions & 10 deletions setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,41 @@ function getArgValue(...argsToMatch) {
}

// prompt user for package name
const packageName = getArgValue("--package", "-p") // !!MY-PACKAGE!!
const packageName = getArgValue("--package", "-p") // %PACKAGE-NAME%
if (!packageName) {
console.error("Please provide a package name")
process.exit(1)
}

const myGithub = getArgValue("--github", "-g") // !!MY-GITHUB!!
const myGithub = getArgValue("--github", "-g") // %GITHUB-USERNAME%
if (!myGithub) {
console.error("Please provide the github name (eg. LankyMoose)")
process.exit(1)
}

const email = getArgValue("--email", "-e") // !!MY-EMAIL!!
const email = getArgValue("--email", "-e") // %EMAIL-ADDRESS%
if (!email) {
console.error("Please provide an email address")
process.exit(1)
}

const cwd = process.cwd()
//build up list of every file in cwd containing the text "test"
const files = fs
.readdirSync(cwd, { withFileTypes: true })
.filter((dirent) => dirent.isFile() && dirent.name !== "setup.js")
.readdirSync(cwd, { withFileTypes: true, recursive: true })
.filter(
(dirent) =>
dirent.isFile() &&
!dirent.path.includes(".git") &&
dirent.name !== "setup.js"
)

for (const file of files) {
const filePath = path.join(cwd, file.name)
console.log(`Updating ${file.name}`, file)
const filePath = path.join(file.path, file.name)
const content = fs.readFileSync(filePath, "utf8")
const updatedContent = content
.replace(/!!MY-PACKAGE!!/g, packageName)
.replace(/!!MY-GITHUB!!/g, myGithub)
.replace(/!!MY-EMAIL!!/g, email)
.replaceAll("%PACKAGE-NAME%", packageName)
.replaceAll("%GITHUB-USERNAME%", myGithub)
.replaceAll("%EMAIL-ADDRESS%", email)
fs.writeFileSync(filePath, updatedContent)
}

0 comments on commit 7f62e4e

Please sign in to comment.