just-task 1.9.0 → 1.10.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.json CHANGED
@@ -2,7 +2,37 @@
2
2
  "name": "just-task",
3
3
  "entries": [
4
4
  {
5
- "date": "Sat, 02 Mar 2024 02:16:28 GMT",
5
+ "date": "Tue, 26 Mar 2024 00:12:31 GMT",
6
+ "version": "1.10.0",
7
+ "tag": "just-task_v1.10.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "email not defined",
12
+ "package": "just-task",
13
+ "commit": "83bfae7bad6e4137a07ec633a5f5c910df1ffe67",
14
+ "comment": "Update dependency undertaker to v2"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Sat, 02 Mar 2024 08:01:34 GMT",
21
+ "version": "1.9.0",
22
+ "tag": "just-task_v1.9.0",
23
+ "comments": {
24
+ "none": [
25
+ {
26
+ "author": "elcraig@microsoft.com",
27
+ "package": "just-task",
28
+ "commit": "feb6217bf318c7d606c6147a4f5d6568572bb2f3",
29
+ "comment": "Update build setup"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Sat, 02 Mar 2024 02:16:34 GMT",
6
36
  "version": "1.9.0",
7
37
  "tag": "just-task_v1.9.0",
8
38
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - just-task
2
2
 
3
- This log was last generated on Sat, 02 Mar 2024 02:16:28 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 26 Mar 2024 00:12:31 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.10.0
8
+
9
+ Tue, 26 Mar 2024 00:12:31 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Update dependency undertaker to v2 (email not defined)
14
+
7
15
  ## 1.9.0
8
16
 
9
- Sat, 02 Mar 2024 02:16:28 GMT
17
+ Sat, 02 Mar 2024 02:16:34 GMT
10
18
 
11
19
  ### Minor changes
12
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-task",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Build task definition library",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "fs-extra": "^11.0.0",
37
37
  "just-task-logger": ">=1.2.1 <2.0.0",
38
38
  "resolve": "^1.19.0",
39
- "undertaker": "^1.3.0",
39
+ "undertaker": "^2.0.0",
40
40
  "undertaker-registry": "^2.0.0",
41
41
  "yargs-parser": "^20.2.3"
42
42
  },
@@ -1,4 +0,0 @@
1
- {
2
- "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "just-task-scripts/api-extractor.base.json"
4
- }
@@ -1,126 +0,0 @@
1
- ## API Report File for "just-task"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- /// <reference types="node" />
8
-
9
- import { Arguments } from 'yargs-parser';
10
- import { Duplex } from 'stream';
11
- import type { FSWatcher } from 'chokidar';
12
- import { Logger } from 'just-task-logger';
13
- import type { Stats } from 'fs';
14
- import { TaskFunction as TaskFunction_2 } from 'undertaker';
15
- import { TaskFunctionParams } from 'undertaker';
16
- import Undertaker = require('undertaker');
17
- import type { WatchOptions } from 'chokidar';
18
-
19
- // @public
20
- export function addResolvePath(pathName: string): void;
21
-
22
- // @public (undocumented)
23
- export function argv(): Arguments;
24
-
25
- // @public (undocumented)
26
- export function chain(subjectTaskName: string): {
27
- before: (taskName: string) => void;
28
- after: (taskName: string) => void;
29
- };
30
-
31
- // @public (undocumented)
32
- export function clearCache(): void;
33
-
34
- // @public (undocumented)
35
- export function condition(taskName: string, conditional: () => boolean): TaskFunction_2;
36
-
37
- // Warning: (ae-forgotten-export) The symbol "OptionConfig" needs to be exported by the entry point index.d.ts
38
- //
39
- // @public (undocumented)
40
- export function option(key: string, options?: OptionConfig): void;
41
-
42
- // @public (undocumented)
43
- interface OptionConfig {
44
- alias?: string | string[];
45
- array?: boolean;
46
- boolean?: boolean;
47
- coerce?: (arg: any) => any;
48
- count?: boolean;
49
- default?: any;
50
- describe?: string;
51
- narg?: number;
52
- normalize?: boolean;
53
- number?: boolean;
54
- string?: boolean;
55
- }
56
-
57
- // @public (undocumented)
58
- export function parallel(...tasks: Task[]): Undertaker.TaskFunction;
59
-
60
- // @public
61
- export function resetResolvePaths(): void;
62
-
63
- // Warning: (ae-forgotten-export) The symbol "ResolveOptions" needs to be exported by the entry point index.d.ts
64
- //
65
- // @public
66
- export function resolve(moduleName: string, options?: ResolveOptions): string | null;
67
-
68
- // @public @deprecated
69
- export function resolve(moduleName: string, cwd?: string): string | null;
70
-
71
- // @public
72
- export function resolveCwd(moduleName: string, options?: ResolveOptions): string | null;
73
-
74
- // @public @deprecated
75
- export function resolveCwd(moduleName: string, cwd?: string): string | null;
76
-
77
- // @public (undocumented)
78
- interface ResolveOptions {
79
- cwd?: string;
80
- extensions?: string[];
81
- }
82
-
83
- // @public (undocumented)
84
- export function series(...tasks: Task[]): Undertaker.TaskFunction;
85
-
86
- // @public (undocumented)
87
- export type Task = string | TaskFunction;
88
-
89
- // @public (undocumented)
90
- export function task(firstParam: string | TaskFunction, secondParam?: string | TaskFunction, thirdParam?: TaskFunction): TaskFunction;
91
-
92
- // @public (undocumented)
93
- export interface TaskContext {
94
- // (undocumented)
95
- argv: Arguments;
96
- // (undocumented)
97
- logger: Logger;
98
- }
99
-
100
- // @public (undocumented)
101
- export interface TaskFunction extends TaskFunctionParams {
102
- // (undocumented)
103
- (this: TaskContext, done: (error?: any) => void): void | Duplex | NodeJS.Process | Promise<never> | any;
104
- // (undocumented)
105
- cached?: () => void;
106
- // (undocumented)
107
- description?: string;
108
- }
109
-
110
- // @public (undocumented)
111
- export const undertaker: Undertaker;
112
-
113
- // Warning: (ae-forgotten-export) The symbol "WatchListener" needs to be exported by the entry point index.d.ts
114
- //
115
- // @public (undocumented)
116
- export function watch(globs: string | string[], optionsOrListener?: WatchListener | WatchOptions | undefined, listener?: WatchListener | undefined): FSWatcher;
117
-
118
- // @public (undocumented)
119
- type WatchListener = (path: string, stats?: Stats) => void;
120
-
121
-
122
- export * from "just-task-logger";
123
-
124
- // (No @packageDocumentation comment for this package)
125
-
126
- ```
@@ -1,5 +0,0 @@
1
- // Dummy
2
- const { task } = require('../../task');
3
- module.exports = function () {
4
- task('default', () => undefined);
5
- };
@@ -1,50 +0,0 @@
1
- import { task } from '../task';
2
- import { chain } from '../chain';
3
- import { parallel } from '../undertaker';
4
-
5
- describe('chain', () => {
6
- it('allows tasks to be injected before another one after definition', done => {
7
- const callOrder: number[] = [];
8
-
9
- const test1Function = jest.fn(() => {
10
- callOrder.push(1);
11
- });
12
- const test2Function = jest.fn(() => {
13
- callOrder.push(2);
14
- });
15
-
16
- task('test1', test1Function);
17
- task('test2', test2Function);
18
- chain('test2').before('test1');
19
-
20
- parallel('test1')(() => {
21
- expect(test2Function).toBeCalledTimes(1);
22
- expect(test1Function).toBeCalledTimes(1);
23
- expect(callOrder).toEqual([2, 1]);
24
- done();
25
- });
26
- });
27
-
28
- it('allows tasks to be injected after another one', done => {
29
- const callOrder: number[] = [];
30
-
31
- const test1Function = jest.fn(() => {
32
- callOrder.push(1);
33
- });
34
- const test2Function = jest.fn(() => {
35
- callOrder.push(2);
36
- });
37
-
38
- task('test1', test1Function);
39
- task('test2', test2Function);
40
-
41
- chain('test2').after('test1');
42
-
43
- parallel('test1')(() => {
44
- expect(test2Function).toBeCalledTimes(1);
45
- expect(test1Function).toBeCalledTimes(1);
46
- expect(callOrder).toEqual([1, 2]);
47
- done();
48
- });
49
- });
50
- });
@@ -1,260 +0,0 @@
1
- import * as path from 'path';
2
- import {
3
- _isFileNameLike,
4
- _tryResolve,
5
- resetResolvePaths,
6
- resolveCwd,
7
- addResolvePath,
8
- resolve,
9
- _getResolvePaths,
10
- } from '../resolve';
11
- import * as option from '../option';
12
- import * as config from '../config';
13
- import * as mockfs from 'mock-fs';
14
-
15
- describe('_isFileNameLike', () => {
16
- it('returns false for empty input', () => {
17
- expect(_isFileNameLike('')).toBe(false);
18
- expect(_isFileNameLike(undefined as any)).toBe(false);
19
- expect(_isFileNameLike(null as any)).toBe(false);
20
- });
21
-
22
- it('returns true for filenames', () => {
23
- expect(_isFileNameLike('.')).toBe(true);
24
- expect(_isFileNameLike('.gitignore')).toBe(true);
25
- expect(_isFileNameLike('foo.js')).toBe(true);
26
- });
27
-
28
- it('returns false for possible non-filenames', () => {
29
- expect(_isFileNameLike('foo')).toBe(false);
30
- });
31
-
32
- it('returns false for names with separators', () => {
33
- expect(_isFileNameLike('foo/bar')).toBe(false);
34
- expect(_isFileNameLike('foo\\bar')).toBe(false);
35
- expect(_isFileNameLike('foo/bar.txt')).toBe(false);
36
- expect(_isFileNameLike('foo\\bar.txt')).toBe(false);
37
- });
38
- });
39
-
40
- describe('_tryResolve', () => {
41
- afterEach(() => {
42
- mockfs.restore();
43
- });
44
-
45
- it('does not throw', () => {
46
- expect(_tryResolve('foo', { cwd: 'bar' })).toBeNull();
47
- expect(_tryResolve(undefined as any, undefined as any)).toBeNull();
48
- });
49
-
50
- it('does not recurse into child dirs', () => {
51
- mockfs({
52
- a: { 'b.txt': '' },
53
- });
54
- expect(_tryResolve('b.txt', { cwd: process.cwd() })).toBeNull();
55
- });
56
-
57
- it('resolves filename relative to basedir', () => {
58
- mockfs({
59
- a: { 'b.txt': '' }, // right
60
- 'b.txt': '', // wrong
61
- });
62
- expect(_tryResolve('b.txt', { cwd: 'a' })).toContain(path.join('a', 'b.txt'));
63
- });
64
-
65
- it('resolves non-filename relative to node_modules in basedir', () => {
66
- mockfs({
67
- a: {
68
- 'b.js': '', // wrong
69
- node_modules: { 'b.js': '' }, // right
70
- },
71
- node_modules: { 'b.js': '' }, // wrong
72
- });
73
- expect(_tryResolve('b', { cwd: 'a' })).toContain(path.join('a', 'node_modules', 'b.js'));
74
- });
75
-
76
- it('resolves path with /', () => {
77
- mockfs({
78
- a: { node_modules: { b: { 'c.js': '' } } },
79
- });
80
- expect(_tryResolve('b/c', { cwd: 'a' })).toContain(path.join('a', 'node_modules', 'b', 'c.js'));
81
- });
82
- });
83
-
84
- describe('_getResolvePaths', () => {
85
- afterEach(() => {
86
- resetResolvePaths();
87
- });
88
-
89
- it('uses resolvePaths for before __dirname', () => {
90
- jest.spyOn(option, 'argv').mockImplementation(() => ({ config: 'config/just-task.js' } as any));
91
- addResolvePath('custom1');
92
- addResolvePath('custom2');
93
-
94
- const paths = _getResolvePaths('cwd');
95
-
96
- expect(paths.map(p => path.basename(p))).toEqual(['cwd', 'config', 'custom1', 'custom2', 'src']);
97
- });
98
- });
99
-
100
- describe('resolveCwd', () => {
101
- beforeEach(() => {
102
- jest.spyOn(option, 'argv').mockImplementation(() => ({ config: undefined } as any));
103
- });
104
-
105
- afterEach(() => {
106
- mockfs.restore();
107
- resetResolvePaths();
108
- });
109
-
110
- // Not testing this one extensively since it's basically a pass-through to _tryResolve
111
-
112
- it('defaults to searching relative to process cwd', () => {
113
- mockfs({
114
- a: { 'b.txt': '' }, // right
115
- 'b.txt': '', // wrong
116
- });
117
- jest.spyOn(process, 'cwd').mockReturnValueOnce('a');
118
- expect(resolveCwd('b.txt')).toContain(path.join('a', 'b.txt'));
119
- });
120
-
121
- it('uses provided cwd', () => {
122
- mockfs({
123
- a: { 'b.txt': '' }, // right
124
- 'b.txt': '', // wrong
125
- });
126
- expect(resolveCwd('b.txt', 'a')).toContain(path.join('a', 'b.txt'));
127
- });
128
-
129
- it('ignores resolvePaths', () => {
130
- mockfs({
131
- a: { 'b.txt': '' },
132
- });
133
- addResolvePath('a');
134
- expect(resolveCwd('b.txt')).toBeNull();
135
- });
136
- });
137
-
138
- describe('resolve', () => {
139
- jest.spyOn(option, 'argv').mockImplementation(() => ({ config: undefined } as any));
140
-
141
- afterEach(() => {
142
- mockfs.restore();
143
- resetResolvePaths();
144
- });
145
-
146
- it('defaults to searching relative to process cwd', () => {
147
- mockfs({
148
- a: { 'b.txt': '' }, // right
149
- 'b.txt': '', // wrong
150
- });
151
- jest.spyOn(process, 'cwd').mockReturnValueOnce('a');
152
- expect(resolve('b.txt')).toContain(path.join('a', 'b.txt'));
153
- });
154
-
155
- it('uses provided cwd', () => {
156
- mockfs({
157
- a: { 'b.txt': '' }, // right
158
- 'b.txt': '', // wrong
159
- c: { 'b.txt': '' },
160
- });
161
- expect(resolve('b.txt', 'a')).toContain(path.join('a', 'b.txt'));
162
- });
163
-
164
- it('uses dirname of --config arg', () => {
165
- mockfs({
166
- a: { 'b.txt': '' },
167
- });
168
-
169
- jest.spyOn(option, 'argv').mockImplementation(() => ({ config: 'a/just-task.js' } as any));
170
-
171
- expect(resolve('b.txt')).toContain(path.join('a', 'b.txt'));
172
- });
173
-
174
- it('uses resolvePaths for file', () => {
175
- mockfs({
176
- a: {},
177
- c: { 'b.txt': '' },
178
- });
179
- addResolvePath('a');
180
- addResolvePath('c');
181
- expect(resolve('b.txt')).toContain(path.join('c', 'b.txt'));
182
- });
183
-
184
- it('prefers provided cwd', () => {
185
- mockfs({
186
- a: { 'b.txt': '' }, // right
187
- c: { 'b.txt': '' }, // wrong
188
- d: { 'b.txt': '' }, // wrong
189
- 'b.txt': '', // wrong
190
- });
191
-
192
- jest.spyOn(option, 'argv').mockImplementation(() => ({ config: 'a/just-task.js' } as any));
193
-
194
- addResolvePath('c');
195
- expect(resolve('b.txt', 'd')).toContain(path.join('d', 'b.txt'));
196
- });
197
- });
198
-
199
- describe('resolveConfigFile', () => {
200
- afterEach(() => {
201
- mockfs.restore();
202
- resetResolvePaths();
203
- });
204
-
205
- it('default chooses local config', () => {
206
- mockfs({
207
- config: {
208
- 'configArgument.ts': 'formConfig',
209
- 'defaultConfigArgument.ts': 'formDefaultConfig',
210
- },
211
- 'just.config.ts': 'localConfig',
212
- });
213
- const resolvedConfig = config.resolveConfigFile({ config: undefined, defaultConfig: undefined } as any);
214
- expect(resolvedConfig).toContain('just.config.ts');
215
- });
216
-
217
- it('config argument wins over local config and defaultConfig', () => {
218
- mockfs({
219
- config: {
220
- 'configArgument.ts': 'formConfig',
221
- 'defaultConfigArgument.ts': 'formDefaultConfig',
222
- },
223
- 'just.config.ts': 'localConfig',
224
- });
225
- const resolvedConfig = config.resolveConfigFile({
226
- config: './config/configArgument.ts',
227
- defaultConfig: './config/defaultConfigArgument.ts',
228
- } as any);
229
- expect(resolvedConfig).toContain('configArgument.ts');
230
- });
231
-
232
- it('local config file wins over defaultConfig', () => {
233
- mockfs({
234
- config: {
235
- 'configArgument.ts': 'formConfig',
236
- 'defaultConfigArgument.ts': 'formDefaultConfig',
237
- },
238
- 'just.config.ts': 'localConfig',
239
- });
240
- const resolvedConfig = config.resolveConfigFile({
241
- config: undefined,
242
- defaultConfig: './config/defaultConfigArgument.ts',
243
- } as any);
244
- expect(resolvedConfig).toContain('just.config.ts');
245
- });
246
-
247
- it('default config is used as last fallback', () => {
248
- mockfs({
249
- config: {
250
- 'configArgument.ts': 'formConfig',
251
- 'defaultConfigArgument.ts': 'formDefaultConfig',
252
- },
253
- });
254
- const resolvedConfig = config.resolveConfigFile({
255
- config: undefined,
256
- defaultConfig: './config/defaultConfigArgument.ts',
257
- } as any);
258
- expect(resolvedConfig).toContain('defaultConfigArgument.ts');
259
- });
260
- });
@@ -1,65 +0,0 @@
1
- import { task } from '../task';
2
- import { parallel, undertaker } from '../undertaker';
3
- import { logger } from '../logger';
4
- import * as path from 'path';
5
- import * as option from '../option';
6
- import * as UndertakerRegistry from 'undertaker-registry';
7
-
8
- describe('task', () => {
9
- beforeAll(() => {
10
- jest
11
- .spyOn(option, 'argv')
12
- .mockImplementation(() => ({ config: path.resolve(__dirname, '__mocks__/just-task.js') } as any));
13
- jest.spyOn(logger, 'info').mockImplementation(() => undefined);
14
- });
15
-
16
- beforeEach(() => {
17
- undertaker.registry(new UndertakerRegistry());
18
- });
19
-
20
- afterAll(() => {
21
- jest.spyOn(option, 'argv').mockImplementation(() => ({ config: 'a/just-task.js' } as any));
22
- jest.restoreAllMocks();
23
- });
24
-
25
- it('allows synchronous tasks to be defined and be run', done => {
26
- const testFunction = jest.fn(() => undefined);
27
-
28
- task('test', function () {
29
- testFunction();
30
- });
31
-
32
- parallel('test')(function () {
33
- expect(testFunction).toBeCalledTimes(1);
34
- done();
35
- });
36
- });
37
-
38
- it('allows callback-based tasks to be defined and be run', done => {
39
- const testFunction = jest.fn(() => undefined);
40
-
41
- task('test', function (cb) {
42
- testFunction();
43
- cb();
44
- });
45
-
46
- parallel('test')(function () {
47
- expect(testFunction).toBeCalledTimes(1);
48
- done();
49
- });
50
- });
51
-
52
- it('allows promise-based tasks to be defined and be run', done => {
53
- const testFunction = jest.fn(() => undefined);
54
-
55
- task('test', function () {
56
- const result = testFunction();
57
- return Promise.resolve(result);
58
- });
59
-
60
- parallel('test')(function () {
61
- expect(testFunction).toBeCalledTimes(1);
62
- done();
63
- });
64
- });
65
- });
@@ -1,38 +0,0 @@
1
- import { watch } from '../watch';
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
- import * as os from 'os';
5
-
6
- describe('watch', () => {
7
- it('can take a synchronous taskFunction', done => {
8
- const tmpDir = path.join(os.tmpdir(), fs.mkdtempSync('watch-sync'));
9
- const changeFile = path.join(tmpDir, 'change.txt');
10
-
11
- fs.mkdirSync(tmpDir, { recursive: true });
12
- fs.writeFileSync(changeFile, 'to be changed');
13
-
14
- const cleanup = () => {
15
- watcher.close();
16
-
17
- fs.unlinkSync(changeFile);
18
- fs.rmdirSync(tmpDir);
19
- };
20
-
21
- const callback = () => {
22
- try {
23
- expect(true).toBeTruthy();
24
- cleanup();
25
- done();
26
- } catch (error) {
27
- cleanup();
28
- done(error);
29
- }
30
- };
31
-
32
- const watcher = watch([path.join(changeFile)], callback);
33
-
34
- watcher.on('ready', () => {
35
- fs.writeFileSync(changeFile, 'new content');
36
- });
37
- });
38
- });