@alfalab/core-components-steps 1.1.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/Component.d.ts +89 -0
- package/Component.js +59 -0
- package/components/step/Component.d.ts +70 -0
- package/components/step/Component.js +126 -0
- package/components/step/index.css +151 -0
- package/components/step/index.d.ts +1 -0
- package/components/step/index.js +17 -0
- package/components/step-indicator/Component.d.ts +6 -0
- package/components/step-indicator/Component.js +22 -0
- package/components/step-indicator/index.css +4 -0
- package/components/step-indicator/index.d.ts +1 -0
- package/components/step-indicator/index.js +12 -0
- package/cssm/Component.d.ts +89 -0
- package/cssm/Component.js +60 -0
- package/cssm/components/step/Component.d.ts +70 -0
- package/cssm/components/step/Component.js +126 -0
- package/cssm/components/step/index.d.ts +1 -0
- package/cssm/components/step/index.js +19 -0
- package/cssm/components/step/index.module.css +150 -0
- package/cssm/components/step-indicator/Component.d.ts +6 -0
- package/cssm/components/step-indicator/Component.js +21 -0
- package/cssm/components/step-indicator/index.d.ts +1 -0
- package/cssm/components/step-indicator/index.js +13 -0
- package/cssm/components/step-indicator/index.module.css +3 -0
- package/cssm/index.d.ts +1 -0
- package/cssm/index.js +21 -0
- package/cssm/index.module.css +17 -0
- package/esm/Component.d.ts +89 -0
- package/esm/Component.js +50 -0
- package/esm/components/step/Component.d.ts +70 -0
- package/esm/components/step/Component.js +117 -0
- package/esm/components/step/index.css +151 -0
- package/esm/components/step/index.d.ts +1 -0
- package/esm/components/step/index.js +9 -0
- package/esm/components/step-indicator/Component.d.ts +6 -0
- package/esm/components/step-indicator/Component.js +13 -0
- package/esm/components/step-indicator/index.css +4 -0
- package/esm/components/step-indicator/index.d.ts +1 -0
- package/esm/components/step-indicator/index.js +4 -0
- package/esm/index.css +18 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +10 -0
- package/index.css +18 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/modern/Component.d.ts +89 -0
- package/modern/Component.js +48 -0
- package/modern/components/step/Component.d.ts +70 -0
- package/modern/components/step/Component.js +85 -0
- package/modern/components/step/index.css +151 -0
- package/modern/components/step/index.d.ts +1 -0
- package/modern/components/step/index.js +9 -0
- package/modern/components/step-indicator/Component.d.ts +6 -0
- package/modern/components/step-indicator/Component.js +12 -0
- package/modern/components/step-indicator/index.css +4 -0
- package/modern/components/step-indicator/index.d.ts +1 -0
- package/modern/components/step-indicator/index.js +4 -0
- package/modern/index.css +18 -0
- package/modern/index.d.ts +1 -0
- package/modern/index.js +10 -0
- package/package.json +25 -0
- package/send-stats.js +82 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { useFocus } from '@alfalab/hooks';
|
|
4
|
+
import { CheckmarkCircleMIcon } from '@alfalab/icons-glyph/CheckmarkCircleMIcon';
|
|
5
|
+
import { ExclamationCircleMIcon } from '@alfalab/icons-glyph/ExclamationCircleMIcon';
|
|
6
|
+
import { ClockMIcon } from '@alfalab/icons-glyph/ClockMIcon';
|
|
7
|
+
import '@alfalab/core-components-badge/modern';
|
|
8
|
+
import { StepIndicator } from '../step-indicator/Component.js';
|
|
9
|
+
|
|
10
|
+
var styles = {"step":"steps__step_xhvt7","vertical":"steps__vertical_xhvt7","interactive":"steps__interactive_xhvt7","disabled":"steps__disabled_xhvt7","text":"steps__text_xhvt7","indicator":"steps__indicator_xhvt7","option":"steps__option_xhvt7","dash":"steps__dash_xhvt7","completed":"steps__completed_xhvt7","focused":"steps__focused_xhvt7","selected":"steps__selected_xhvt7","checkbox":"steps__checkbox_xhvt7","dot":"steps__dot_xhvt7","error":"steps__error_xhvt7","unordered":"steps__unordered_xhvt7","completedIndicator":"steps__completedIndicator_xhvt7"};
|
|
11
|
+
require('./index.css')
|
|
12
|
+
|
|
13
|
+
const Step = ({ children, stepNumber, isSelected, disabled, ordered, isPositive, isError, isWarning, isWaiting, customStepIndicator, isStepCompleted, onClick, interactive, isVerticalAlign, isNotLastStep, }) => {
|
|
14
|
+
const stepRef = useRef(null);
|
|
15
|
+
const [focused] = useFocus(stepRef, 'keyboard');
|
|
16
|
+
const handleButtonClick = () => {
|
|
17
|
+
if (!disabled && onClick) {
|
|
18
|
+
onClick(stepNumber);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const handleTextClick = (e) => {
|
|
22
|
+
if (!interactive) {
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const handleKeyDown = (event) => {
|
|
27
|
+
if (event.key === 'Enter') {
|
|
28
|
+
handleButtonClick();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const getStepIndicator = () => {
|
|
32
|
+
if (customStepIndicator) {
|
|
33
|
+
return React.createElement(StepIndicator, Object.assign({}, customStepIndicator));
|
|
34
|
+
}
|
|
35
|
+
if (isError) {
|
|
36
|
+
return React.createElement(StepIndicator, { iconColor: 'negative', content: React.createElement(ExclamationCircleMIcon, null) });
|
|
37
|
+
}
|
|
38
|
+
if (isWarning) {
|
|
39
|
+
return React.createElement(StepIndicator, { iconColor: 'attention', content: React.createElement(ExclamationCircleMIcon, null) });
|
|
40
|
+
}
|
|
41
|
+
if (isWaiting) {
|
|
42
|
+
return React.createElement(StepIndicator, { iconColor: 'secondary', content: React.createElement(ClockMIcon, null) });
|
|
43
|
+
}
|
|
44
|
+
if (isPositive) {
|
|
45
|
+
return React.createElement(StepIndicator, { iconColor: 'positive', content: React.createElement(CheckmarkCircleMIcon, null) });
|
|
46
|
+
}
|
|
47
|
+
if (isStepCompleted) {
|
|
48
|
+
return React.createElement(StepIndicator, { iconColor: 'positive', content: React.createElement(CheckmarkCircleMIcon, null), className: styles.completedIndicator });
|
|
49
|
+
}
|
|
50
|
+
if (!ordered) {
|
|
51
|
+
return (React.createElement("div", { className: styles.checkbox },
|
|
52
|
+
React.createElement("span", { className: styles.dot })));
|
|
53
|
+
}
|
|
54
|
+
return stepNumber;
|
|
55
|
+
};
|
|
56
|
+
const renderDash = () => (React.createElement("div", { className: cn(styles.dash, {
|
|
57
|
+
[styles.vertical]: isVerticalAlign,
|
|
58
|
+
[styles.completed]: isStepCompleted,
|
|
59
|
+
}) }));
|
|
60
|
+
return (React.createElement("div", { role: 'button', tabIndex: 0, ref: stepRef, className: cn(styles.step, {
|
|
61
|
+
[styles.completed]: isStepCompleted,
|
|
62
|
+
[styles.error]: isError,
|
|
63
|
+
[styles.selected]: isSelected,
|
|
64
|
+
[styles.disabled]: disabled,
|
|
65
|
+
[styles.focused]: focused,
|
|
66
|
+
[styles.vertical]: isVerticalAlign,
|
|
67
|
+
[styles.interactive]: interactive,
|
|
68
|
+
}), onClick: handleButtonClick, onKeyDown: handleKeyDown },
|
|
69
|
+
React.createElement("div", { className: cn(styles.indicator, {
|
|
70
|
+
[styles.vertical]: isVerticalAlign,
|
|
71
|
+
[styles.interactive]: interactive,
|
|
72
|
+
}) },
|
|
73
|
+
React.createElement("div", { className: cn(styles.option, {
|
|
74
|
+
[styles.unordered]: !ordered,
|
|
75
|
+
[styles.vertical]: isVerticalAlign,
|
|
76
|
+
[styles.error]: isError,
|
|
77
|
+
}) }, getStepIndicator()),
|
|
78
|
+
isNotLastStep && isVerticalAlign && renderDash()),
|
|
79
|
+
React.createElement("div", { className: cn(styles.text, {
|
|
80
|
+
[styles.interactive]: interactive,
|
|
81
|
+
}), onClick: handleTextClick }, children),
|
|
82
|
+
isNotLastStep && !isVerticalAlign && renderDash()));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { Step };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* hash: j46l8 */
|
|
2
|
+
:root {
|
|
3
|
+
--color-light-border-link: #007aff;
|
|
4
|
+
--color-light-border-primary: #dbdee1;
|
|
5
|
+
--color-light-graphic-positive: #2fc26e;
|
|
6
|
+
--color-light-graphic-primary: #0b1f35;
|
|
7
|
+
--color-light-graphic-primary-inverted: #fff;
|
|
8
|
+
--color-light-graphic-quaternary: #dbdee1;
|
|
9
|
+
--color-light-text-primary: #0b1f35;
|
|
10
|
+
--color-light-bg-primary-inverted-alpha-7: rgba(11, 31, 53, 0.07);
|
|
11
|
+
--color-light-bg-primary-inverted-alpha-15: rgba(11, 31, 53, 0.15);
|
|
12
|
+
}
|
|
13
|
+
:root {
|
|
14
|
+
|
|
15
|
+
/* Hard */
|
|
16
|
+
|
|
17
|
+
/* Up */
|
|
18
|
+
|
|
19
|
+
/* Hard up */
|
|
20
|
+
}
|
|
21
|
+
:root {
|
|
22
|
+
--gap-3xs: 2px;
|
|
23
|
+
--gap-2xs: 4px;
|
|
24
|
+
--gap-xs: 8px;
|
|
25
|
+
}
|
|
26
|
+
:root {
|
|
27
|
+
--focus-color: var(--color-light-border-link);
|
|
28
|
+
}
|
|
29
|
+
:root {
|
|
30
|
+
--steps-option-svg-color: var(--color-light-graphic-positive);
|
|
31
|
+
--steps-dash-border: 2px solid var(--color-light-graphic-positive);
|
|
32
|
+
}
|
|
33
|
+
.steps__step_xhvt7 {
|
|
34
|
+
display: flex;
|
|
35
|
+
outline: none
|
|
36
|
+
}
|
|
37
|
+
.steps__step_xhvt7:not(.steps__vertical_xhvt7) {
|
|
38
|
+
align-items: center;
|
|
39
|
+
}
|
|
40
|
+
.steps__step_xhvt7.steps__interactive_xhvt7:not(.steps__disabled_xhvt7):hover {
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
.steps__step_xhvt7.steps__disabled_xhvt7:hover .steps__text_xhvt7 {
|
|
44
|
+
background: unset;
|
|
45
|
+
}
|
|
46
|
+
.steps__step_xhvt7.steps__disabled_xhvt7 .steps__indicator_xhvt7 {
|
|
47
|
+
cursor: unset;
|
|
48
|
+
}
|
|
49
|
+
.steps__indicator_xhvt7 {
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
margin-right: var(--gap-2xs)
|
|
54
|
+
}
|
|
55
|
+
.steps__indicator_xhvt7.steps__vertical_xhvt7 {
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
margin-right: var(--gap-xs);
|
|
58
|
+
}
|
|
59
|
+
.steps__option_xhvt7 {
|
|
60
|
+
font-size: 14px;
|
|
61
|
+
line-height: 20px;
|
|
62
|
+
font-weight: 700;
|
|
63
|
+
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
color: var(--color-light-graphic-primary);
|
|
68
|
+
background: var(--color-light-graphic-quaternary);
|
|
69
|
+
min-width: 24px;
|
|
70
|
+
height: 24px;
|
|
71
|
+
border-radius: 50%
|
|
72
|
+
}
|
|
73
|
+
.steps__option_xhvt7.steps__vertical_xhvt7 {
|
|
74
|
+
margin-top: var(--gap-xs);
|
|
75
|
+
}
|
|
76
|
+
.steps__dash_xhvt7 {
|
|
77
|
+
flex: 1 1 auto;
|
|
78
|
+
min-width: 24px;
|
|
79
|
+
border-top: 2px solid var(--color-light-border-primary);
|
|
80
|
+
margin-right: var(--gap-xs)
|
|
81
|
+
}
|
|
82
|
+
.steps__dash_xhvt7.steps__completed_xhvt7 {
|
|
83
|
+
border-top: var(--steps-dash-border);
|
|
84
|
+
}
|
|
85
|
+
.steps__dash_xhvt7.steps__vertical_xhvt7 {
|
|
86
|
+
min-width: unset;
|
|
87
|
+
min-height: 24px;
|
|
88
|
+
margin-right: 0;
|
|
89
|
+
margin-top: var(--gap-xs);
|
|
90
|
+
border-left: 2px solid var(--color-light-border-primary);
|
|
91
|
+
border-top: none;
|
|
92
|
+
}
|
|
93
|
+
.steps__dash_xhvt7.steps__completed_xhvt7.steps__vertical_xhvt7 {
|
|
94
|
+
border-left: var(--steps-dash-border);
|
|
95
|
+
}
|
|
96
|
+
.steps__text_xhvt7 {
|
|
97
|
+
font-size: 16px;
|
|
98
|
+
line-height: 24px;
|
|
99
|
+
font-weight: 400;
|
|
100
|
+
|
|
101
|
+
transition: background 0.2s;
|
|
102
|
+
padding: var(--gap-xs);
|
|
103
|
+
color: var(--color-light-text-primary);
|
|
104
|
+
border-radius: var(--gap-xs);
|
|
105
|
+
height: min-content
|
|
106
|
+
}
|
|
107
|
+
.steps__text_xhvt7.steps__interactive_xhvt7:not(.steps__disabled_xhvt7):hover {
|
|
108
|
+
background: var(--color-light-bg-primary-inverted-alpha-7);
|
|
109
|
+
}
|
|
110
|
+
.steps__text_xhvt7.steps__interactive_xhvt7:not(.steps__disabled_xhvt7):active {
|
|
111
|
+
background: var(--color-light-bg-primary-inverted-alpha-15);
|
|
112
|
+
}
|
|
113
|
+
.steps__focused_xhvt7 {
|
|
114
|
+
outline: var(--gap-3xs) solid var(--focus-color);
|
|
115
|
+
outline-offset: var(--gap-3xs);
|
|
116
|
+
}
|
|
117
|
+
.steps__selected_xhvt7 .steps__text_xhvt7 {
|
|
118
|
+
color: var(--color-light-graphic-primary);
|
|
119
|
+
}
|
|
120
|
+
.steps__selected_xhvt7 .steps__option_xhvt7 {
|
|
121
|
+
color: var(--color-light-graphic-primary-inverted);
|
|
122
|
+
background: var(--color-light-graphic-primary);
|
|
123
|
+
}
|
|
124
|
+
.steps__checkbox_xhvt7 {
|
|
125
|
+
display: flex;
|
|
126
|
+
justify-content: center;
|
|
127
|
+
align-items: center;
|
|
128
|
+
border-radius: 50%;
|
|
129
|
+
width: 20px;
|
|
130
|
+
height: 20px;
|
|
131
|
+
border: 2px solid var(--color-light-graphic-quaternary);
|
|
132
|
+
}
|
|
133
|
+
.steps__dot_xhvt7 {
|
|
134
|
+
width: 10px;
|
|
135
|
+
height: 10px;
|
|
136
|
+
border-radius: 50%;
|
|
137
|
+
background: var(--color-light-graphic-quaternary);
|
|
138
|
+
}
|
|
139
|
+
.steps__selected_xhvt7 .steps__checkbox_xhvt7 {
|
|
140
|
+
border: 2px solid var(--color-light-graphic-primary)
|
|
141
|
+
}
|
|
142
|
+
.steps__selected_xhvt7 .steps__checkbox_xhvt7 .steps__dot_xhvt7 {
|
|
143
|
+
background: var(--color-light-graphic-primary);
|
|
144
|
+
}
|
|
145
|
+
.steps__option_xhvt7:not(.steps__error_xhvt7).steps__unordered_xhvt7 {
|
|
146
|
+
background: unset;
|
|
147
|
+
}
|
|
148
|
+
.steps__completedIndicator_xhvt7 > [class*='positive'] {
|
|
149
|
+
color: var(--steps-option-svg-color);
|
|
150
|
+
background-color: var(--steps-option-svg-color);
|
|
151
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import 'classnames';
|
|
3
|
+
import '@alfalab/hooks';
|
|
4
|
+
import '@alfalab/icons-glyph/CheckmarkCircleMIcon';
|
|
5
|
+
import '@alfalab/icons-glyph/ExclamationCircleMIcon';
|
|
6
|
+
import '@alfalab/icons-glyph/ClockMIcon';
|
|
7
|
+
import '@alfalab/core-components-badge/modern';
|
|
8
|
+
import '../step-indicator/Component.js';
|
|
9
|
+
export { Step } from './Component.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BadgeProps } from "@alfalab/core-components-badge";
|
|
4
|
+
type StepIndicatorProps = Pick<BadgeProps, 'content' | 'iconColor' | 'className'>;
|
|
5
|
+
declare const StepIndicator: React.FC<StepIndicatorProps>;
|
|
6
|
+
export { StepIndicatorProps, StepIndicator };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Badge } from '@alfalab/core-components-badge/modern';
|
|
4
|
+
|
|
5
|
+
var styles = {"component":"steps__component_19vei"};
|
|
6
|
+
require('./index.css')
|
|
7
|
+
|
|
8
|
+
const StepIndicator = ({ content, iconColor, className }) => {
|
|
9
|
+
return (React.createElement(Badge, { size: 'l', view: 'icon', iconColor: iconColor, className: cn(styles.component, className), content: content }));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { StepIndicator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
package/modern/index.css
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* hash: hx0e0 */
|
|
2
|
+
:root {
|
|
3
|
+
|
|
4
|
+
/* Hard */
|
|
5
|
+
|
|
6
|
+
/* Up */
|
|
7
|
+
|
|
8
|
+
/* Hard up */
|
|
9
|
+
}
|
|
10
|
+
.steps__component_rm960 {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
flex-direction: row
|
|
14
|
+
}
|
|
15
|
+
.steps__component_rm960.steps__vertical_rm960 {
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
align-items: flex-start;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
package/modern/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import 'classnames';
|
|
3
|
+
import '@alfalab/hooks';
|
|
4
|
+
import '@alfalab/icons-glyph/CheckmarkCircleMIcon';
|
|
5
|
+
import '@alfalab/icons-glyph/ExclamationCircleMIcon';
|
|
6
|
+
import '@alfalab/icons-glyph/ClockMIcon';
|
|
7
|
+
import '@alfalab/core-components-badge/modern';
|
|
8
|
+
import './components/step-indicator/Component.js';
|
|
9
|
+
import './components/step/Component.js';
|
|
10
|
+
export { Steps } from './Component.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alfalab/core-components-steps",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"module": "./esm/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node -e \"if (require('fs').existsSync('./send-stats.js')){require('./send-stats.js')} \""
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"directory": "dist"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@alfalab/core-components-badge": "^4.0.1",
|
|
21
|
+
"@alfalab/hooks": "^1.13.0",
|
|
22
|
+
"@alfalab/icons-glyph": "^2.64.0",
|
|
23
|
+
"classnames": "^2.3.1"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/send-stats.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const http = require('http');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const { promisify } = require('util');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const readFile = promisify(fs.readFile);
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const remoteHost = process.env.NIS_HOST || 'digital';
|
|
10
|
+
const remotePort = process.env.NIS_PORT || 80;
|
|
11
|
+
const remotePath = process.env.NIS_PATH || '/npm-install-stats/api/install-stats';
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const [_, node, os, arch] =
|
|
15
|
+
/node\/v(\d+\.\d+\.\d+) (\w+) (\w+)/.exec(process.env.npm_config_user_agent) || [];
|
|
16
|
+
const [__, npm] = /npm\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
|
|
17
|
+
const [___, yarn] = /yarn\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
|
|
18
|
+
|
|
19
|
+
let ownPackageJson, packageJson;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const result = await Promise.all([
|
|
23
|
+
readFile(path.join(process.cwd(), 'package.json'), 'utf-8'),
|
|
24
|
+
readFile(path.join(process.cwd(), '../../../package.json'), 'utf-8'),
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
ownPackageJson = JSON.parse(result[0]);
|
|
28
|
+
packageJson = JSON.parse(result[1]);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
ownPackageJson = '';
|
|
31
|
+
packageJson = '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const data = {
|
|
35
|
+
node,
|
|
36
|
+
npm,
|
|
37
|
+
yarn,
|
|
38
|
+
os,
|
|
39
|
+
arch,
|
|
40
|
+
ownPackageJson: JSON.stringify(ownPackageJson),
|
|
41
|
+
packageJson: JSON.stringify(packageJson),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const body = JSON.stringify(data);
|
|
45
|
+
|
|
46
|
+
const options = {
|
|
47
|
+
host: remoteHost,
|
|
48
|
+
port: remotePort,
|
|
49
|
+
path: remotePath,
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
'Content-Length': body.length,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const req = http.request(options, res => {
|
|
59
|
+
res.on('end', () => {
|
|
60
|
+
resolve();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
req.on('error', () => {
|
|
65
|
+
reject();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
req.write(body);
|
|
69
|
+
req.end();
|
|
70
|
+
});
|
|
71
|
+
} catch (error) {
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main()
|
|
77
|
+
.then(() => {
|
|
78
|
+
process.exit(0);
|
|
79
|
+
})
|
|
80
|
+
.catch(() => {
|
|
81
|
+
process.exit(0);
|
|
82
|
+
});
|