happy 0.13.3 → 0.13.4

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.
Files changed (3) hide show
  1. package/README.md +109 -11
  2. package/package.json +4 -2
  3. package/src/save.js +4 -3
package/README.md CHANGED
@@ -67,26 +67,122 @@ $ happy --help
67
67
 
68
68
  It makes sure your project is ready to deploy, and then deploy it. For this, these are the steps:
69
69
 
70
- - "Building project": run `npm run build` *if* the `"build"` script is found in your `package.json`.
71
- - "Linting": run `npm run lint` *if* the `"lint"` script is found in the project `package.json`.
72
- - "Testing project": run `npm test` *if* the `"test"` script is found in the project `package.json`.
73
- - "Saving changes": add all of the files with git, equivalent to `git add . && git commit -m "Saved on $TIME"`. Provide a message for a custom git message.
74
- - "Downloading latest": git pull
75
- - "Uploading changes": git push
76
- - "Publish to npm": _only_ if the `--publish` flag is passed, publish it to npm.
70
+ - ["Building project"](#building-project): run `npm run build` *if* the `"build"` script is found in your `package.json`.
71
+ - ["Linting"](#linting): run `npm run lint` *if* the `"lint"` script is found in the project `package.json`.
72
+ - ["Testing project"](#testing-project): run `npm test` *if* the `"test"` script is found in the project `package.json`.
73
+ - ["Saving changes"](#saving-changes): add all of the files with git, equivalent to `git add . && git commit -m "Saved on $TIME"`. Provide a message for a custom git message.
74
+ - ["Downloading latest"](#downloading-latest): git pull
75
+ - ["Uploading changes"](#uploading-changes): git push
76
+ - ["Publish to npm"](#publish-to-npm): _only_ if the `--publish` flag is passed, publish it to npm.
77
77
 
78
78
 
79
- Run it with a string to use it as a commit string:
79
+
80
+ ### Building project
81
+
82
+ Run the `npm run build` script *if* this script is found in your `package.json` configuration. Example:
83
+
84
+ ```json
85
+ {
86
+ "scripts": {
87
+ "build": "rollup -c"
88
+ }
89
+ }
90
+ ```
91
+
92
+ This step will be **skipped** if:
93
+ - The script `"build"` is not found in the project `package.json`.
94
+ - The flag `--now` was passed.
95
+
96
+
97
+
98
+ ### Linting
99
+
100
+ Run the `npm run lint` script *if* this script is found in your `package.json` configuration. Example:
101
+
102
+ ```json
103
+ {
104
+ "scripts": {
105
+ "lint": "eslint"
106
+ }
107
+ }
108
+ ```
109
+
110
+ This step will be **skipped** if:
111
+ - The script `"lint"` is not found in the project `package.json`.
112
+ - The flag `--now` was passed.
113
+
114
+
115
+
116
+ ### Testing project
117
+
118
+ Run the `npm test` script *if* this script is found in your `package.json` configuration. Example:
119
+
120
+ ```json
121
+ {
122
+ "scripts": {
123
+ "test": "jest"
124
+ }
125
+ }
126
+ ```
127
+
128
+ The test script will also set the environment variable CI=true to avoid [some common issues](https://stackoverflow.com/a/56917151/938236).
129
+
130
+ This step will be **skipped** if:
131
+ - The script `"test"` is not found in the project `package.json`.
132
+ - The flag `--now` was passed.
133
+
134
+
135
+
136
+ ### Saving Changes
137
+
138
+ This is the equivalent of _adding_ and _commiting_ the changed files to Git. The message for the commit is the string that you pass:
80
139
 
81
140
  ```bash
82
141
  happy "Added that new cool feature"
83
142
  ```
84
143
 
85
- Add a `--now` to skip building, linting and testing. It _only_ runs these if they are found, so no need for `--now` if you don't have any of these npm scripts:
144
+ When no string is provided, it will save the changes with a generic commit with the current timestamp like:
86
145
 
87
- ```bash
88
- happy --now
89
146
  ```
147
+ Saved on 2020-08-13T10:20:00Z
148
+ ```
149
+
150
+ This step will be **skipped** if:
151
+ - There are no changes to add or commit.
152
+ - The changes were already commited.
153
+
154
+
155
+
156
+ ### Downloading latest
157
+
158
+ Try to pull the latest changes from the remote repo to combine them locally. It will exit if there's a problem with the merge so that you can merge it manually.
159
+
160
+ > This step might take longer than the others since it talks to your git server.
161
+
162
+ This step will be **skipped** if:
163
+ - There were no changes in the remote repo (you are up to date).
164
+
165
+ This step will **throw an error** if:
166
+ - The origin is not set.
167
+
168
+ > TODO: ask/fix the origin if it's not set
169
+
170
+
171
+
172
+ ### Uploading changes
173
+
174
+ Take all of your changes and upload them to the `origin` that is set in your project. This is specially useful when combined with e.g. Heroku, and you set heroku as the origin, since it will also deploy the full website.
175
+
176
+ This step takes longer than the others since it's talking to your git server.
177
+
178
+ This step will be **skipped** if:
179
+ - There were no changes in the local repo.
180
+
181
+
182
+
183
+ ### Publish to npm
184
+
185
+ > You need to have the library `np` installed for this, please do `npm i np -g`
90
186
 
91
187
  Add a `--publish VERSION` flag to publish the current package to npm with [np](https://github.com/sindresorhus/np#readme):
92
188
 
@@ -107,3 +203,5 @@ happy --major
107
203
 
108
204
  happy --publish 5.0.0
109
205
  ```
206
+
207
+
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "happy",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "description": "Happy simplifies your day-to-day git workflow",
5
5
  "author": "Francisco Presencia <public@francisco.io> (https://francisco.io/)",
6
- "funding": "https://www.paypal.me/franciscopresencia/19",
6
+ "funding": {
7
+ "url": "https://www.paypal.me/franciscopresencia/19"
8
+ },
7
9
  "license": "MIT",
8
10
  "scripts": {},
9
11
  "homepage": "https://github.com/franciscop/happy",
package/src/save.js CHANGED
@@ -9,9 +9,10 @@ module.exports = (cli) => ({
9
9
  title: "Saving changes",
10
10
  skip: async () => {
11
11
  const status = await cmd(`git status`);
12
- const hasEdited = /Changes not staged for commit/.test(status);
13
- const hasUncommited = /Changes to be committed/.test(status);
14
- if (!hasEdited && !hasUncommited) return true;
12
+ const hasAdded = /untracked files present/i.test(status);
13
+ const hasEdited = /Changes not staged for commit/i.test(status);
14
+ const hasUncommited = /Changes to be committed/i.test(status);
15
+ if (!hasAdded && !hasEdited && !hasUncommited) return true;
15
16
  },
16
17
  task: async () => {
17
18
  const message = cli.input[0] || `Saved on ${time()}`;