go-dev 0.4.2 → 0.5.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.
@@ -1,151 +1,151 @@
1
- const RESET_ALL = "0";
2
- const RESET_FOREGROUND = "39";
3
- const RESET_BACKGROUND = "49";
4
-
5
- const SET_BOLD = "1";
6
- const SET_DIM = "2";
7
- const SET_ITALIC = "3";
8
- const SET_UNDERLINE = "4";
9
- const SET_SLOW_BLINK = "5";
10
- const SET_RAPID_BLINK = "6";
11
- const SET_REVERSE = "7";
12
- const SET_HIDE = "8";
13
- const SET_STRIKETHROUGH = "9";
14
- const SET_DOUBLE_UNDERLINE = "21";
15
-
16
- const RESET_BOLD_DIM = "22";
17
- const RESET_ITALIC = "23";
18
- const RESET_UNDERLINE = "24";
19
- const RESET_BLINK = "25";
20
- const RESET_REVERSE = "27";
21
- const RESET_HIDE = "28";
22
- const RESET_STRIKETHROUGH = "29";
23
-
24
- const SET_FG_BLACK = "30";
25
- const SET_FG_RED = "31";
26
- const SET_FG_GREEN = "32";
27
- const SET_FG_YELLOW = "33";
28
- const SET_FG_BLUE = "34";
29
- const SET_FG_MAGENTA = "35";
30
- const SET_FG_CYAN = "36";
31
- const SET_FG_WHITE = "37";
32
-
33
- const SET_BG_BLACK = "40";
34
- const SET_BG_RED = "41";
35
- const SET_BG_GREEN = "42";
36
- const SET_BG_YELLOW = "43";
37
- const SET_BG_BLUE = "44";
38
- const SET_BG_MAGENTA = "45";
39
- const SET_BG_CYAN = "46";
40
- const SET_BG_WHITE = "47";
41
-
42
- const SET_FG_BRIGHT_BLACK = "90";
43
- const SET_FG_BRIGHT_RED = "91";
44
- const SET_FG_BRIGHT_GREEN = "92";
45
- const SET_FG_BRIGHT_YELLOW = "93";
46
- const SET_FG_BRIGHT_BLUE = "94";
47
- const SET_FG_BRIGHT_MAGENTA = "95";
48
- const SET_FG_BRIGHT_CYAN = "96";
49
- const SET_FG_BRIGHT_WHITE = "97";
50
-
51
- const SET_BG_BRIGHT_BLACK = "100";
52
- const SET_BG_BRIGHT_RED = "101";
53
- const SET_BG_BRIGHT_GREEN = "102";
54
- const SET_BG_BRIGHT_YELLOW = "103";
55
- const SET_BG_BRIGHT_BLUE = "104";
56
- const SET_BG_BRIGHT_MAGENTA = "105";
57
- const SET_BG_BRIGHT_CYAN = "106";
58
- const SET_BG_BRIGHT_WHITE = "107";
59
-
60
- const SET_FG_COLOR = "38";
61
- const SET_BG_COLOR = "48";
62
-
63
- const COLOR_MODE_256 = "5";
64
- const COLOR_MODE_RGB = "2";
65
-
66
- const FOREGROUND_INDEX = 0;
67
- const BACKGROUND_INDEX = 1;
68
- const BOLD_DIM_INDEX = 2;
69
- const ITALIC_INDEX = 3;
70
- const UNDERLINE_INDEX = 4;
71
- const BLINK_INDEX = 5;
72
- const REVERSE_INDEX = 6;
73
- const HIDE_INDEX = 7;
74
- const STRIKETHROUGH_INDEX = 8;
75
-
76
- module.exports = {
77
- RESET_ALL,
78
- RESET_FOREGROUND,
79
- RESET_BACKGROUND,
80
-
81
- SET_BOLD,
82
- SET_DIM,
83
- SET_ITALIC,
84
- SET_UNDERLINE,
85
- SET_SLOW_BLINK,
86
- SET_RAPID_BLINK,
87
- SET_REVERSE,
88
- SET_HIDE,
89
- SET_STRIKETHROUGH,
90
- SET_DOUBLE_UNDERLINE,
91
-
92
- RESET_BOLD_DIM,
93
- RESET_ITALIC,
94
- RESET_UNDERLINE,
95
- RESET_BLINK,
96
- RESET_REVERSE,
97
- RESET_HIDE,
98
- RESET_STRIKETHROUGH,
99
-
100
- SET_FG_BLACK,
101
- SET_FG_RED,
102
- SET_FG_GREEN,
103
- SET_FG_YELLOW,
104
- SET_FG_BLUE,
105
- SET_FG_MAGENTA,
106
- SET_FG_CYAN,
107
- SET_FG_WHITE,
108
-
109
- SET_BG_BLACK,
110
- SET_BG_RED,
111
- SET_BG_GREEN,
112
- SET_BG_YELLOW,
113
- SET_BG_BLUE,
114
- SET_BG_MAGENTA,
115
- SET_BG_CYAN,
116
- SET_BG_WHITE,
117
-
118
- SET_FG_BRIGHT_BLACK,
119
- SET_FG_BRIGHT_RED,
120
- SET_FG_BRIGHT_GREEN,
121
- SET_FG_BRIGHT_YELLOW,
122
- SET_FG_BRIGHT_BLUE,
123
- SET_FG_BRIGHT_MAGENTA,
124
- SET_FG_BRIGHT_CYAN,
125
- SET_FG_BRIGHT_WHITE,
126
-
127
- SET_BG_BRIGHT_BLACK,
128
- SET_BG_BRIGHT_RED,
129
- SET_BG_BRIGHT_GREEN,
130
- SET_BG_BRIGHT_YELLOW,
131
- SET_BG_BRIGHT_BLUE,
132
- SET_BG_BRIGHT_MAGENTA,
133
- SET_BG_BRIGHT_CYAN,
134
- SET_BG_BRIGHT_WHITE,
135
-
136
- SET_FG_COLOR,
137
- SET_BG_COLOR,
138
-
139
- COLOR_MODE_256,
140
- COLOR_MODE_RGB,
141
-
142
- FOREGROUND_INDEX,
143
- BACKGROUND_INDEX,
144
- BOLD_DIM_INDEX,
145
- ITALIC_INDEX,
146
- UNDERLINE_INDEX,
147
- BLINK_INDEX,
148
- REVERSE_INDEX,
149
- HIDE_INDEX,
150
- STRIKETHROUGH_INDEX,
1
+ const RESET_ALL = "0";
2
+ const RESET_FOREGROUND = "39";
3
+ const RESET_BACKGROUND = "49";
4
+
5
+ const SET_BOLD = "1";
6
+ const SET_DIM = "2";
7
+ const SET_ITALIC = "3";
8
+ const SET_UNDERLINE = "4";
9
+ const SET_SLOW_BLINK = "5";
10
+ const SET_RAPID_BLINK = "6";
11
+ const SET_REVERSE = "7";
12
+ const SET_HIDE = "8";
13
+ const SET_STRIKETHROUGH = "9";
14
+ const SET_DOUBLE_UNDERLINE = "21";
15
+
16
+ const RESET_BOLD_DIM = "22";
17
+ const RESET_ITALIC = "23";
18
+ const RESET_UNDERLINE = "24";
19
+ const RESET_BLINK = "25";
20
+ const RESET_REVERSE = "27";
21
+ const RESET_HIDE = "28";
22
+ const RESET_STRIKETHROUGH = "29";
23
+
24
+ const SET_FG_BLACK = "30";
25
+ const SET_FG_RED = "31";
26
+ const SET_FG_GREEN = "32";
27
+ const SET_FG_YELLOW = "33";
28
+ const SET_FG_BLUE = "34";
29
+ const SET_FG_MAGENTA = "35";
30
+ const SET_FG_CYAN = "36";
31
+ const SET_FG_WHITE = "37";
32
+
33
+ const SET_BG_BLACK = "40";
34
+ const SET_BG_RED = "41";
35
+ const SET_BG_GREEN = "42";
36
+ const SET_BG_YELLOW = "43";
37
+ const SET_BG_BLUE = "44";
38
+ const SET_BG_MAGENTA = "45";
39
+ const SET_BG_CYAN = "46";
40
+ const SET_BG_WHITE = "47";
41
+
42
+ const SET_FG_BRIGHT_BLACK = "90";
43
+ const SET_FG_BRIGHT_RED = "91";
44
+ const SET_FG_BRIGHT_GREEN = "92";
45
+ const SET_FG_BRIGHT_YELLOW = "93";
46
+ const SET_FG_BRIGHT_BLUE = "94";
47
+ const SET_FG_BRIGHT_MAGENTA = "95";
48
+ const SET_FG_BRIGHT_CYAN = "96";
49
+ const SET_FG_BRIGHT_WHITE = "97";
50
+
51
+ const SET_BG_BRIGHT_BLACK = "100";
52
+ const SET_BG_BRIGHT_RED = "101";
53
+ const SET_BG_BRIGHT_GREEN = "102";
54
+ const SET_BG_BRIGHT_YELLOW = "103";
55
+ const SET_BG_BRIGHT_BLUE = "104";
56
+ const SET_BG_BRIGHT_MAGENTA = "105";
57
+ const SET_BG_BRIGHT_CYAN = "106";
58
+ const SET_BG_BRIGHT_WHITE = "107";
59
+
60
+ const SET_FG_COLOR = "38";
61
+ const SET_BG_COLOR = "48";
62
+
63
+ const COLOR_MODE_256 = "5";
64
+ const COLOR_MODE_RGB = "2";
65
+
66
+ const FOREGROUND_INDEX = 0;
67
+ const BACKGROUND_INDEX = 1;
68
+ const BOLD_DIM_INDEX = 2;
69
+ const ITALIC_INDEX = 3;
70
+ const UNDERLINE_INDEX = 4;
71
+ const BLINK_INDEX = 5;
72
+ const REVERSE_INDEX = 6;
73
+ const HIDE_INDEX = 7;
74
+ const STRIKETHROUGH_INDEX = 8;
75
+
76
+ module.exports = {
77
+ RESET_ALL,
78
+ RESET_FOREGROUND,
79
+ RESET_BACKGROUND,
80
+
81
+ SET_BOLD,
82
+ SET_DIM,
83
+ SET_ITALIC,
84
+ SET_UNDERLINE,
85
+ SET_SLOW_BLINK,
86
+ SET_RAPID_BLINK,
87
+ SET_REVERSE,
88
+ SET_HIDE,
89
+ SET_STRIKETHROUGH,
90
+ SET_DOUBLE_UNDERLINE,
91
+
92
+ RESET_BOLD_DIM,
93
+ RESET_ITALIC,
94
+ RESET_UNDERLINE,
95
+ RESET_BLINK,
96
+ RESET_REVERSE,
97
+ RESET_HIDE,
98
+ RESET_STRIKETHROUGH,
99
+
100
+ SET_FG_BLACK,
101
+ SET_FG_RED,
102
+ SET_FG_GREEN,
103
+ SET_FG_YELLOW,
104
+ SET_FG_BLUE,
105
+ SET_FG_MAGENTA,
106
+ SET_FG_CYAN,
107
+ SET_FG_WHITE,
108
+
109
+ SET_BG_BLACK,
110
+ SET_BG_RED,
111
+ SET_BG_GREEN,
112
+ SET_BG_YELLOW,
113
+ SET_BG_BLUE,
114
+ SET_BG_MAGENTA,
115
+ SET_BG_CYAN,
116
+ SET_BG_WHITE,
117
+
118
+ SET_FG_BRIGHT_BLACK,
119
+ SET_FG_BRIGHT_RED,
120
+ SET_FG_BRIGHT_GREEN,
121
+ SET_FG_BRIGHT_YELLOW,
122
+ SET_FG_BRIGHT_BLUE,
123
+ SET_FG_BRIGHT_MAGENTA,
124
+ SET_FG_BRIGHT_CYAN,
125
+ SET_FG_BRIGHT_WHITE,
126
+
127
+ SET_BG_BRIGHT_BLACK,
128
+ SET_BG_BRIGHT_RED,
129
+ SET_BG_BRIGHT_GREEN,
130
+ SET_BG_BRIGHT_YELLOW,
131
+ SET_BG_BRIGHT_BLUE,
132
+ SET_BG_BRIGHT_MAGENTA,
133
+ SET_BG_BRIGHT_CYAN,
134
+ SET_BG_BRIGHT_WHITE,
135
+
136
+ SET_FG_COLOR,
137
+ SET_BG_COLOR,
138
+
139
+ COLOR_MODE_256,
140
+ COLOR_MODE_RGB,
141
+
142
+ FOREGROUND_INDEX,
143
+ BACKGROUND_INDEX,
144
+ BOLD_DIM_INDEX,
145
+ ITALIC_INDEX,
146
+ UNDERLINE_INDEX,
147
+ BLINK_INDEX,
148
+ REVERSE_INDEX,
149
+ HIDE_INDEX,
150
+ STRIKETHROUGH_INDEX,
151
151
  };
@@ -1,10 +1,10 @@
1
- const extractFormattingCodes = require("./extract-formatting-codes");
2
-
3
- function detectLastFormatting(text, latestFormatting) {
4
- const currentFormattingCodes = extractFormattingCodes(latestFormatting);
5
- const latestFormattingCodes = extractFormattingCodes(text, currentFormattingCodes);
6
-
7
- return latestFormattingCodes.filter(code => code != null).map(code => `\x1b[${code}m`).join("");
8
- }
9
-
10
- module.exports = detectLastFormatting;
1
+ const extractFormattingCodes = require("./extract-formatting-codes");
2
+
3
+ function detectLastFormatting(text, latestFormatting) {
4
+ const currentFormattingCodes = extractFormattingCodes(latestFormatting);
5
+ const latestFormattingCodes = extractFormattingCodes(text, currentFormattingCodes);
6
+
7
+ return latestFormattingCodes.filter(code => code != null).map(code => `\x1b[${code}m`).join("");
8
+ }
9
+
10
+ module.exports = detectLastFormatting;
@@ -1,26 +1,26 @@
1
- const applyFormattingCodes = require("./apply-formatting-codes");
2
-
3
- function extractFormattingCodes(text, currentFormattingCodes = []) {
4
- const colorRegex = /\x1b\[[0-9;]*m/g;
5
- const matches = text.match(colorRegex);
6
- if (matches == null || matches.length <= 0) {
7
- return [];
8
- }
9
-
10
- for (const match of matches) {
11
- const formattingCodes = match.slice(2, -1).split(";");
12
- if (
13
- formattingCodes.length === 1 &&
14
- formattingCodes[0] === ""
15
- ) {
16
- currentFormattingCodes.splice(0);
17
- continue;
18
- }
19
-
20
- applyFormattingCodes(currentFormattingCodes, formattingCodes);
21
- }
22
-
23
- return currentFormattingCodes;
24
- }
25
-
26
- module.exports = extractFormattingCodes;
1
+ const applyFormattingCodes = require("./apply-formatting-codes");
2
+
3
+ function extractFormattingCodes(text, currentFormattingCodes = []) {
4
+ const colorRegex = /\x1b\[[0-9;]*m/g;
5
+ const matches = text.match(colorRegex);
6
+ if (matches == null || matches.length <= 0) {
7
+ return [];
8
+ }
9
+
10
+ for (const match of matches) {
11
+ const formattingCodes = match.slice(2, -1).split(";");
12
+ if (
13
+ formattingCodes.length === 1 &&
14
+ formattingCodes[0] === ""
15
+ ) {
16
+ currentFormattingCodes.splice(0);
17
+ continue;
18
+ }
19
+
20
+ applyFormattingCodes(currentFormattingCodes, formattingCodes);
21
+ }
22
+
23
+ return currentFormattingCodes;
24
+ }
25
+
26
+ module.exports = extractFormattingCodes;
@@ -0,0 +1,84 @@
1
+ # Test configuration with dummy services to exercise go-dev features,
2
+ # especially the service-as-preCommand support.
3
+ #
4
+ # Run from the repo root with one of:
5
+ # node bin/go-dev api -c test/go-dev.yml # the user's actual scenario
6
+ # node bin/go-dev dedup -c test/go-dev.yml # main:build referenced twice -> runs once
7
+ # node bin/go-dev multi -c test/go-dev.yml # preCommand-service with parallel commands
8
+ # node bin/go-dev basic -c test/go-dev.yml # regression: literal preCommand only
9
+
10
+ services:
11
+
12
+ # `main` package: has a long-running dev watcher and one-shot build modes.
13
+ main:
14
+ type: hybrid
15
+ modes:
16
+ dev:
17
+ type: cmd
18
+ commands: [bash, -c, "i=0; while sleep 1; do i=$((i+1)); echo 'main:dev tick' $i; done"]
19
+
20
+ build:
21
+ type: cmd
22
+ # Inner literal preCommand to verify recursion works when this mode
23
+ # is itself invoked as a service-preCommand from api/worker.
24
+ preCommands:
25
+ - [bash, -c, "echo ' [main:build] inner literal pre-step'"]
26
+ commands: [bash, -c, "echo ' [main:build] STARTED'; sleep 1; echo ' [main:build] DONE'"]
27
+
28
+ build-multi:
29
+ # Two parallel one-shot commands; both must complete before the
30
+ # caller's main command starts.
31
+ type: cmd
32
+ commands:
33
+ - command: [bash, -c, "echo ' [main:build-multi:0] STARTED'; sleep 1; echo ' [main:build-multi:0] DONE'"]
34
+ - command: [bash, -c, "echo ' [main:build-multi:1] STARTED'; sleep 2; echo ' [main:build-multi:1] DONE'"]
35
+
36
+ # `api` is the user's real scenario: build main once, then run api:dev with main:dev as a peer.
37
+ api:
38
+ type: cmd
39
+ preCommands:
40
+ - { service: main, mode: build }
41
+ commands: [bash, -c, "i=0; while sleep 1; do i=$((i+1)); echo 'api:dev tick' $i; done"]
42
+ dependencies:
43
+ - { service: main, mode: dev }
44
+
45
+ # Second referrer of main:build, to test the dedup cache.
46
+ worker:
47
+ type: cmd
48
+ preCommands:
49
+ - { service: main, mode: build }
50
+ commands: [bash, -c, "i=0; while sleep 1; do i=$((i+1)); echo 'worker:dev tick' $i; done"]
51
+
52
+ # Exercises a preCommand-service that itself has multiple parallel commands.
53
+ multi:
54
+ type: cmd
55
+ preCommands:
56
+ - { service: main, mode: build-multi }
57
+ commands: [bash, -c, "echo 'multi:dev started after build-multi'; sleep 2; echo 'multi:dev done'"]
58
+
59
+
60
+ presets:
61
+
62
+ # Scenario A: api:dev with main:build precommand + main:dev dependency.
63
+ # Expected: main:build runs once to completion, then api:dev and main:dev run concurrently.
64
+ api:
65
+ services: [api]
66
+
67
+ # Scenario B: dedup. Two primary services both reference main:build.
68
+ # Expected: "[main:build] STARTED ... DONE" appears EXACTLY ONCE.
69
+ dedup:
70
+ services: [api, worker]
71
+
72
+ # Scenario C: parallel commands inside a preCommand-service.
73
+ # Expected: both build-multi:0 and build-multi:1 STARTED before either DONE,
74
+ # then multi:dev starts after both complete.
75
+ multi:
76
+ services: [multi]
77
+
78
+ # Scenario D: regression check that a literal-array preCommand still runs.
79
+ # Runs main in 'build' mode as the primary; main:build's literal preCommand fires first.
80
+ # Expected: "inner literal pre-step" -> "STARTED" -> "DONE" -> auto-exit.
81
+ basic:
82
+ services: [main]
83
+ modes:
84
+ main: build