@baic/yolk-cli 2.1.0-alpha.56 → 2.1.0-alpha.57

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.
@@ -0,0 +1,267 @@
1
+ /******/ (function() { // webpackBootstrap
2
+ /******/ var __webpack_modules__ = ({
3
+
4
+ /***/ 925:
5
+ /***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
6
+
7
+ var spawn = (__nccwpck_require__(81).spawn);
8
+ var fs = __nccwpck_require__(147);
9
+
10
+
11
+ var sgf = function (options = {}, callback) {
12
+ const typeOfOptions = typeof options;
13
+ let filter;
14
+
15
+ if (typeOfOptions === 'function') {
16
+ callback = options;
17
+ filter = undefined;
18
+ } else if (typeOfOptions === 'string') {
19
+ filter = options;
20
+ } else {
21
+ filter = options.filter;
22
+ }
23
+
24
+ if (typeof callback === 'undefined') {
25
+ return new Promise(function (resolve, reject) {
26
+ _sgf(filter, function (err, head) {
27
+ if (err)
28
+ return reject(err);
29
+ resolve(head);
30
+ }, options);
31
+ });
32
+ } else {
33
+ _sgf(filter, callback, options);
34
+ }
35
+ };
36
+
37
+
38
+ function _sgf (filter, callback, options) {
39
+ if (typeof filter === 'undefined')
40
+ filter = 'ACDMRTUXB';
41
+
42
+ sgf.getHead(function(err, head) {
43
+ if (err) {
44
+ callback(err);
45
+ } else {
46
+ var command = "git -c core.quotepath=false diff-index --cached --name-status";
47
+
48
+ if (options.relative) {
49
+ command += " --relative";
50
+ }
51
+ if (filter.indexOf('R') !== -1) {
52
+ command += " -M";
53
+ }
54
+
55
+ command += " --diff-filter=" + filter + " " + head;
56
+
57
+ run(command, function(err, stdout, stderr) {
58
+ if (err || stderr) {
59
+ callback(err || new Error(stderr));
60
+ } else {
61
+ callback(null, stdoutToResultsObject(stdout));
62
+ }
63
+ });
64
+ }
65
+ });
66
+ };
67
+
68
+
69
+ sgf.cwd = process.cwd();
70
+ sgf.debug = false;
71
+ sgf.includeContent = false;
72
+
73
+ // sgf.firstHead = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
74
+
75
+ sgf.getHead = function(callback) {
76
+ run("git rev-parse --verify HEAD", function(err, stdout, stderr) {
77
+ if (err && err.message.indexOf("fatal: Needed a single revision")!==-1) {
78
+ // callback(null, sgf.firstHead);
79
+ run("git hash-object -t tree /dev/null", function(err, stdout, stderr) {
80
+ if (err || stderr) {
81
+ callback(err || new Error("STDERR: " + stderr));
82
+ } else {
83
+ stdout = stdout.replace("\n", "");
84
+ callback(null, stdout);
85
+ }
86
+ });
87
+ } else if (err || stderr) {
88
+ callback(err || new Error("STDERR: " + stderr));
89
+ } else {
90
+ stdout = stdout.replace("\n", "");
91
+ callback(null, stdout);
92
+ }
93
+ });
94
+ }
95
+
96
+ sgf.readFile = function(filename, options, callback) {
97
+ fs.readFile(sgf.cwd + "/" + filename, options, callback);
98
+ }
99
+
100
+
101
+ module.exports = sgf;
102
+
103
+ /** ======================================== HELPERS ======================================== **/
104
+
105
+ var run = function(command, callback) {
106
+ if (sgf.debug) {
107
+ console.log("RUNNING: " + command);
108
+ }
109
+
110
+ var bits = command.split(" ");
111
+ var args = bits.slice(1);
112
+
113
+ var cmd = spawn(bits[0], args, {
114
+ cwd: module.exports.cwd
115
+ });
116
+
117
+ var stdout = "";
118
+ var stderr = "";
119
+
120
+ cmd.stdout.on('data', function(data){
121
+ stdout+=data.toString();
122
+ });
123
+
124
+ cmd.stderr.on('data', function(data){
125
+ stderr+=data.toString();
126
+ });
127
+
128
+ cmd.on("close", function(code){
129
+ var err = null;
130
+
131
+ if(code!==0){
132
+ err = new Error(stderr);
133
+ }
134
+
135
+ callback(err,stdout,stderr);
136
+ });
137
+ }
138
+
139
+ var codeToStatus = function(code) {
140
+ /* =======================================================================================================
141
+ ** PER docs at https://git-scm.com/docs/git-diff-index
142
+ ** Possible status letters are:
143
+ ** A: addition of a file
144
+ ** C: copy of a file into a new one
145
+ ** D: deletion of a file
146
+ ** M: modification of the contents or mode of a file
147
+ ** R: renaming of a file
148
+ ** T: change in the type of the file
149
+ ** U: file is unmerged (you must complete the merge before it can be committed)
150
+ ** X: "unknown" change type (most probably a bug, please report it)
151
+ **
152
+ ** Status letters C and R are always followed by a score
153
+ ** (denoting the percentage of similarity between the source and target of the move or copy).
154
+ ** Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.
155
+ ** ======================================================================================================= */
156
+
157
+ var map = {
158
+ "A": "Added",
159
+ "C": "Copied",
160
+ "D": "Deleted",
161
+ "M": "Modified",
162
+ "R": "Renamed",
163
+ "T": "Type-Change",
164
+ "U": "Unmerged",
165
+ "X": "Unknown",
166
+ "B": "Broken"
167
+ }
168
+
169
+ return map[code.charAt(0)];
170
+ }
171
+
172
+ var stdoutToResultsObject = function(stdout) {
173
+ var results = [];
174
+ var lines = stdout.split("\n");
175
+ var iLines = lines.length;
176
+ var files_with_errors = 0;
177
+ while (iLines--) {
178
+ var line = lines[iLines];
179
+ if (line != "") {
180
+ var parts = line.split("\t");
181
+ var result = {
182
+ filename: parts[2] || parts[1],
183
+ status: codeToStatus(parts[0])
184
+ }
185
+
186
+ if (sgf.includeContent) {
187
+ try {
188
+ result.content = fs.readFileSync(sgf.cwd + "/" + result.filename, {
189
+ encoding: "utf8"
190
+ });
191
+ } catch (err) {
192
+ result.err = err;
193
+ }
194
+ }
195
+
196
+ results.push(result);
197
+ }
198
+ }
199
+ return results;
200
+ }
201
+
202
+
203
+ /***/ }),
204
+
205
+ /***/ 81:
206
+ /***/ (function(module) {
207
+
208
+ "use strict";
209
+ module.exports = require("child_process");
210
+
211
+ /***/ }),
212
+
213
+ /***/ 147:
214
+ /***/ (function(module) {
215
+
216
+ "use strict";
217
+ module.exports = require("fs");
218
+
219
+ /***/ })
220
+
221
+ /******/ });
222
+ /************************************************************************/
223
+ /******/ // The module cache
224
+ /******/ var __webpack_module_cache__ = {};
225
+ /******/
226
+ /******/ // The require function
227
+ /******/ function __nccwpck_require__(moduleId) {
228
+ /******/ // Check if module is in cache
229
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
230
+ /******/ if (cachedModule !== undefined) {
231
+ /******/ return cachedModule.exports;
232
+ /******/ }
233
+ /******/ // Create a new module (and put it into the cache)
234
+ /******/ var module = __webpack_module_cache__[moduleId] = {
235
+ /******/ // no module.id needed
236
+ /******/ // no module.loaded needed
237
+ /******/ exports: {}
238
+ /******/ };
239
+ /******/
240
+ /******/ // Execute the module function
241
+ /******/ var threw = true;
242
+ /******/ try {
243
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
244
+ /******/ threw = false;
245
+ /******/ } finally {
246
+ /******/ if(threw) delete __webpack_module_cache__[moduleId];
247
+ /******/ }
248
+ /******/
249
+ /******/ // Return the exports of the module
250
+ /******/ return module.exports;
251
+ /******/ }
252
+ /******/
253
+ /************************************************************************/
254
+ /******/ /* webpack/runtime/compat */
255
+ /******/
256
+ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
257
+ /******/
258
+ /************************************************************************/
259
+ /******/
260
+ /******/ // startup
261
+ /******/ // Load entry module and return exports
262
+ /******/ // This entry module is referenced by other modules so it can't be inlined
263
+ /******/ var __webpack_exports__ = __nccwpck_require__(925);
264
+ /******/ module.exports = __webpack_exports__;
265
+ /******/
266
+ /******/ })()
267
+ ;
@@ -0,0 +1 @@
1
+ {"name":"staged-git-files","author":"Matthew Chase Whittemore <mcwhittemore@gmail.com>","license":"BSD-2-Clause"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baic/yolk-cli",
3
- "version": "2.1.0-alpha.56",
3
+ "version": "2.1.0-alpha.57",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/303394539/yolk.git"
@@ -14,6 +14,7 @@
14
14
  "yolk": "lib/index.js"
15
15
  },
16
16
  "files": [
17
+ "compiled",
17
18
  "lib",
18
19
  "es",
19
20
  "templates"
@@ -50,5 +51,5 @@
50
51
  "publishConfig": {
51
52
  "access": "public"
52
53
  },
53
- "gitHead": "932f264ef9b2898967765df98d59f270326a7bc1"
54
+ "gitHead": "7119f1f025da6f5c50e917010f20ad0415d39a95"
54
55
  }