-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c75d1d
commit 1558acf
Showing
8 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# npm installed packages | ||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"*.js": [ | ||
"prettier --write" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
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 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. | ||
|
||
For more information, please refer to <https://unlicense.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env node | ||
|
||
import { argv } from 'node:process'; | ||
import { promisifiedExec } from '../src/promisifiedExec.js'; | ||
|
||
const TURBOREPO_ROOT_PACKAGE_NAME = '//'; | ||
const TURBOREPO_TASK_NOT_FOUND_MAGIC_STRING = '\u003cNONEXISTENT\u003e'; | ||
|
||
const taskToDryRun = argv[2]; | ||
const baseRef = argv[3]; | ||
|
||
let execCommand = `pnpm exec turbo run ${taskToDryRun} --dry=json`; | ||
|
||
if (baseRef !== undefined) { | ||
execCommand += ` --filter ...[${baseRef}]`; | ||
} | ||
|
||
const stringifiedDryRun = (await promisifiedExec(execCommand)).trim(); | ||
|
||
const dryRunResult = JSON.parse(stringifiedDryRun); | ||
|
||
/** @type {Array.<string>} */ | ||
const dryResultPackageNames = dryRunResult.packages.filter( | ||
(packageName) => packageName !== TURBOREPO_ROOT_PACKAGE_NAME, | ||
); | ||
|
||
const tasks = dryRunResult.tasks.filter((task) => | ||
dryResultPackageNames.some( | ||
(packageName) => | ||
task.taskId === `${packageName}#${taskToDryRun}` && | ||
!task.command.includes(TURBOREPO_TASK_NOT_FOUND_MAGIC_STRING), | ||
), | ||
); | ||
|
||
/** @type {Array.<string>} */ | ||
const packageNames = tasks.map((task) => task.package); | ||
|
||
console.log(JSON.stringify(packageNames)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@cuaklabs/scripts", | ||
"private": true, | ||
"description": "common scripts", | ||
"author": "Roberto Pintos López (https://github.com/notaphplover)", | ||
"license": "See license in \"LICENSE\" file", | ||
"type": "module", | ||
"homepage": "https://github.com/cuaklabs/ajstt#readme", | ||
"bugs": { | ||
"url": "https://github.com/cuaklabs/ajstt/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/cuaklabs/ajstt.git" | ||
}, | ||
"bin": { | ||
"script-get-affected-projects": "./bin/getAffectedProjects.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import config from '@cuaklabs/prettier-config'; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { exec } from 'node:child_process'; | ||
|
||
/** | ||
* @param {string} command command | ||
* @param {PromisifiedExecOptions} options true to pipe standard input output and error streams | ||
* @returns {Promise<string>} | ||
*/ | ||
export async function promisifiedExec(command, options) { | ||
options = { | ||
cwd: options?.cwd, | ||
interactive: options?.interactive ?? false, | ||
}; | ||
|
||
return new Promise((resolve, reject) => { | ||
const childProcess = exec( | ||
command, | ||
{ | ||
cwd: options.cwd, | ||
}, | ||
(error, stdout) => { | ||
if (error === null) { | ||
resolve(stdout); | ||
} else { | ||
reject(error); | ||
} | ||
}, | ||
); | ||
|
||
if (options.interactive) { | ||
childProcess.stdout.pipe(process.stdout); | ||
childProcess.stderr.pipe(process.stderr); | ||
|
||
process.stdin.pipe(childProcess.stdin); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* @typedef {Object} PromisifiedExecOptions | ||
* @property {boolean} interactive | ||
* @property {string} cwd | ||
*/ |