@adbayb/create 0.14.0 → 1.0.1

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/README.md CHANGED
@@ -4,15 +4,7 @@
4
4
  </div>
5
5
  <p></p>
6
6
 
7
- ## Usage
7
+ ## 🚀 Usage
8
8
 
9
9
  - `cd my-project-root-folder`
10
- - `npm init @adbayb --yes` or `npx @adbayb/create`
11
-
12
- ## TODO
13
-
14
- - Github actions (integrate and release)
15
- - PNPM
16
- - @adbayb/scripts usage
17
- - Monorepo by default with project_name, packages/*, examples/*, docs/, .config (?) folder
18
- - Renovatebot
10
+ - `npm init @adbayb`
package/bin/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var e=require("termost");e.helpers.exec("pnpm dlx @adbayb/stack create",{hasLiveOutput:!0});
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["#!/usr/bin/env node\n\n/**\n * Package proxy using `@adbayb/stack` to benefit from NPM initializer `npm init @adbayb`\n * @see https://docs.npmjs.com/cli/v9/commands/npm-init\n */\nimport { helpers } from \"termost\";\n\nhelpers.exec(\"pnpm dlx @adbayb/stack create\", { hasLiveOutput: true });\n"],
5
+ "mappings": ";aAMA,IAAAA,EAAwB,mBAExB,UAAQ,KAAK,gCAAiC,CAAE,cAAe,EAAK,CAAC",
6
+ "names": ["import_termost"]
7
+ }
package/package.json CHANGED
@@ -1,32 +1,41 @@
1
1
  {
2
- "name": "@adbayb/create",
3
- "version": "0.14.0",
4
- "publishConfig": {
5
- "access": "public"
6
- },
7
- "description": "My opinionated scaffolding tool",
8
- "bin": "cli/index.js",
9
- "scripts": {
10
- "start": "./cli/index.js"
11
- },
12
- "keywords": [
13
- "setup",
14
- "scaffolding",
15
- "development"
16
- ],
17
- "author": {
18
- "name": "Ayoub Adib",
19
- "email": "adbayb@gmail.com",
20
- "url": "https://twitter.com/adbayb"
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/adbayb/stack.git",
25
- "directory": "packages/create"
26
- },
27
- "license": "MIT",
28
- "dependencies": {
29
- "ora": "5.4.1"
30
- },
31
- "gitHead": "7126c134205832bb8a4a2d2505c1cb631a711df9"
32
- }
2
+ "name": "@adbayb/create",
3
+ "version": "1.0.1",
4
+ "description": "My opinionated scaffolding tool",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "files": [
9
+ "bin"
10
+ ],
11
+ "bin": "bin/index.js",
12
+ "source": "src/index.ts",
13
+ "main": "bin/index.js",
14
+ "platform": "node",
15
+ "keywords": [
16
+ "setup",
17
+ "scaffolding",
18
+ "development"
19
+ ],
20
+ "author": {
21
+ "name": "Ayoub Adib",
22
+ "email": "adbayb@gmail.com",
23
+ "url": "https://twitter.com/adbayb"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/adbayb/stack.git",
28
+ "directory": "packages/create"
29
+ },
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "@adbayb/stack": "^1.1.0",
33
+ "termost": "^0.9.0"
34
+ },
35
+ "scripts": {
36
+ "prestart": "pnpm build",
37
+ "start": "bin/index.js",
38
+ "build": "quickbundle build && chmod +x bin/index.js",
39
+ "watch": "quickbundle watch"
40
+ }
41
+ }
package/CHANGELOG.md DELETED
@@ -1,90 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [0.14.0](https://github.com/adbayb/stack/compare/v0.13.0...v0.14.0) (2022-04-03)
7
-
8
- **Note:** Version bump only for package @adbayb/create
9
-
10
-
11
-
12
-
13
-
14
- # [0.13.0](https://github.com/adbayb/stack/compare/v0.12.0...v0.13.0) (2022-04-03)
15
-
16
- **Note:** Version bump only for package @adbayb/create
17
-
18
-
19
-
20
-
21
-
22
- # [0.12.0](https://github.com/adbayb/stack/compare/v0.11.0...v0.12.0) (2022-04-01)
23
-
24
-
25
- ### Features
26
-
27
- * update dependencies ([4dcd403](https://github.com/adbayb/stack/commit/4dcd4039c0dac3596129db05657fa5a85deaceab))
28
-
29
-
30
-
31
-
32
-
33
- # [0.11.0](https://github.com/adbayb/stack/compare/v0.10.0...v0.11.0) (2022-03-31)
34
-
35
-
36
- ### Features
37
-
38
- * **scripts:** use built-in package manager to resolve bin instead of yarn ([80a5fd4](https://github.com/adbayb/stack/commit/80a5fd4776b4f36ac6e583e289342bfe2474e22e))
39
-
40
-
41
-
42
-
43
-
44
- # [0.10.0](https://github.com/adbayb/stack/compare/v0.9.0...v0.10.0) (2021-11-25)
45
-
46
- ### Features
47
-
48
- - **prettier-config:** make prettier a peer dependency ([7ff4fe8](https://github.com/adbayb/stack/commit/7ff4fe86438dbccfebe27ad71fabd2108e1b848e))
49
-
50
- # [0.9.0](https://github.com/adbayb/stack/compare/v0.8.0...v0.9.0) (2021-11-23)
51
-
52
- **Note:** Version bump only for package @adbayb/create
53
-
54
- # [0.8.0](https://github.com/adbayb/stack/compare/v0.7.0...v0.8.0) (2021-11-23)
55
-
56
- ### Features
57
-
58
- - **create:** use husky v4 ([982c8be](https://github.com/adbayb/stack/commit/982c8bea835f1610d578175071b6d52e83cc8e92))
59
-
60
- # [0.7.0](https://github.com/adbayb/stack/compare/v0.6.1...v0.7.0) (2021-07-17)
61
-
62
- ### Features
63
-
64
- - update dependencies ([6efb186](https://github.com/adbayb/stack/commit/6efb1864152fc7c1a2a697e0795fd2f104cfd09e))
65
-
66
- # [0.6.0](https://github.com/adbayb/stack/compare/v0.5.0...v0.6.0) (2021-04-05)
67
-
68
- ### Features
69
-
70
- - **terminal-kit:** add library ([4c515b0](https://github.com/adbayb/stack/commit/4c515b0094beadf12d7169dc658a7de8917bfbde))
71
-
72
- # [0.5.0](https://github.com/adbayb/create/compare/v0.4.0...v0.5.0) (2021-04-03)
73
-
74
- ### Bug Fixes
75
-
76
- - **eslint-config:** make padding rule compatible with import rule ([80ac540](https://github.com/adbayb/create/commit/80ac5402c6cb319d669d3af261d6b69b6bf49486))
77
-
78
- ### Features
79
-
80
- - **create:** remove adbayb pkg from create ([885f3d0](https://github.com/adbayb/create/commit/885f3d09f99cfbfd84729331bf06c2de10eb2bfe))
81
- - **create:** switch from npm to yarn ([f0021a4](https://github.com/adbayb/create/commit/f0021a4241e04bdca823087a41bb3dac6b040309))
82
- - **scripts:** add clean command ([977e83f](https://github.com/adbayb/create/commit/977e83fc629a021b5b8f5d501ec363ecb5a5f4c2))
83
-
84
- # [0.4.0](https://github.com/adbayb/create/compare/v0.3.0...v0.4.0) (2021-03-27)
85
-
86
- **Note:** Version bump only for package @adbayb/create
87
-
88
- # 0.3.0 (2021-03-22)
89
-
90
- **Note:** Version bump only for package @adbayb/create
package/cli/constants.js DELETED
@@ -1,10 +0,0 @@
1
- const path = require("path");
2
-
3
- const PROJECT_FOLDER = process.cwd();
4
- const PACKAGE_FOLDER = path.resolve(__dirname, "../");
5
- const TEMPLATES_FOLDER = path.join(PACKAGE_FOLDER, "templates");
6
-
7
- module.exports = {
8
- PROJECT_FOLDER,
9
- TEMPLATES_FOLDER,
10
- };
package/cli/helpers.js DELETED
@@ -1,90 +0,0 @@
1
- const childProcess = require("child_process");
2
- const fs = require("fs");
3
- const path = require("path");
4
- const { PROJECT_FOLDER } = require("./constants");
5
-
6
- const fsPromises = fs.promises;
7
- const isObject = (value) => {
8
- return value !== null && typeof value === "object";
9
- };
10
-
11
- const merge = (target, ...sources) => {
12
- if (sources.length === 0) {
13
- return target;
14
- }
15
-
16
- const source = sources[0];
17
-
18
- for (const key in source) {
19
- const sourceValue = source[key];
20
- const targetValue = target[key];
21
-
22
- if (isObject(sourceValue) && isObject(targetValue)) {
23
- target[key] = merge(targetValue, sourceValue);
24
- } else {
25
- target[key] = sourceValue;
26
- }
27
- }
28
-
29
- sources.shift();
30
-
31
- return merge(target, ...sources);
32
- };
33
-
34
- const exec = (command) => {
35
- return new Promise((resolve, reject) => {
36
- childProcess.exec(
37
- command,
38
- {
39
- cwd: PROJECT_FOLDER,
40
- stdio: "pipe",
41
- },
42
- (error, stdout) => {
43
- if (error) {
44
- reject(error);
45
- } else {
46
- resolve(stdout.replace(/(\r?\n|\r)$/, ""));
47
- }
48
- }
49
- );
50
- });
51
- };
52
-
53
- const createLogger = () => {
54
- const logs = [];
55
-
56
- return {
57
- log(message, level = "log") {
58
- logs.push({ message, level });
59
- },
60
- flush() {
61
- logs.forEach(({ message, level }) => console[level](message));
62
- },
63
- };
64
- };
65
-
66
- const logger = createLogger();
67
- const writeFileToProject = (baseName, content, checkIfExists) => {
68
- if (checkIfExists) {
69
- const destFileName = path.join(PROJECT_FOLDER, baseName);
70
-
71
- if (fs.existsSync(destFileName)) {
72
- logger.log(
73
- `File ${baseName} already exists, please consider reviewing it manually`
74
- );
75
- }
76
- }
77
-
78
- return fsPromises.writeFile(
79
- path.join(PROJECT_FOLDER, baseName),
80
- content,
81
- "utf-8"
82
- );
83
- };
84
-
85
- module.exports = {
86
- exec,
87
- logger,
88
- merge,
89
- writeFileToProject,
90
- };
package/cli/index.js DELETED
@@ -1,151 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const path = require("path");
4
- const fs = require("fs");
5
- const ora = require("ora");
6
- const { exec, merge, writeFileToProject, logger } = require("./helpers");
7
- const { PROJECT_FOLDER, TEMPLATES_FOLDER } = require("./constants");
8
-
9
- const fsPromises = fs.promises;
10
-
11
- const processPkg = async () => {
12
- let rootPath = PROJECT_FOLDER;
13
- let repositoryUrl = "";
14
-
15
- try {
16
- [repositoryUrl, rootPath] = await Promise.all([
17
- exec("git remote get-url --push origin"),
18
- exec("git rev-parse --show-toplevel"),
19
- ]);
20
- } catch (error) {
21
- // Nothing
22
- }
23
-
24
- const isMonorepo = rootPath !== PROJECT_FOLDER;
25
- const directory = isMonorepo
26
- ? PROJECT_FOLDER.replace(new RegExp(`^${rootPath}/`), "")
27
- : "";
28
-
29
- let pkgConfig = {
30
- author: {
31
- name: "Ayoub Adib",
32
- email: "adbayb@gmail.com",
33
- url: "https://twitter.com/adbayb",
34
- },
35
- repository: {
36
- type: "git",
37
- url: repositoryUrl,
38
- ...(isMonorepo && { directory }),
39
- },
40
- license: "MIT",
41
- scripts: {
42
- verify: "yarn lint & tsc --noEmit",
43
- fix: "yarn lint --fix",
44
- lint: "eslint . --ignore-path .gitignore",
45
- format: "prettier . --ignore-path .gitignore --ignore-path .prettierignore --write",
46
- },
47
- prettier: "@adbayb/prettier-config",
48
- eslintConfig: {
49
- ...(isMonorepo && { root: true }), // https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
50
- extends: "@adbayb",
51
- },
52
- husky: {
53
- hooks: {
54
- "pre-commit": "lint-staged",
55
- },
56
- },
57
- "lint-staged": {
58
- "**/*.{js,jsx,ts,tsx}": ["yarn lint"],
59
- "**/*.{json,md,mdx,html,css}": ["yarn format"],
60
- },
61
- };
62
-
63
- const targetPkg = path.join(PROJECT_FOLDER, "package.json");
64
-
65
- if (fs.existsSync(targetPkg)) {
66
- pkgConfig = merge(require(targetPkg), pkgConfig);
67
- }
68
-
69
- return writeFileToProject(
70
- "package.json",
71
- JSON.stringify(pkgConfig, null, 2)
72
- );
73
- };
74
-
75
- const copyTemplates = async () => {
76
- const files = await fsPromises.readdir(TEMPLATES_FOLDER);
77
-
78
- return Promise.all(
79
- files.map(async (sourceFileName) => {
80
- return new Promise((resolve, reject) => {
81
- // @note: we suffix all templates with `.tmpl` to avoid npm publish postprocessing
82
- // By default, .gitignore and .npmrc are excluded and using "files" package.json field
83
- // solves the issue partially since npm post-transform by renaming .gitignore to .npmignore
84
- const destinationFileName = path.parse(sourceFileName).name;
85
-
86
- fs.copyFile(
87
- path.join(TEMPLATES_FOLDER, sourceFileName),
88
- path.join(PROJECT_FOLDER, destinationFileName),
89
- (error) => {
90
- if (error) {
91
- reject(error.toString());
92
- } else {
93
- resolve();
94
- }
95
- }
96
- );
97
- });
98
- })
99
- );
100
- };
101
-
102
- const install = async () => {
103
- await exec("yarn add typescript@latest --dev");
104
- await exec("yarn add eslint@latest --dev");
105
- await exec("yarn add prettier@latest --dev");
106
- await exec("yarn add @adbayb/eslint-config@latest --dev");
107
- await exec("yarn add @adbayb/prettier-config@latest --dev");
108
- await exec("yarn add @adbayb/ts-config@latest --dev");
109
- await exec("yarn add @adbayb/create@latest --dev"); // @todo: replace with @adbayb/scripts once ready (scripts should hoist the husky and other core dev packages)
110
- };
111
-
112
- const clean = async () => {
113
- try {
114
- await exec("yarn lint");
115
- await exec("yarn format");
116
- } catch (error) {
117
- // @note: encapsulate lint/format logic to be error tolerant in case of new project without any files
118
- }
119
- };
120
-
121
- const run = async () => {
122
- const spinner = ora().start();
123
- const runStep = async (message, asyncFunction) => {
124
- try {
125
- spinner.start();
126
- spinner.text = message;
127
- await asyncFunction();
128
- spinner.succeed();
129
- } catch (error) {
130
- spinner.fail();
131
-
132
- throw error;
133
- }
134
- };
135
-
136
- await runStep("Apply templates", copyTemplates);
137
- await runStep("Process `package.json`", processPkg);
138
- await runStep("Install dependencies", install);
139
- await runStep("Verify and clean project with 🦦 standards", clean);
140
- spinner.stop();
141
- logger.flush();
142
- };
143
-
144
- // @todo: future version => add possibility to specifiy language source (typescript / javascript / ...) via cli args ?
145
- try {
146
- run();
147
- } catch (error) {
148
- logger.log(error.toString(), "error");
149
- logger.flush();
150
- process.exit(1);
151
- }
@@ -1,4 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_size = 4
@@ -1,116 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- lerna-debug.log*
8
-
9
- # Diagnostic reports (https://nodejs.org/api/report.html)
10
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11
-
12
- # Runtime data
13
- pids
14
- *.pid
15
- *.seed
16
- *.pid.lock
17
-
18
- # Directory for instrumented libs generated by jscoverage/JSCover
19
- lib-cov
20
-
21
- # Coverage directory used by tools like istanbul
22
- coverage
23
- *.lcov
24
-
25
- # nyc test coverage
26
- .nyc_output
27
-
28
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29
- .grunt
30
-
31
- # Bower dependency directory (https://bower.io/)
32
- bower_components
33
-
34
- # node-waf configuration
35
- .lock-wscript
36
-
37
- # Compiled binary addons (https://nodejs.org/api/addons.html)
38
- build/Release
39
-
40
- # Dependency directories
41
- node_modules/
42
- jspm_packages/
43
-
44
- # Snowpack dependency directory (https://snowpack.dev/)
45
- web_modules/
46
-
47
- # TypeScript cache
48
- *.tsbuildinfo
49
-
50
- # Optional npm cache directory
51
- .npm
52
-
53
- # Optional eslint cache
54
- .eslintcache
55
-
56
- # Microbundle cache
57
- .rpt2_cache/
58
- .rts2_cache_cjs/
59
- .rts2_cache_es/
60
- .rts2_cache_umd/
61
-
62
- # Optional REPL history
63
- .node_repl_history
64
-
65
- # Output of 'npm pack'
66
- *.tgz
67
-
68
- # Yarn Integrity file
69
- .yarn-integrity
70
-
71
- # dotenv environment variables file
72
- .env
73
- .env.test
74
-
75
- # parcel-bundler cache (https://parceljs.org/)
76
- .cache
77
- .parcel-cache
78
-
79
- # Next.js build output
80
- .next
81
- out
82
-
83
- # Nuxt.js build / generate output
84
- .nuxt
85
- dist
86
-
87
- # Gatsby files
88
- .cache/
89
- # Comment in the public line in if your project uses Gatsby and not Next.js
90
- # https://nextjs.org/blog/next-9-1#public-directory-support
91
- # public
92
-
93
- # vuepress build output
94
- .vuepress/dist
95
-
96
- # Serverless directories
97
- .serverless/
98
-
99
- # FuseBox cache
100
- .fusebox/
101
-
102
- # DynamoDB Local files
103
- .dynamodb/
104
-
105
- # TernJS port file
106
- .tern-port
107
-
108
- # Stores VSCode versions used for testing VSCode extensions
109
- .vscode-test
110
-
111
- # yarn v2
112
- .yarn/cache
113
- .yarn/unplugged
114
- .yarn/build-state.yml
115
- .yarn/install-state.gz
116
- .pnp.*
@@ -1 +0,0 @@
1
- save-exact=true
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@adbayb/ts-config"
3
- }