putout 29.14.0 → 29.15.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/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2023.06.15, v29.15.0
2
+
3
+ feature:
4
+ - 69bee138c @putout/cli-staged: move out from putout
5
+
1
6
  2023.06.15, v29.14.0
2
7
 
3
8
  feature:
package/lib/cli/index.js CHANGED
@@ -42,6 +42,7 @@ const {
42
42
  CANNOT_LINT_STAGED,
43
43
  } = require('./exit-codes');
44
44
 
45
+ const {isSupported} = supportedFiles;
45
46
  const getFormatter = nanomemoize(require('./formatter').getFormatter);
46
47
 
47
48
  const cwd = process.cwd();
@@ -240,11 +241,12 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
240
241
  const stagedNames = [];
241
242
 
242
243
  if (staged) {
243
- const {get} = require('./staged');
244
+ const {get} = require('@putout/cli-staged');
244
245
  const {findUp} = await simpleImport('find-up');
245
246
 
246
247
  const [error, names] = await tryToCatch(get, {
247
248
  findUp,
249
+ isSupported,
248
250
  });
249
251
 
250
252
  if (error)
@@ -341,7 +343,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
341
343
  }
342
344
 
343
345
  if (fix && staged) {
344
- const {set} = require('./staged');
346
+ const {set} = require('@putout/cli-staged');
345
347
  const {findUp} = await simpleImport('find-up');
346
348
 
347
349
  const stagedNames = await set({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "29.14.0",
3
+ "version": "29.15.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
@@ -50,6 +50,7 @@
50
50
  "@putout/cli-keypress": "^1.0.0",
51
51
  "@putout/cli-match": "^2.0.0",
52
52
  "@putout/cli-ruler": "^3.0.0",
53
+ "@putout/cli-staged": "^1.0.0",
53
54
  "@putout/cli-validate-args": "^1.0.0",
54
55
  "@putout/compare": "^10.0.0",
55
56
  "@putout/engine-loader": "^9.0.0",
@@ -66,7 +67,6 @@
66
67
  "@putout/formatter-progress": "^4.0.0",
67
68
  "@putout/formatter-progress-bar": "^3.0.0",
68
69
  "@putout/formatter-stream": "^4.0.0",
69
- "@putout/git-status-porcelain": "^3.0.0",
70
70
  "@putout/operate": "^8.0.0",
71
71
  "@putout/operator-add-args": "^4.0.0",
72
72
  "@putout/operator-declare": "^5.0.0",
package/lib/cli/staged.js DELETED
@@ -1,70 +0,0 @@
1
- 'use strict';
2
-
3
- const {join} = require('path');
4
- const {spawnSync} = require('child_process');
5
-
6
- const porcelain = require('@putout/git-status-porcelain');
7
- const once = require('once');
8
- const fullstore = require('fullstore');
9
- const {isSupported} = require('./supported-files');
10
-
11
- const namesStore = fullstore([]);
12
-
13
- const findGit = once(async ({findUp}) => {
14
- const type = 'directory';
15
-
16
- const gitDir = await findUp('.git', {
17
- type,
18
- });
19
-
20
- if (!gitDir)
21
- throw Error('not git repository');
22
-
23
- const dir = gitDir.replace(/\.git$/, '');
24
-
25
- return dir;
26
- });
27
-
28
- const joinDir = (a) => (b) => join(a, b);
29
-
30
- module.exports.get = async function get({findUp}) {
31
- const dir = await findGit({
32
- findUp,
33
- });
34
-
35
- const names = porcelain({
36
- modified: true,
37
- added: true,
38
- }).filter(isSupported);
39
-
40
- namesStore(names);
41
-
42
- return names.map(joinDir(dir));
43
- };
44
-
45
- module.exports.set = async function set({findUp}) {
46
- const dir = await findGit({
47
- findUp,
48
- });
49
-
50
- const names = namesStore();
51
-
52
- const staged = porcelain({
53
- unstaged: true,
54
- });
55
-
56
- const namesToAdd = [];
57
-
58
- for (const filepath of names) {
59
- if (!staged.includes(filepath))
60
- namesToAdd.push(filepath);
61
- }
62
-
63
- add(namesToAdd.map(joinDir(dir)));
64
-
65
- return staged;
66
- };
67
-
68
- function add(names) {
69
- spawnSync('git', ['add', ...names]);
70
- }