@trayai/tray-sync-cli 1.0.13 → 1.0.15

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.
Files changed (139) hide show
  1. package/dist/api/resources/me.js +14 -0
  2. package/dist/api/resources/project.js +36 -0
  3. package/dist/commands/api/api.js +4 -0
  4. package/dist/commands/api/login.js +91 -0
  5. package/dist/commands/api/logout.js +39 -0
  6. package/dist/commands/api/project.js +116 -4
  7. package/dist/commands/api/shared.js +10 -4
  8. package/dist/commands/api/workflow.js +4 -4
  9. package/dist/commands/promote.js +2 -1
  10. package/dist/lib/apiAuth.js +25 -2
  11. package/dist/lib/apiSessionStore.js +104 -0
  12. package/dist/lib/browserOpener.js +24 -0
  13. package/dist/lib/dotenvEdit.js +31 -0
  14. package/dist/lib/oauth.js +125 -0
  15. package/dist/lib/oauthCallbackServer.js +97 -0
  16. package/dist/lib/oauthRefresh.js +65 -0
  17. package/dist/lib/promoteTarget.js +0 -24
  18. package/dist/lib/region.js +1 -0
  19. package/dist/views/api/project.v2.js +6 -0
  20. package/node_modules/bundle-name/index.js +5 -0
  21. package/node_modules/bundle-name/license +9 -0
  22. package/node_modules/bundle-name/package.json +45 -0
  23. package/node_modules/bundle-name/readme.md +23 -0
  24. package/node_modules/default-browser/index.d.ts +29 -0
  25. package/node_modules/default-browser/index.js +34 -0
  26. package/node_modules/default-browser/license +9 -0
  27. package/node_modules/default-browser/package.json +54 -0
  28. package/node_modules/default-browser/readme.md +24 -0
  29. package/node_modules/default-browser/windows.js +59 -0
  30. package/node_modules/default-browser-id/index.js +25 -0
  31. package/node_modules/default-browser-id/license +9 -0
  32. package/node_modules/default-browser-id/package.json +41 -0
  33. package/node_modules/default-browser-id/readme.md +19 -0
  34. package/node_modules/define-lazy-prop/index.d.ts +31 -0
  35. package/node_modules/define-lazy-prop/index.js +18 -0
  36. package/node_modules/define-lazy-prop/license +9 -0
  37. package/node_modules/define-lazy-prop/package.json +51 -0
  38. package/node_modules/define-lazy-prop/readme.md +55 -0
  39. package/node_modules/dotenv/CHANGELOG.md +643 -0
  40. package/node_modules/dotenv/LICENSE +23 -0
  41. package/node_modules/dotenv/README-es.md +757 -0
  42. package/node_modules/dotenv/README.md +812 -0
  43. package/node_modules/dotenv/SECURITY.md +1 -0
  44. package/node_modules/dotenv/config.d.ts +1 -0
  45. package/node_modules/dotenv/config.js +9 -0
  46. package/node_modules/dotenv/lib/cli-options.js +17 -0
  47. package/node_modules/dotenv/lib/env-options.js +28 -0
  48. package/node_modules/dotenv/lib/main.d.ts +179 -0
  49. package/node_modules/dotenv/lib/main.js +423 -0
  50. package/node_modules/dotenv/package.json +62 -0
  51. package/node_modules/dotenv/skills/dotenv/SKILL.md +200 -0
  52. package/node_modules/dotenv/skills/dotenvx/SKILL.md +118 -0
  53. package/node_modules/graceful-fs/LICENSE +15 -0
  54. package/node_modules/graceful-fs/README.md +143 -0
  55. package/node_modules/graceful-fs/clone.js +23 -0
  56. package/node_modules/graceful-fs/graceful-fs.js +448 -0
  57. package/node_modules/graceful-fs/legacy-streams.js +118 -0
  58. package/node_modules/graceful-fs/package.json +53 -0
  59. package/node_modules/graceful-fs/polyfills.js +355 -0
  60. package/node_modules/is-docker/cli.js +5 -0
  61. package/node_modules/is-docker/index.d.ts +13 -0
  62. package/node_modules/is-docker/index.js +29 -0
  63. package/node_modules/is-docker/license +9 -0
  64. package/node_modules/is-docker/package.json +44 -0
  65. package/node_modules/is-docker/readme.md +27 -0
  66. package/node_modules/is-in-ssh/index.d.ts +15 -0
  67. package/node_modules/is-in-ssh/index.js +7 -0
  68. package/node_modules/is-in-ssh/license +9 -0
  69. package/node_modules/is-in-ssh/package.json +43 -0
  70. package/node_modules/is-in-ssh/readme.md +43 -0
  71. package/node_modules/is-inside-container/cli.js +5 -0
  72. package/node_modules/is-inside-container/index.d.ts +13 -0
  73. package/node_modules/is-inside-container/index.js +23 -0
  74. package/node_modules/is-inside-container/license +9 -0
  75. package/node_modules/is-inside-container/package.json +51 -0
  76. package/node_modules/is-inside-container/readme.md +36 -0
  77. package/node_modules/is-wsl/index.d.ts +15 -0
  78. package/node_modules/is-wsl/index.js +36 -0
  79. package/node_modules/is-wsl/license +9 -0
  80. package/node_modules/is-wsl/package.json +58 -0
  81. package/node_modules/is-wsl/readme.md +21 -0
  82. package/node_modules/open/index.d.ts +158 -0
  83. package/node_modules/open/index.js +425 -0
  84. package/node_modules/open/license +9 -0
  85. package/node_modules/open/package.json +70 -0
  86. package/node_modules/open/readme.md +197 -0
  87. package/node_modules/open/xdg-open +1267 -0
  88. package/node_modules/powershell-utils/index.d.ts +175 -0
  89. package/node_modules/powershell-utils/index.js +79 -0
  90. package/node_modules/powershell-utils/license +9 -0
  91. package/node_modules/powershell-utils/package.json +47 -0
  92. package/node_modules/powershell-utils/readme.md +209 -0
  93. package/node_modules/proper-lockfile/CHANGELOG.md +108 -0
  94. package/node_modules/proper-lockfile/LICENSE +21 -0
  95. package/node_modules/proper-lockfile/README.md +183 -0
  96. package/node_modules/proper-lockfile/index.js +40 -0
  97. package/node_modules/proper-lockfile/lib/adapter.js +85 -0
  98. package/node_modules/proper-lockfile/lib/lockfile.js +342 -0
  99. package/node_modules/proper-lockfile/lib/mtime-precision.js +55 -0
  100. package/node_modules/proper-lockfile/package.json +71 -0
  101. package/node_modules/retry/.npmignore +3 -0
  102. package/node_modules/retry/.travis.yml +15 -0
  103. package/node_modules/retry/License +21 -0
  104. package/node_modules/retry/Makefile +18 -0
  105. package/node_modules/retry/README.md +227 -0
  106. package/node_modules/retry/equation.gif +0 -0
  107. package/node_modules/retry/example/dns.js +31 -0
  108. package/node_modules/retry/example/stop.js +40 -0
  109. package/node_modules/retry/index.js +1 -0
  110. package/node_modules/retry/lib/retry.js +100 -0
  111. package/node_modules/retry/lib/retry_operation.js +158 -0
  112. package/node_modules/retry/package.json +32 -0
  113. package/node_modules/retry/test/common.js +10 -0
  114. package/node_modules/retry/test/integration/test-forever.js +24 -0
  115. package/node_modules/retry/test/integration/test-retry-operation.js +258 -0
  116. package/node_modules/retry/test/integration/test-retry-wrap.js +101 -0
  117. package/node_modules/retry/test/integration/test-timeouts.js +69 -0
  118. package/node_modules/run-applescript/index.d.ts +66 -0
  119. package/node_modules/run-applescript/index.js +37 -0
  120. package/node_modules/run-applescript/license +9 -0
  121. package/node_modules/run-applescript/package.json +42 -0
  122. package/node_modules/run-applescript/readme.md +78 -0
  123. package/node_modules/signal-exit/LICENSE.txt +16 -0
  124. package/node_modules/signal-exit/README.md +39 -0
  125. package/node_modules/signal-exit/index.js +202 -0
  126. package/node_modules/signal-exit/package.json +38 -0
  127. package/node_modules/signal-exit/signals.js +53 -0
  128. package/node_modules/wsl-utils/index.d.ts +180 -0
  129. package/node_modules/wsl-utils/index.js +145 -0
  130. package/node_modules/wsl-utils/license +9 -0
  131. package/node_modules/wsl-utils/node_modules/powershell-utils/index.d.ts +122 -0
  132. package/node_modules/wsl-utils/node_modules/powershell-utils/index.js +58 -0
  133. package/node_modules/wsl-utils/node_modules/powershell-utils/license +9 -0
  134. package/node_modules/wsl-utils/node_modules/powershell-utils/package.json +47 -0
  135. package/node_modules/wsl-utils/node_modules/powershell-utils/readme.md +153 -0
  136. package/node_modules/wsl-utils/package.json +48 -0
  137. package/node_modules/wsl-utils/readme.md +223 -0
  138. package/node_modules/wsl-utils/utilities.js +19 -0
  139. package/package.json +8 -1
@@ -0,0 +1,175 @@
1
+ import type {ExecFileOptions, ExecFileSyncOptions} from 'node:child_process';
2
+
3
+ export type ExecutePowerShellOptions = Omit<ExecFileOptions, 'shell'> & {
4
+ /**
5
+ Path to PowerShell executable.
6
+
7
+ @default powerShellPath()
8
+ */
9
+ readonly powerShellPath?: string;
10
+
11
+ /**
12
+ Not supported. PowerShell is always executed directly to prevent shell injection.
13
+ */
14
+ readonly shell?: never;
15
+ };
16
+
17
+ export type ExecutePowerShellSyncOptions = Omit<ExecFileSyncOptions, 'shell'> & {
18
+ /**
19
+ Path to PowerShell executable.
20
+
21
+ @default powerShellPath()
22
+ */
23
+ readonly powerShellPath?: string;
24
+
25
+ /**
26
+ Not supported. PowerShell is always executed directly to prevent shell injection.
27
+ */
28
+ readonly shell?: never;
29
+ };
30
+
31
+ export type ExecutePowerShellResult = {
32
+ readonly stdout: string;
33
+ readonly stderr: string;
34
+ };
35
+
36
+ /**
37
+ Get the PowerShell executable path on Windows.
38
+
39
+ @returns The path to the PowerShell executable.
40
+
41
+ @example
42
+ ```
43
+ import {powerShellPath} from 'powershell-utils';
44
+
45
+ const psPath = powerShellPath();
46
+ //=> 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
47
+ ```
48
+ */
49
+ export function powerShellPath(): string;
50
+
51
+ /**
52
+ Check if PowerShell is accessible on Windows.
53
+
54
+ This checks if the PowerShell executable exists and has execute permissions. Useful for detecting restricted environments where PowerShell may be disabled by administrators.
55
+
56
+ @returns A promise that resolves to true if PowerShell is accessible, false otherwise.
57
+
58
+ @example
59
+ ```
60
+ import {canAccessPowerShell} from 'powershell-utils';
61
+
62
+ if (await canAccessPowerShell()) {
63
+ console.log('PowerShell is available');
64
+ } else {
65
+ console.log('PowerShell is not accessible');
66
+ }
67
+ ```
68
+ */
69
+ export function canAccessPowerShell(): Promise<boolean>;
70
+
71
+ /**
72
+ Execute a PowerShell command.
73
+
74
+ @param command - The PowerShell command to execute.
75
+ @returns A promise that resolves to the command output.
76
+
77
+ @example
78
+ ```
79
+ import {executePowerShell} from 'powershell-utils';
80
+
81
+ const {stdout} = await executePowerShell('Get-Process');
82
+ console.log(stdout);
83
+ ```
84
+ */
85
+ export function executePowerShell(
86
+ command: string,
87
+ options?: ExecutePowerShellOptions
88
+ ): Promise<ExecutePowerShellResult>;
89
+
90
+ export namespace executePowerShell {
91
+ /**
92
+ Standard PowerShell arguments that prefix the encoded command: `['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand']`
93
+
94
+ Exposed for debugging or for advanced use cases where you need to customize the arguments. For most cases, use `createArguments()` instead.
95
+ */
96
+ export const argumentsPrefix: readonly string[];
97
+
98
+ /**
99
+ Encode a PowerShell command as Base64 UTF-16LE.
100
+
101
+ This encoding prevents shell escaping issues and ensures complex commands with special characters are executed reliably.
102
+
103
+ @param command - The PowerShell command to encode.
104
+ @returns Base64-encoded command.
105
+
106
+ @example
107
+ ```
108
+ import {executePowerShell} from 'powershell-utils';
109
+
110
+ const encoded = executePowerShell.encodeCommand('Get-Process');
111
+ ```
112
+ */
113
+ export function encodeCommand(command: string): string;
114
+
115
+ /**
116
+ Escape a string argument for use in PowerShell single-quoted strings.
117
+
118
+ This makes a value safe as a PowerShell string literal, not as an argument to a native program. PowerShell removes the outer quotes before passing a value onwards, and the receiving process then re-splits it under its own command-line rules, where spaces and double quotes are delimiters. For example, `Start-Process -ArgumentList` receives `'a b'` as two arguments rather than one.
119
+
120
+ Escaping also does not make an untrusted value safe to use as the program that `Start-Process` runs. Validate such values against an allowlist.
121
+
122
+ @param value - The value to escape.
123
+ @returns Escaped and quoted string ready for PowerShell.
124
+
125
+ @example
126
+ ```
127
+ import {executePowerShell} from 'powershell-utils';
128
+
129
+ const escaped = executePowerShell.escapeArgument("it's a test");
130
+ //=> "'it''s a test'"
131
+
132
+ // Use in command building
133
+ const command = `Start-Process ${executePowerShell.escapeArgument(appName)}`;
134
+ ```
135
+ */
136
+ export function escapeArgument(value: unknown): string;
137
+
138
+ /**
139
+ Create the full arguments array for PowerShell execution.
140
+
141
+ Combines `argumentsPrefix` with the encoded command. Useful when using `spawn()`, `execFile()`, or other process execution methods.
142
+
143
+ @param command - The PowerShell command.
144
+ @returns Array of arguments ready to pass to a process spawner.
145
+
146
+ @example
147
+ ```
148
+ import {spawn} from 'node:child_process';
149
+ import {powerShellPath, executePowerShell} from 'powershell-utils';
150
+
151
+ const args = executePowerShell.createArguments('Get-Process');
152
+ spawn(powerShellPath(), args);
153
+ ```
154
+ */
155
+ export function createArguments(command: string): string[];
156
+ }
157
+
158
+ /**
159
+ Execute a PowerShell command synchronously.
160
+
161
+ @param command - The PowerShell command to execute.
162
+ @returns The stdout output as a string.
163
+
164
+ @example
165
+ ```
166
+ import {executePowerShellSync} from 'powershell-utils';
167
+
168
+ const stdout = executePowerShellSync('Get-Process');
169
+ console.log(stdout);
170
+ ```
171
+ */
172
+ export function executePowerShellSync(
173
+ command: string,
174
+ options?: ExecutePowerShellSyncOptions
175
+ ): string;
@@ -0,0 +1,79 @@
1
+ import process from 'node:process';
2
+ import {Buffer} from 'node:buffer';
3
+ import {promisify} from 'node:util';
4
+ import childProcess from 'node:child_process';
5
+ import fs, {constants as fsConstants} from 'node:fs/promises';
6
+
7
+ const execFile = promisify(childProcess.execFile);
8
+
9
+ export const powerShellPath = () => `${process.env.SYSTEMROOT || process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
10
+
11
+ // Cache for PowerShell accessibility check
12
+ let canAccessCache;
13
+
14
+ export const canAccessPowerShell = async () => {
15
+ canAccessCache ??= (async () => {
16
+ try {
17
+ await fs.access(powerShellPath(), fsConstants.X_OK);
18
+ return true;
19
+ } catch {
20
+ return false;
21
+ }
22
+ })();
23
+
24
+ return canAccessCache;
25
+ };
26
+
27
+ const argumentsPrefix = [
28
+ '-NoProfile',
29
+ '-NonInteractive',
30
+ '-ExecutionPolicy',
31
+ 'Bypass',
32
+ '-EncodedCommand',
33
+ ];
34
+
35
+ const encodeCommand = command => Buffer.from(command, 'utf16le').toString('base64');
36
+
37
+ /*
38
+ PowerShell's tokenizer treats the typographic single quotes U+2018, U+2019, U+201A, and U+201B as string delimiters, exactly like the ASCII one, and it does not require the closing quote to match the opening quote. Escaping only the ASCII quote would let any of the others terminate the string and inject a statement. Doubling works for all of them.
39
+ */
40
+ const escapeArgument = value => `'${String(value).replaceAll(/['‘’‚‛]/g, match => match + match)}'`;
41
+
42
+ const createArguments = command => [...argumentsPrefix, encodeCommand(command)];
43
+
44
+ const createExecFileOptions = options => ({
45
+ encoding: 'utf8',
46
+ ...options,
47
+ shell: false,
48
+ });
49
+
50
+ export const executePowerShell = async (command, options = {}) => {
51
+ const {
52
+ powerShellPath: psPath,
53
+ ...execFileOptions
54
+ } = options;
55
+
56
+ return execFile(
57
+ psPath ?? powerShellPath(),
58
+ createArguments(command),
59
+ createExecFileOptions(execFileOptions),
60
+ );
61
+ };
62
+
63
+ executePowerShell.argumentsPrefix = argumentsPrefix;
64
+ executePowerShell.encodeCommand = encodeCommand;
65
+ executePowerShell.escapeArgument = escapeArgument;
66
+ executePowerShell.createArguments = createArguments;
67
+
68
+ export const executePowerShellSync = (command, options = {}) => {
69
+ const {
70
+ powerShellPath: psPath,
71
+ ...execFileOptions
72
+ } = options;
73
+
74
+ return childProcess.execFileSync(
75
+ psPath ?? powerShellPath(),
76
+ createArguments(command),
77
+ createExecFileOptions(execFileOptions),
78
+ );
79
+ };
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "powershell-utils",
3
+ "version": "0.2.1",
4
+ "description": "Utilities for executing PowerShell commands",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/powershell-utils",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "author": {
9
+ "name": "Sindre Sorhus",
10
+ "email": "sindresorhus@gmail.com",
11
+ "url": "https://sindresorhus.com"
12
+ },
13
+ "type": "module",
14
+ "exports": {
15
+ "types": "./index.d.ts",
16
+ "default": "./index.js"
17
+ },
18
+ "sideEffects": false,
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "scripts": {
23
+ "test": "xo && ava && tsc index.d.ts --skipLibCheck"
24
+ },
25
+ "files": [
26
+ "index.js",
27
+ "index.d.ts"
28
+ ],
29
+ "keywords": [
30
+ "powershell",
31
+ "windows",
32
+ "execute",
33
+ "command",
34
+ "shell",
35
+ "console",
36
+ "terminal",
37
+ "cli",
38
+ "spawn",
39
+ "exec",
40
+ "utilities"
41
+ ],
42
+ "devDependencies": {
43
+ "ava": "^6.4.1",
44
+ "typescript": "^5.9.3",
45
+ "xo": "^0.59.0"
46
+ }
47
+ }
@@ -0,0 +1,209 @@
1
+ # powershell-utils
2
+
3
+ > Utilities for executing PowerShell commands
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install powershell-utils
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import {executePowerShell, powerShellPath} from 'powershell-utils';
15
+
16
+ const {stdout} = await executePowerShell('Get-Process');
17
+ console.log(stdout);
18
+
19
+ console.log(powerShellPath());
20
+ //=> 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
21
+ ```
22
+
23
+ ## API
24
+
25
+ ### powerShellPath()
26
+
27
+ Returns: `string`
28
+
29
+ Get the PowerShell executable path on Windows.
30
+
31
+ ```js
32
+ import {powerShellPath} from 'powershell-utils';
33
+
34
+ const psPath = powerShellPath();
35
+ //=> 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
36
+ ```
37
+
38
+ ### canAccessPowerShell()
39
+
40
+ Returns: `Promise<boolean>`
41
+
42
+ Check if PowerShell is accessible on Windows.
43
+
44
+ This checks if the PowerShell executable exists and has execute permissions. Useful for detecting restricted environments where PowerShell may be disabled by administrators.
45
+
46
+ ```js
47
+ import {canAccessPowerShell} from 'powershell-utils';
48
+
49
+ if (await canAccessPowerShell()) {
50
+ console.log('PowerShell is available');
51
+ } else {
52
+ console.log('PowerShell is not accessible');
53
+ }
54
+ ```
55
+
56
+ ### executePowerShell(command, options?)
57
+
58
+ Returns: `Promise<{stdout: string, stderr: string}>`
59
+
60
+ Execute a PowerShell command.
61
+
62
+ ```js
63
+ import {executePowerShell} from 'powershell-utils';
64
+
65
+ const {stdout} = await executePowerShell('Get-Process');
66
+ console.log(stdout);
67
+ ```
68
+
69
+ #### command
70
+
71
+ Type: `string`
72
+
73
+ The PowerShell command to execute.
74
+
75
+ #### options
76
+
77
+ Type: `object`
78
+
79
+ The below option and all options except `shell` in Node.js [`child_process.execFile()`](https://nodejs.org/api/child_process.html#child_processexecfilefile-args-options-callback) are supported. PowerShell is always executed directly to prevent shell injection.
80
+
81
+ ##### powerShellPath
82
+
83
+ Type: `string`\
84
+ Default: `powerShellPath()`
85
+
86
+ Path to PowerShell executable. Useful when calling from WSL or when PowerShell is in a non-standard location.
87
+
88
+ ##### encoding
89
+
90
+ Type: `string`\
91
+ Default: `'utf8'`
92
+
93
+ Character encoding for stdout and stderr.
94
+
95
+ ### executePowerShell.argumentsPrefix
96
+
97
+ Type: `string[]`
98
+
99
+ Standard PowerShell arguments that prefix the encoded command: `['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand']`
100
+
101
+ Exposed for debugging or for advanced use cases where you need to customize the arguments. For most cases, use `createArguments()` instead.
102
+
103
+ ### executePowerShell.encodeCommand(command)
104
+
105
+ Returns: `string`
106
+
107
+ Encode a PowerShell command as Base64 UTF-16LE.
108
+
109
+ This encoding prevents shell escaping issues and ensures complex commands with special characters are executed reliably.
110
+
111
+ #### command
112
+
113
+ Type: `string`
114
+
115
+ The PowerShell command to encode.
116
+
117
+ ```js
118
+ import {executePowerShell} from 'powershell-utils';
119
+
120
+ const encoded = executePowerShell.encodeCommand('Get-Process');
121
+ ```
122
+
123
+ ### executePowerShell.escapeArgument(value)
124
+
125
+ Returns: `string`
126
+
127
+ Escape a string argument for use in PowerShell single-quoted strings.
128
+
129
+ > [!IMPORTANT]
130
+ > This makes a value safe as a PowerShell string literal, not as an argument to a native program. PowerShell removes the outer quotes before passing a value onwards, and the receiving process then re-splits it under its own command-line rules, where spaces and double quotes are delimiters. For example, `Start-Process -ArgumentList` receives `'a b'` as two arguments rather than one.
131
+ >
132
+ > Escaping also does not make an untrusted value safe to use as the program that `Start-Process` runs. Validate such values against an allowlist.
133
+
134
+ #### value
135
+
136
+ Type: `unknown`
137
+
138
+ The value to escape.
139
+
140
+ ```js
141
+ import {executePowerShell} from 'powershell-utils';
142
+
143
+ const escaped = executePowerShell.escapeArgument("it's a test");
144
+ //=> "'it''s a test'"
145
+
146
+ // Use in command building
147
+ const command = `Start-Process ${executePowerShell.escapeArgument(appName)}`;
148
+ ```
149
+
150
+ ### executePowerShell.createArguments(command)
151
+
152
+ Returns: `string[]`
153
+
154
+ Create the full arguments array for PowerShell execution.
155
+
156
+ Combines `argumentsPrefix` with the encoded command. Useful when using `spawn()`, `execFile()`, or other process execution methods.
157
+
158
+ #### command
159
+
160
+ Type: `string`
161
+
162
+ The PowerShell command.
163
+
164
+ ```js
165
+ import {spawn} from 'node:child_process';
166
+ import {powerShellPath, executePowerShell} from 'powershell-utils';
167
+
168
+ const args = executePowerShell.createArguments('Get-Process');
169
+ spawn(powerShellPath(), args);
170
+ ```
171
+
172
+ ### executePowerShellSync(command, options?)
173
+
174
+ Returns: `string`
175
+
176
+ Execute a PowerShell command synchronously.
177
+
178
+ ```js
179
+ import {executePowerShellSync} from 'powershell-utils';
180
+
181
+ const stdout = executePowerShellSync('Get-Process');
182
+ console.log(stdout);
183
+ ```
184
+
185
+ #### command
186
+
187
+ Type: `string`
188
+
189
+ The PowerShell command to execute.
190
+
191
+ #### options
192
+
193
+ Type: `object`
194
+
195
+ The below option and all options except `shell` in Node.js [`child_process.execFileSync()`](https://nodejs.org/api/child_process.html#child_processexecfilesyncfile-args-options) are supported. PowerShell is always executed directly to prevent shell injection.
196
+
197
+ ##### powerShellPath
198
+
199
+ Type: `string`\
200
+ Default: `powerShellPath()`
201
+
202
+ Path to PowerShell executable.
203
+
204
+ ##### encoding
205
+
206
+ Type: `string`\
207
+ Default: `'utf8'`
208
+
209
+ Character encoding for the output.
@@ -0,0 +1,108 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ <a name="4.1.2"></a>
6
+ ## [4.1.2](https://github.com/moxystudio/node-proper-lockfile/compare/v4.1.1...v4.1.2) (2021-01-25)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix node 14 updating graceful-fs ([#102](https://github.com/moxystudio/node-proper-lockfile/issues/102)) ([b0d988e](https://github.com/moxystudio/node-proper-lockfile/commit/b0d988e))
12
+
13
+
14
+
15
+ <a name="4.1.1"></a>
16
+ ## [4.1.1](https://github.com/moxystudio/node-proper-lockfile/compare/v4.1.0...v4.1.1) (2019-04-03)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * fix mtime precision on some filesystems ([#88](https://github.com/moxystudio/node-proper-lockfile/issues/88)) ([f266158](https://github.com/moxystudio/node-proper-lockfile/commit/f266158)), closes [#82](https://github.com/moxystudio/node-proper-lockfile/issues/82) [#87](https://github.com/moxystudio/node-proper-lockfile/issues/87)
22
+
23
+
24
+
25
+ <a name="4.1.0"></a>
26
+ # [4.1.0](https://github.com/moxystudio/node-proper-lockfile/compare/v4.0.0...v4.1.0) (2019-03-18)
27
+
28
+
29
+ ### Features
30
+
31
+ * allow second precision in mtime comparison ([#78](https://github.com/moxystudio/node-proper-lockfile/issues/78)) ([b2816a6](https://github.com/moxystudio/node-proper-lockfile/commit/b2816a6))
32
+
33
+
34
+
35
+ <a name="4.0.0"></a>
36
+ # [4.0.0](https://github.com/moxystudio/node-proper-lockfile/compare/v3.2.0...v4.0.0) (2019-03-12)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * fix typo in error message ([#68](https://github.com/moxystudio/node-proper-lockfile/issues/68)) ([b91cb55](https://github.com/moxystudio/node-proper-lockfile/commit/b91cb55))
42
+
43
+
44
+ ### Features
45
+
46
+ * make staleness check more robust ([#74](https://github.com/moxystudio/node-proper-lockfile/issues/74)) ([9cc0973](https://github.com/moxystudio/node-proper-lockfile/commit/9cc0973)), closes [#71](https://github.com/moxystudio/node-proper-lockfile/issues/71) [/github.com/ipfs/js-ipfs-repo/issues/188#issuecomment-468682971](https://github.com//github.com/ipfs/js-ipfs-repo/issues/188/issues/issuecomment-468682971)
47
+
48
+
49
+ ### BREAKING CHANGES
50
+
51
+ * We were marking the lock as compromised when system went into sleep or if the event loop was busy taking too long to run the internals timers, Now we keep track of the mtime updated by the current process, and if we lose some cycles in the update process but recover and the mtime is still ours we do not mark the lock as compromised.
52
+
53
+
54
+
55
+ <a name="3.2.0"></a>
56
+ # [3.2.0](https://github.com/moxystudio/node-proper-lockfile/compare/v3.1.0...v3.2.0) (2018-11-19)
57
+
58
+
59
+ ### Features
60
+
61
+ * add lock path option ([#66](https://github.com/moxystudio/node-proper-lockfile/issues/66)) ([32f1b8d](https://github.com/moxystudio/node-proper-lockfile/commit/32f1b8d))
62
+
63
+
64
+
65
+ <a name="3.1.0"></a>
66
+ # [3.1.0](https://github.com/moxystudio/node-proper-lockfile/compare/v3.0.2...v3.1.0) (2018-11-15)
67
+
68
+
69
+ ### Bug Fixes
70
+
71
+ * **package:** update retry to version 0.12.0 ([#50](https://github.com/moxystudio/node-proper-lockfile/issues/50)) ([d400b98](https://github.com/moxystudio/node-proper-lockfile/commit/d400b98))
72
+
73
+
74
+ ### Features
75
+
76
+ * add signal exit ([#65](https://github.com/moxystudio/node-proper-lockfile/issues/65)) ([f20bc45](https://github.com/moxystudio/node-proper-lockfile/commit/f20bc45))
77
+
78
+
79
+
80
+ <a name="3.0.2"></a>
81
+ ## [3.0.2](https://github.com/moxystudio/node-proper-lockfile/compare/v3.0.1...v3.0.2) (2018-01-30)
82
+
83
+
84
+
85
+ <a name="3.0.1"></a>
86
+ ## [3.0.1](https://github.com/moxystudio/node-proper-lockfile/compare/v3.0.0...v3.0.1) (2018-01-20)
87
+
88
+
89
+ ### Bug Fixes
90
+
91
+ * restore ability to use lockfile() directly ([0ef8fbc](https://github.com/moxystudio/node-proper-lockfile/commit/0ef8fbc))
92
+
93
+
94
+
95
+ <a name="3.0.0"></a>
96
+ # [3.0.0](https://github.com/moxystudio/node-proper-lockfile/compare/v2.0.1...v3.0.0) (2018-01-20)
97
+
98
+
99
+ ### Chores
100
+
101
+ * update project to latest node lts ([b1d43e5](https://github.com/moxystudio/node-proper-lockfile/commit/b1d43e5))
102
+
103
+
104
+ ### BREAKING CHANGES
105
+
106
+ * remove callback support
107
+ * use of node lts language features such as object spread
108
+ * compromised function in lock() has been moved to an option
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.