@airfleet/generator-init 0.3.1 → 0.4.0

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
@@ -22,6 +22,7 @@ npm install -g @airfleet/generator-init
22
22
  | --------- | ------------------------------------- | ----------------------------------------- |
23
23
  | Block | `yo @airfleet/init:block --force` | Create a block for the Airfleet Theme |
24
24
  | Component | `yo @airfleet/init:component --force` | Create a component for the Airfleet Theme |
25
+ | npm | `yo @airfleet/init:npm --force` | Generate an npm package for publishing |
25
26
 
26
27
  ## Documentation
27
28
 
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ import Generator from "yeoman-generator";
3
+
4
+ import nameCases from "../../utils/nameCases.js";
5
+ import copyTemplates from "../../utils/copyTemplates.js";
6
+ import mapFilesToTemplates from "../../utils/mapFilesToTemplates.js";
7
+ import requiredText from "../../utils/validation/requiredText.js";
8
+ import title from "../../utils/log/title.js";
9
+ import highlightText from "../../utils/log/text/highlightText.js";
10
+ import lines from "../../utils/log/text/lines.js";
11
+ import brandText from "../../utils/log/text/brandText.js";
12
+ import dangerText from "../../utils/log/text/dangerText.js";
13
+ import infoBox from "../../utils/log/boxes/infoBox.js";
14
+
15
+ export default class extends Generator {
16
+ async prompting() {
17
+ this.log(
18
+ lines([
19
+ title(`Let's generate an ${highlightText("npm package")}!`),
20
+ infoBox(
21
+ lines([
22
+ "This will create an npm package that will be",
23
+ `published to npm under the ${brandText("airfleet")} scope`,
24
+ "as soon as the changes are pushed to the main",
25
+ "branch.",
26
+ "",
27
+ dangerText("Make sure to add a feature in code and update"),
28
+ dangerText("change log before merging to main branch!"),
29
+ "",
30
+ "Before starting you should have:",
31
+ " - Created a repository",
32
+ " - Created the Notion page (can start empty)",
33
+ "",
34
+ "All the files will be created in the current",
35
+ "folder. Make sure to navigate to repo folder",
36
+ "first.",
37
+ ])
38
+ ),
39
+ "",
40
+ ])
41
+ );
42
+
43
+ const prompts = [
44
+ {
45
+ type: "input",
46
+ name: "npmName",
47
+ message: "What is the name of the npm package? (will be prescoped with \"@airfleet\")",
48
+ validate: requiredText("Please enter a name"),
49
+ },
50
+ {
51
+ type: "input",
52
+ name: "npmTitle",
53
+ message: "What is the title of the npm package?",
54
+ validate: requiredText("Please enter a title"),
55
+ },
56
+ {
57
+ type: "input",
58
+ name: "npmDescription",
59
+ message: "How would you describe the npm package?",
60
+ validate: requiredText("Please enter a description"),
61
+ },
62
+ {
63
+ type: "input",
64
+ name: "npmRepository",
65
+ message: "What's the repository URL? (start with https and end with .git)",
66
+ validate: requiredText("Please enter the repository URL"),
67
+ },
68
+ {
69
+ type: "input",
70
+ name: "npmDocumentationUrl",
71
+ message: "What's the documentation URL? (Notion page)",
72
+ validate: requiredText("Please enter the documentation URL"),
73
+ },
74
+ {
75
+ type: "input",
76
+ name: "npmNodeVersion",
77
+ message: "What's the required Node version?",
78
+ validate: requiredText("Please enter the Node version"),
79
+ default: ">=14",
80
+ },
81
+ ];
82
+
83
+ this.answers = await this.prompt(prompts);
84
+ this.name = nameCases(this.answers.npmName);
85
+ this.data = {
86
+ answers: this.answers,
87
+ name: this.name,
88
+ packageName: `@airfleet/${this.name.slug}`,
89
+ repositoryBase: this.answers.npmRepository.replace(/\.git$/, ""),
90
+ year: new Date().getFullYear(),
91
+ };
92
+ }
93
+
94
+ writing() {
95
+ const files = [
96
+ ".airfleet-release",
97
+ ".editorconfig",
98
+ ".gitattributes",
99
+ ".gitignore",
100
+ ".gitlab-ci.yml",
101
+ "CHANGELOG.md",
102
+ "LICENSE.ejs",
103
+ "package.json.ejs",
104
+ "README.md.ejs",
105
+ ];
106
+ const templates = mapFilesToTemplates(files);
107
+
108
+ copyTemplates(this, templates, this.data);
109
+ }
110
+ }
@@ -0,0 +1 @@
1
+ minor
@@ -0,0 +1,18 @@
1
+ # editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ end_of_line = lf
8
+ indent_style = space
9
+ indent_size = 2
10
+ trim_trailing_whitespace = true
11
+ insert_final_newline = true
12
+
13
+ [*.md]
14
+ trim_trailing_whitespace = false
15
+
16
+ [*.php]
17
+ indent_style = tab
18
+ indent_size = 4
@@ -0,0 +1,11 @@
1
+ *.js eol=lf
2
+ *.jsx eol=lf
3
+ *.ts eol=lf
4
+ *.tsx eol=lf
5
+ *.json eol=lf
6
+ *.md eol=lf
7
+ *.yml eol=lf
8
+ *.yaml eol=lf
9
+ *.css eol=lf
10
+ *.scss eol=lf
11
+ *.php eol=lf
@@ -0,0 +1,8 @@
1
+ stages:
2
+ - release
3
+
4
+ include:
5
+ # Release process
6
+ - project: 'codersclan/tools/gitlab-ci-templates'
7
+ ref: main
8
+ file: '/release/npm.yaml'
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
+ and this project adheres to [Semantic Versioning](http://semver.org/).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
@@ -0,0 +1,2 @@
1
+ Copyright (c) <%= year %> Airfleet <dev@airfleet.co> (https://www.airfleet.co/)
2
+ All rights reserved.
@@ -0,0 +1,20 @@
1
+ # <%= answers.npmTitle %>
2
+
3
+ ![npm](https://img.shields.io/npm/v/<%= packageName %>)
4
+ [![pipeline status](<%= repositoryBase %>/badges/main/pipeline.svg)](<%= repositoryBase %>/-/commits/main)
5
+
6
+ <%= answers.npmDescription %>
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install --save-dev <%= packageName %>
12
+ ```
13
+
14
+ ## Documentation
15
+
16
+ - [Documentation](<%= answers.npmDocumentationUrl %>).
17
+
18
+ ## License
19
+
20
+ © [Airfleet](https://www.airfleet.co/)
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "<%= packageName %>",
3
+ "description": "<%= answers.npmDescription %>",
4
+ "version": "0.0.0",
5
+ "scripts": {},
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "keywords": [
10
+ "airfleet"
11
+ ],
12
+ "homepage": "https://www.airfleet.co",
13
+ "author": {
14
+ "name": "Airfleet",
15
+ "email": "dev@airfleet.co",
16
+ "url": "https://www.airfleet.co/"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "<%= answers.npmRepository %>"
21
+ },
22
+ "type": "module",
23
+ "engines": {
24
+ "node": "<%- answers.npmNodeVersion %>"
25
+ },
26
+ "dependencies": {}
27
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airfleet/generator-init",
3
3
  "description": "A Yeoman generator to scaffold common Airfleet features",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "scripts": {},
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -38,9 +38,5 @@
38
38
  "title-case": "^3.0.3",
39
39
  "yeoman-generator": "^5.4.2",
40
40
  "yosay": "^2.0.2"
41
- },
42
- "devDependencies": {
43
- "@release-it/keep-a-changelog": "^2.3.0",
44
- "release-it": "^14.11.7"
45
41
  }
46
42
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Take a list of strings and create objects to be passed to `copyTemplates`.
3
+ * Assumes all files/templates will be copied to the same directory.
4
+ *
5
+ * @param {string[]} files Template files.
6
+ */
7
+ export default function mapFilesToTemplates(files) {
8
+ return files.map((file) => ({
9
+ template: file,
10
+ destination: file.replace(/\.ejs$/, ""),
11
+ isEnabled: true,
12
+ }));
13
+ }