diff --git a/.gitignore b/.gitignore index e8388c8..9757584 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Logs +.DS_Store logs *.log npm-debug.log* diff --git a/packages/create-abell/.gitignore b/packages/create-abell/.gitignore new file mode 100644 index 0000000..e119b4c --- /dev/null +++ b/packages/create-abell/.gitignore @@ -0,0 +1 @@ +scaffold-dir/ \ No newline at end of file diff --git a/packages/create-abell/.npmignore b/packages/create-abell/.npmignore new file mode 100644 index 0000000..144af46 --- /dev/null +++ b/packages/create-abell/.npmignore @@ -0,0 +1,9 @@ +node_modules +dist +scaffold-dir +src +templates/**/dist/ +templates/**/node_modules/ +templates/**/yarn.lock +scripts +tsconfig.json \ No newline at end of file diff --git a/packages/create-abell/package.json b/packages/create-abell/package.json new file mode 100644 index 0000000..2aab0bf --- /dev/null +++ b/packages/create-abell/package.json @@ -0,0 +1,37 @@ +{ + "name": "create-abell", + "version": "0.0.15", + "description": "Boilerplate for abell. npx create-abell my-blog", + "main": "dist/create.js", + "types": "dist/create.d.ts", + "bin": { + "create-abell": "dist/bin.js" + }, + "scripts": { + "build": "tsc && node scripts/post-build.js", + "dev": "nodemon --exec \"yarn build\" --watch src --watch templates -e js,ts,abell,css", + "clean-scaffolds": "node scripts/clean-scaffolds.js", + "scaffold": "npm run clean-scaffolds && cd scaffold-dir && node ../dist/bin.js", + "prepublishOnly": "yarn build" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/abelljs/abell.git" + }, + "keywords": [ + "abell" + ], + "author": "saurabhdaware", + "license": "MIT", + "bugs": { + "url": "https://github.com/abelljs/abell/issues" + }, + "homepage": "https://github.com/abelljs/abell#readme", + "dependencies": { + "commander": "^9.2.0", + "prompts": "^2.4.2" + }, + "devDependencies": { + "@types/prompts": "^2.0.14" + } +} diff --git a/packages/create-abell/scripts/clean-scaffolds.js b/packages/create-abell/scripts/clean-scaffolds.js new file mode 100644 index 0000000..8353788 --- /dev/null +++ b/packages/create-abell/scripts/clean-scaffolds.js @@ -0,0 +1,11 @@ +const fs = require('fs'); +const path = require('path'); +const { deleteDir } = require('../dist/utils'); + +function clean() { + const scaffoldDir = path.join(__dirname, '..', 'scaffold-dir'); + deleteDir(scaffoldDir); + fs.mkdirSync(scaffoldDir); +} + +clean(); diff --git a/packages/create-abell/scripts/post-build.js b/packages/create-abell/scripts/post-build.js new file mode 100644 index 0000000..ac420e2 --- /dev/null +++ b/packages/create-abell/scripts/post-build.js @@ -0,0 +1,12 @@ +const fs = require('fs'); +const path = require('path'); + +const DIST = path.join(__dirname, '..', 'dist'); + +try { + const fd = fs.openSync(path.join(DIST, 'bin.js'), 'r'); + fs.fchmodSync(fd, 511); + console.log('> Changed bin.js file persmission to executable'); +} catch (error) { + console.log(error); +} diff --git a/packages/create-abell/src/bin.ts b/packages/create-abell/src/bin.ts new file mode 100644 index 0000000..f9f25ff --- /dev/null +++ b/packages/create-abell/src/bin.ts @@ -0,0 +1,25 @@ +#!/usr/bin/env node +import { createCommand } from 'commander'; +import create, { CreateAbellOptions } from './create'; + +const program = createCommand(); +/** + * npx create-abell [projectName] --template