Skip to content

Commit

Permalink
[Publish]
Browse files Browse the repository at this point in the history
  • Loading branch information
onemanfighter committed Apr 25, 2024
1 parent db74cc3 commit 7bc1bb9
Show file tree
Hide file tree
Showing 5 changed files with 7,167 additions and 16,674 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish job

on:
push:
branches: main

jobs:
publish_npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install Dependencies
run: npm ci
- name: Linting
run: npm run lint
- name: Test
run: npm run test-no-watch
- uses: JS-DevTools/npm-publish@v3
with:
access: "public"
token: ${{ secrets.NPM_AUTH_TOKEN }}
52 changes: 52 additions & 0 deletions bin/create-clean-react-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node

const { execSync } = require("child_process");
const path = require("path");
const fs = require("fs");

if (process.argv.length < 3) {
console.log("You have to provide a name to your app.");
console.log("For example :");
console.log("npx create-clean-react-app my-app");
process.exit(1);
}

const projectName = process.argv[2];
const currentPath = process.cwd();
const projectPath = path.join(currentPath, projectName);
const git_repo =
"git@github.com:onemanfighter/create-clean-react-app-publish.git";

try {
fs.mkdirSync(projectPath);
} catch (err) {
if (err.code === "EEXIST") {
console.log(
`The file ${projectName} already exist in the current directory, please give it another name.`
);
} else {
console.log(err);
}
process.exit(1);
}

async function main() {
try {
console.log("Downloading files...");
execSync(`git clone --depth 1 ${git_repo} ${projectPath}`);

process.chdir(projectPath);

console.log("Installing dependencies...");
execSync("yarn install");

console.log("Removing useless files");
execSync("npx rimraf ./.git");
fs.rmdirSync(path.join(projectPath, "bin"), { recursive: true });

console.log("The installation is done, this is ready to use !");
} catch (error) {
console.log(error);
}
}
main();
Loading

0 comments on commit 7bc1bb9

Please sign in to comment.