@alexaegis/turbowatch 0.15.1 → 0.15.2

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/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_watch_local_node_modules = require("./watch-local-node-modules-0DugEhkt.cjs");
2
+ const require_watch_local_node_modules = require("./watch-local-node-modules-D4Eoulp5.cjs");
3
3
  exports.normalizeTurbowatchLocalNodeModulesOptions = require_watch_local_node_modules.normalizeTurbowatchLocalNodeModulesOptions;
4
4
  exports.turbowatchLocalNodeModules = require_watch_local_node_modules.turbowatchLocalNodeModules;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as normalizeTurbowatchLocalNodeModulesOptions, t as turbowatchLocalNodeModules } from "./watch-local-node-modules-gDrf144G.js";
1
+ import { n as normalizeTurbowatchLocalNodeModulesOptions, t as turbowatchLocalNodeModules } from "./watch-local-node-modules-DCaYNkqS.js";
2
2
  export { normalizeTurbowatchLocalNodeModulesOptions, turbowatchLocalNodeModules };
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_watch_local_node_modules = require("./watch-local-node-modules-0DugEhkt.cjs");
2
+ const require_watch_local_node_modules = require("./watch-local-node-modules-D4Eoulp5.cjs");
3
3
  exports.turbowatchLocalNodeModules = require_watch_local_node_modules.turbowatchLocalNodeModules;
@@ -1,2 +1,2 @@
1
- import { t as turbowatchLocalNodeModules } from "./watch-local-node-modules-gDrf144G.js";
1
+ import { t as turbowatchLocalNodeModules } from "./watch-local-node-modules-DCaYNkqS.js";
2
2
  export { turbowatchLocalNodeModules };
@@ -0,0 +1,3 @@
1
+ declare const _default: Record<string, any>;
2
+ export default _default;
3
+ //# sourceMappingURL=vite.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["../vite.config.ts"],"names":[],"mappings":";AAMA,wBAOE"}
@@ -0,0 +1,2 @@
1
+ export { vitestNodeConfig as default } from '@alexaegis/vitest';
2
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
@@ -117,4 +117,4 @@ Object.defineProperty(exports, "turbowatchLocalNodeModules", {
117
117
  }
118
118
  });
119
119
 
120
- //# sourceMappingURL=watch-local-node-modules-0DugEhkt.cjs.map
120
+ //# sourceMappingURL=watch-local-node-modules-D4Eoulp5.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch-local-node-modules-0DugEhkt.cjs","names":[],"sources":["../src/internal/watch-local-node-modules.options.ts","../src/internal/watch-local-node-modules.ts"],"sourcesContent":["import type { Defined } from '@alexaegis/common';\nimport { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport type { ChildProcess } from 'node:child_process';\n\nexport interface TurbowatchLocalNodeModulesOptions extends CwdOption {\n\t/**\n\t * If true, it will make sure ignore statements do not contain node_modules\n\t * so the watcher can watch the entire dependency tree.\n\t *\n\t * If false deeper node_modules will be ignored.\n\t *\n\t * @default true\n\t */\n\tdeep?: boolean | undefined;\n\n\t/**\n\t * If the default ignored files like\n\t * - 'dist'\n\t * - '.turbo'\n\t * - '.vercel'\n\t * - '.cache'\n\t * - 'coverage'\n\t * - 'build'\n\t *\n\t * Does not suffice, you can enable this and then it will read all the\n\t * .gitignore files up your project root and include those too in the do\n\t * not watch list. This could potentially ignore more than you actually\n\t * want though!\n\t *\n\t * @default false\n\t */\n\tuseGitIgnore?: boolean | undefined;\n\n\t/**\n\t * Log out changed files on every change. Useful for debugging if you\n\t * notice builds are getting triggered over and over again.\n\t *\n\t * @default false\n\t */\n\tlogChangedFiles?: boolean | undefined;\n\n\t/**\n\t * The command used to build the dependencies of this package.\n\t *\n\t * @default 'build:dependencies'\n\t */\n\tbuildDependenciesScript?: string | undefined;\n\n\t/**\n\t * Which package manager to invoke when running buildDependenciesScript\n\t *\n\t * @default 'pnpm'\n\t */\n\tpackageManagerCommand?: string | undefined;\n\n\t/**\n\t * Called the first time buildDependenciesScript finished\n\t * You can use this to start your app if the way devScript doesn't suffice.\n\t * If this is defined, devScript will not be used!\n\t *\n\t * It can be async but it won't be awaited!\n\t */\n\tonFirstBuild?: (() => ChildProcess | undefined) | undefined;\n\n\t/**\n\t * What package.json script should be started once buildDependenciesScript\n\t * is first finished. By default it's `dev_` with an underscore at the\n\t * end as this turbowatch call should be named `dev`\n\t *\n\t * @default 'dev_'\n\t */\n\tdevScript?: string | undefined;\n}\n\n// type gr= Defined<Omit<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>>\n// type asd = Pick<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>\n// type hhrt = gr | asd\n// const a :hhrt ={}\n\nexport type NormalizedTurbowatchLocalNodeModulesOptions = Defined<\n\tOmit<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>\n> &\n\tPick<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>;\n\nexport const normalizeTurbowatchLocalNodeModulesOptions = (\n\toptions?: TurbowatchLocalNodeModulesOptions,\n): NormalizedTurbowatchLocalNodeModulesOptions => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\tdeep: options?.deep ?? true,\n\t\tuseGitIgnore: options?.useGitIgnore ?? false,\n\t\tlogChangedFiles: options?.logChangedFiles ?? false,\n\t\tbuildDependenciesScript: options?.buildDependenciesScript ?? 'build:dependencies',\n\t\tpackageManagerCommand: options?.packageManagerCommand ?? 'pnpm',\n\t\tonFirstBuild: options?.onFirstBuild,\n\t\tdevScript: options?.devScript ?? 'dev_',\n\t};\n};\n","import { isNotNullish, noopAsync } from '@alexaegis/common';\nimport {\n\tNODE_MODULES_DIRECTORY_NAME,\n\tcollectIgnoreEntries,\n\tcollectWorkspacePackages,\n\tgetCurrentPackageRoot,\n} from '@alexaegis/workspace-tools';\nimport { ChildProcess, spawn } from 'node:child_process';\nimport { join } from 'node:path';\nimport type { Expression } from 'turbowatch';\nimport {\n\tnormalizeTurbowatchLocalNodeModulesOptions,\n\ttype TurbowatchLocalNodeModulesOptions,\n} from './watch-local-node-modules.options.js';\n\n/**\n * Defines a turbowatch config that runs a build command everytime something\n * changes in `node_modules`, where all the local dependencies expected to be\n * linked.\n */\nexport const turbowatchLocalNodeModules = async (\n\trawOptions?: TurbowatchLocalNodeModulesOptions,\n): Promise<Parameters<typeof import('turbowatch').watch>[0]> => {\n\tconst options = normalizeTurbowatchLocalNodeModulesOptions(rawOptions);\n\tconsole.log('turbowatch started in', options.cwd);\n\tconst currentPackagePath = getCurrentPackageRoot(options.cwd);\n\tif (!currentPackagePath) {\n\t\tthrow new Error('Not in a package!');\n\t}\n\n\tconst currentPackagesNodeModulesPath = join(currentPackagePath, NODE_MODULES_DIRECTORY_NAME);\n\n\tconst workspacePackages = await collectWorkspacePackages({\n\t\t...options,\n\t\tskipWorkspaceRoot: true,\n\t});\n\n\t/**\n\t * Pakk modifies it on build, as it's not part of the source code, and is\n\t * actually a result of build, it should be skipped.\n\t */\n\tconst doNotMatchPackageJson: Expression = ['not', ['match', 'package.json', 'basename']];\n\n\t/**\n\t * Only trigger changes within local packages in a workspace\n\t */\n\tconst matchInLocalPackageDirectories: Expression = [\n\t\t'anyof',\n\t\t...workspacePackages\n\t\t\t.map((workspacePackage) => workspacePackage.packageJson.name)\n\t\t\t.filter(isNotNullish)\n\t\t\t.map<Expression>((packageName) => ['dirname', packageName]),\n\t];\n\n\tconst commonIgnoredDirs: Expression[] = [\n\t\t['dirname', 'dist'],\n\t\t['dirname', 'out'],\n\t\t['dirname', 'build'],\n\t\t['dirname', 'coverage'],\n\t\t['dirname', '.turbo'],\n\t\t['dirname', '.vercel'],\n\t\t['dirname', '.cache'],\n\t\t['dirname', '.svelte-kit'],\n\t\t['dirname', '.next'],\n\t\t['match', 'vite(st)?.config.*'],\n\t];\n\n\tif (!options.deep) {\n\t\tcommonIgnoredDirs.push(['dirname', 'node_modules']); // This prevents deep dependencies from being watched\n\t}\n\n\tconst doNotMatchCommonOutputs: Expression = ['not', ['anyof', ...commonIgnoredDirs]];\n\n\tconst watchExpression: Expression = [\n\t\t'allof',\n\t\tmatchInLocalPackageDirectories,\n\t\tdoNotMatchCommonOutputs,\n\t\tdoNotMatchPackageJson,\n\t];\n\n\tif (options.useGitIgnore) {\n\t\tlet ignoreEntries = await collectIgnoreEntries(options);\n\n\t\tif (options.deep) {\n\t\t\tignoreEntries = ignoreEntries.filter(\n\t\t\t\t(entry) => !entry.includes(NODE_MODULES_DIRECTORY_NAME),\n\t\t\t);\n\t\t}\n\n\t\tconst ignoreMatchEntries = ignoreEntries.map<Expression>((ignoreEntry) => [\n\t\t\t'match',\n\t\t\tignoreEntry,\n\t\t]);\n\n\t\tconst doNotMatchIgnored: Expression = ['not', ['anyof', ...ignoreMatchEntries]];\n\t\twatchExpression.push(doNotMatchIgnored);\n\t}\n\n\tlet changeCount = 0;\n\n\tconst startCommand = (): ChildProcess => {\n\t\treturn spawn(options.packageManagerCommand, ['run', options.devScript], {\n\t\t\tstdio: 'inherit',\n\t\t});\n\t};\n\n\tlet spawnedOnFirstBuild: ChildProcess | undefined;\n\tconst abortController: AbortController = new AbortController();\n\n\treturn {\n\t\tproject: currentPackagesNodeModulesPath,\n\t\tdebounce: { wait: 50 },\n\t\tabortController,\n\t\ttriggers: [\n\t\t\t{\n\t\t\t\texpression: watchExpression,\n\t\t\t\tname: 'build',\n\t\t\t\tretry: { retries: 0 },\n\t\t\t\tonChange: async ({ spawn, files }) => {\n\t\t\t\t\tif (options.logChangedFiles) {\n\t\t\t\t\t\tconsole.log('changed files:', files);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait spawn`${options.packageManagerCommand} run ${options.buildDependenciesScript}`;\n\t\t\t\t\tif (changeCount < 1) {\n\t\t\t\t\t\tspawnedOnFirstBuild = options.onFirstBuild\n\t\t\t\t\t\t\t? options.onFirstBuild()\n\t\t\t\t\t\t\t: startCommand();\n\n\t\t\t\t\t\tif (spawnedOnFirstBuild) {\n\t\t\t\t\t\t\tspawnedOnFirstBuild.on('exit', () => {\n\t\t\t\t\t\t\t\tabortController.abort('onFirstBuild command exited!');\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchangeCount++;\n\t\t\t\t},\n\t\t\t\tonTeardown: async (): Promise<void> => {\n\t\t\t\t\tif (spawnedOnFirstBuild) {\n\t\t\t\t\t\tspawnedOnFirstBuild.kill();\n\t\t\t\t\t}\n\t\t\t\t\tawait noopAsync();\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n};\n"],"mappings":";;;;;;AAoFA,IAAa,8CACZ,YACiD;AACjD,QAAO;EACN,IAAA,GAAA,cAAA,oBAAsB,QAAQ;EAC9B,MAAM,SAAS,QAAQ;EACvB,cAAc,SAAS,gBAAgB;EACvC,iBAAiB,SAAS,mBAAmB;EAC7C,yBAAyB,SAAS,2BAA2B;EAC7D,uBAAuB,SAAS,yBAAyB;EACzD,cAAc,SAAS;EACvB,WAAW,SAAS,aAAa;EACjC;;;;;;;;;AC5EF,IAAa,6BAA6B,OACzC,eAC+D;CAC/D,MAAM,UAAU,2CAA2C,WAAW;AACtE,SAAQ,IAAI,yBAAyB,QAAQ,IAAI;CACjD,MAAM,sBAAA,GAAA,2BAAA,uBAA2C,QAAQ,IAAI;AAC7D,KAAI,CAAC,mBACJ,OAAM,IAAI,MAAM,oBAAoB;CAGrC,MAAM,kCAAA,GAAA,UAAA,MAAsC,oBAAoB,2BAAA,4BAA4B;CAE5F,MAAM,oBAAoB,OAAA,GAAA,2BAAA,0BAA+B;EACxD,GAAG;EACH,mBAAmB;EACnB,CAAC;;;;;CAMF,MAAM,wBAAoC,CAAC,OAAO;EAAC;EAAS;EAAgB;E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AAG;GACrB,UAAU,OAAO,EAAE,OAAO,YAAY;AACrC,QAAI,QAAQ,gBACX,SAAQ,IAAI,kBAAkB,MAAM;AAGrC,UAAM,KAAK,GAAG,QAAQ,sBAAsB,OAAO,QAAQ;AAC3D,QAAI,cAAc,GAAG;AACpB,2BAAsB,QAAQ,eAC3B,QAAQ,cAAc,GACtB,cAAc;AAEjB,SAAI,oBACH,qBAAoB,GAAG,cAAc;AACpC,sBAAgB,MAAM,+BAA+B;OACpD;;AAGJ;;GAED,YAAY,YAA2B;AACtC,QAAI,oBACH,qBAAoB,MAAM;AAE3B,WAAA,GAAA,kBAAA,YAAiB;;GAElB,CACD;EACD"}
1
+ {"version":3,"file":"watch-local-node-modules-D4Eoulp5.cjs","names":[],"sources":["../src/internal/watch-local-node-modules.options.ts","../src/internal/watch-local-node-modules.ts"],"sourcesContent":["import type { Defined } from '@alexaegis/common';\nimport { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport type { ChildProcess } from 'node:child_process';\n\nexport interface TurbowatchLocalNodeModulesOptions extends CwdOption {\n\t/**\n\t * If true, it will make sure ignore statements do not contain node_modules\n\t * so the watcher can watch the entire dependency tree.\n\t *\n\t * If false deeper node_modules will be ignored.\n\t *\n\t * @default true\n\t */\n\tdeep?: boolean | undefined;\n\n\t/**\n\t * If the default ignored files like\n\t * - 'dist'\n\t * - '.turbo'\n\t * - '.vercel'\n\t * - '.cache'\n\t * - 'coverage'\n\t * - 'build'\n\t *\n\t * Does not suffice, you can enable this and then it will read all the\n\t * .gitignore files up your project root and include those too in the do\n\t * not watch list. This could potentially ignore more than you actually\n\t * want though!\n\t *\n\t * @default false\n\t */\n\tuseGitIgnore?: boolean | undefined;\n\n\t/**\n\t * Log out changed files on every change. Useful for debugging if you\n\t * notice builds are getting triggered over and over again.\n\t *\n\t * @default false\n\t */\n\tlogChangedFiles?: boolean | undefined;\n\n\t/**\n\t * The command used to build the dependencies of this package.\n\t *\n\t * @default 'build:dependencies'\n\t */\n\tbuildDependenciesScript?: string | undefined;\n\n\t/**\n\t * Which package manager to invoke when running buildDependenciesScript\n\t *\n\t * @default 'pnpm'\n\t */\n\tpackageManagerCommand?: string | undefined;\n\n\t/**\n\t * Called the first time buildDependenciesScript finished\n\t * You can use this to start your app if the way devScript doesn't suffice.\n\t * If this is defined, devScript will not be used!\n\t *\n\t * It can be async but it won't be awaited!\n\t */\n\tonFirstBuild?: (() => ChildProcess | undefined) | undefined;\n\n\t/**\n\t * What package.json script should be started once buildDependenciesScript\n\t * is first finished. By default it's `dev_` with an underscore at the\n\t * end as this turbowatch call should be named `dev`\n\t *\n\t * @default 'dev_'\n\t */\n\tdevScript?: string | undefined;\n}\n\n// type gr= Defined<Omit<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>>\n// type asd = Pick<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>\n// type hhrt = gr | asd\n// const a :hhrt ={}\n\nexport type NormalizedTurbowatchLocalNodeModulesOptions = Defined<\n\tOmit<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>\n> &\n\tPick<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>;\n\nexport const normalizeTurbowatchLocalNodeModulesOptions = (\n\toptions?: TurbowatchLocalNodeModulesOptions,\n): NormalizedTurbowatchLocalNodeModulesOptions => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\tdeep: options?.deep ?? true,\n\t\tuseGitIgnore: options?.useGitIgnore ?? false,\n\t\tlogChangedFiles: options?.logChangedFiles ?? false,\n\t\tbuildDependenciesScript: options?.buildDependenciesScript ?? 'build:dependencies',\n\t\tpackageManagerCommand: options?.packageManagerCommand ?? 'pnpm',\n\t\tonFirstBuild: options?.onFirstBuild,\n\t\tdevScript: options?.devScript ?? 'dev_',\n\t};\n};\n","import { isNotNullish, noopAsync } from '@alexaegis/common';\nimport {\n\tNODE_MODULES_DIRECTORY_NAME,\n\tcollectIgnoreEntries,\n\tcollectWorkspacePackages,\n\tgetCurrentPackageRoot,\n} from '@alexaegis/workspace-tools';\nimport { ChildProcess, spawn } from 'node:child_process';\nimport { join } from 'node:path';\nimport type { Expression } from 'turbowatch';\nimport {\n\tnormalizeTurbowatchLocalNodeModulesOptions,\n\ttype TurbowatchLocalNodeModulesOptions,\n} from './watch-local-node-modules.options.js';\n\n/**\n * Defines a turbowatch config that runs a build command everytime something\n * changes in `node_modules`, where all the local dependencies expected to be\n * linked.\n */\nexport const turbowatchLocalNodeModules = async (\n\trawOptions?: TurbowatchLocalNodeModulesOptions,\n): Promise<Parameters<typeof import('turbowatch').watch>[0]> => {\n\tconst options = normalizeTurbowatchLocalNodeModulesOptions(rawOptions);\n\tconsole.log('turbowatch started in', options.cwd);\n\tconst currentPackagePath = getCurrentPackageRoot(options.cwd);\n\tif (!currentPackagePath) {\n\t\tthrow new Error('Not in a package!');\n\t}\n\n\tconst currentPackagesNodeModulesPath = join(currentPackagePath, NODE_MODULES_DIRECTORY_NAME);\n\n\tconst workspacePackages = await collectWorkspacePackages({\n\t\t...options,\n\t\tskipWorkspaceRoot: true,\n\t});\n\n\t/**\n\t * Pakk modifies it on build, as it's not part of the source code, and is\n\t * actually a result of build, it should be skipped.\n\t */\n\tconst doNotMatchPackageJson: Expression = ['not', ['match', 'package.json', 'basename']];\n\n\t/**\n\t * Only trigger changes within local packages in a workspace\n\t */\n\tconst matchInLocalPackageDirectories: Expression = [\n\t\t'anyof',\n\t\t...workspacePackages\n\t\t\t.map((workspacePackage) => workspacePackage.packageJson.name)\n\t\t\t.filter(isNotNullish)\n\t\t\t.map<Expression>((packageName) => ['dirname', packageName]),\n\t];\n\n\tconst commonIgnoredDirs: Expression[] = [\n\t\t['dirname', 'dist'],\n\t\t['dirname', 'out'],\n\t\t['dirname', 'build'],\n\t\t['dirname', 'coverage'],\n\t\t['dirname', '.turbo'],\n\t\t['dirname', '.vercel'],\n\t\t['dirname', '.cache'],\n\t\t['dirname', '.svelte-kit'],\n\t\t['dirname', '.next'],\n\t\t['match', 'vite(st)?.config.*'],\n\t];\n\n\tif (!options.deep) {\n\t\tcommonIgnoredDirs.push(['dirname', 'node_modules']); // This prevents deep dependencies from being watched\n\t}\n\n\tconst doNotMatchCommonOutputs: Expression = ['not', ['anyof', ...commonIgnoredDirs]];\n\n\tconst watchExpression: Expression = [\n\t\t'allof',\n\t\tmatchInLocalPackageDirectories,\n\t\tdoNotMatchCommonOutputs,\n\t\tdoNotMatchPackageJson,\n\t];\n\n\tif (options.useGitIgnore) {\n\t\tlet ignoreEntries = await collectIgnoreEntries(options);\n\n\t\tif (options.deep) {\n\t\t\tignoreEntries = ignoreEntries.filter(\n\t\t\t\t(entry) => !entry.includes(NODE_MODULES_DIRECTORY_NAME),\n\t\t\t);\n\t\t}\n\n\t\tconst ignoreMatchEntries = ignoreEntries.map<Expression>((ignoreEntry) => [\n\t\t\t'match',\n\t\t\tignoreEntry,\n\t\t]);\n\n\t\tconst doNotMatchIgnored: Expression = ['not', ['anyof', ...ignoreMatchEntries]];\n\t\twatchExpression.push(doNotMatchIgnored);\n\t}\n\n\tlet changeCount = 0;\n\n\tconst startCommand = (): ChildProcess => {\n\t\treturn spawn(options.packageManagerCommand, ['run', options.devScript], {\n\t\t\tstdio: 'inherit',\n\t\t});\n\t};\n\n\tlet spawnedOnFirstBuild: ChildProcess | undefined;\n\tconst abortController: AbortController = new AbortController();\n\n\treturn {\n\t\tproject: currentPackagesNodeModulesPath,\n\t\tdebounce: { wait: 50 },\n\t\tabortController,\n\t\ttriggers: [\n\t\t\t{\n\t\t\t\texpression: watchExpression,\n\t\t\t\tname: 'build',\n\t\t\t\tretry: { retries: 0 },\n\t\t\t\tonChange: async ({ spawn, files }) => {\n\t\t\t\t\tif (options.logChangedFiles) {\n\t\t\t\t\t\tconsole.log('changed files:', files);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait spawn`${options.packageManagerCommand} run ${options.buildDependenciesScript}`;\n\t\t\t\t\tif (changeCount < 1) {\n\t\t\t\t\t\tspawnedOnFirstBuild = options.onFirstBuild\n\t\t\t\t\t\t\t? options.onFirstBuild()\n\t\t\t\t\t\t\t: startCommand();\n\n\t\t\t\t\t\tif (spawnedOnFirstBuild) {\n\t\t\t\t\t\t\tspawnedOnFirstBuild.on('exit', () => {\n\t\t\t\t\t\t\t\tabortController.abort('onFirstBuild command exited!');\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchangeCount++;\n\t\t\t\t},\n\t\t\t\tonTeardown: async (): Promise<void> => {\n\t\t\t\t\tif (spawnedOnFirstBuild) {\n\t\t\t\t\t\tspawnedOnFirstBuild.kill();\n\t\t\t\t\t}\n\t\t\t\t\tawait noopAsync();\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n};\n"],"mappings":";;;;;;AAoFA,IAAa,8CACZ,YACiD;CACjD,OAAO;EACN,IAAA,GAAA,cAAA,oBAAsB,OAAO;EAC7B,MAAM,SAAS,QAAQ;EACvB,cAAc,SAAS,gBAAgB;EACvC,iBAAiB,SAAS,mBAAmB;EAC7C,yBAAyB,SAAS,2BAA2B;EAC7D,uBAAuB,SAAS,yBAAyB;EACzD,cAAc,SAAS;EACvB,WAAW,SAAS,aAAa;CAClC;AACD;;;;;;;;AC7EA,IAAa,6BAA6B,OACzC,eAC+D;CAC/D,MAAM,UAAU,2CAA2C,UAAU;CACrE,QAAQ,IAAI,yBAAyB,QAAQ,GAAG;CAChD,MAAM,sBAAA,GAAA,2BAAA,uBAA2C,QAAQ,GAAG;CAC5D,IAAI,CAAC,oBACJ,MAAM,IAAI,MAAM,mBAAmB;CAGpC,MAAM,kCAAA,GAAA,UAAA,MAAsC,oBAAoB,2BAAA,2BAA2B;CAE3F,MAAM,oBAAoB,OAAA,GAAA,2BAAA,0BAA+B;EACxD,GAAG;EACH,mBAAmB;CACpB,CAAC;;;;;CAMD,MAAM,wBAAoC,CAAC,OAAO;EAAC;EAAS;EAAgB;CAAU,CAAC;;;;CAKvF,MAAM,iCAA6C,CAClD,SACA,GAAG,k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,IAAI,QAAQ,iBACX,QAAQ,IAAI,kBAAkB,KAAK;IAGpC,MAAM,KAAK,GAAG,QAAQ,sBAAsB,OAAO,QAAQ;IAC3D,IAAI,cAAc,GAAG;KACpB,sBAAsB,QAAQ,eAC3B,QAAQ,aAAa,IACrB,aAAa;KAEhB,IAAI,qBACH,oBAAoB,GAAG,cAAc;MACpC,gBAAgB,MAAM,8BAA8B;KACrD,CAAC;IAEH;IACA;GACD;GACA,YAAY,YAA2B;IACtC,IAAI,qBACH,oBAAoB,KAAK;IAE1B,OAAA,GAAA,kBAAA,WAAgB;GACjB;EACD,CACD;CACD;AACD"}
@@ -106,4 +106,4 @@ var turbowatchLocalNodeModules = async (rawOptions) => {
106
106
  //#endregion
107
107
  export { normalizeTurbowatchLocalNodeModulesOptions as n, turbowatchLocalNodeModules as t };
108
108
 
109
- //# sourceMappingURL=watch-local-node-modules-gDrf144G.js.map
109
+ //# sourceMappingURL=watch-local-node-modules-DCaYNkqS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch-local-node-modules-gDrf144G.js","names":[],"sources":["../src/internal/watch-local-node-modules.options.ts","../src/internal/watch-local-node-modules.ts"],"sourcesContent":["import type { Defined } from '@alexaegis/common';\nimport { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport type { ChildProcess } from 'node:child_process';\n\nexport interface TurbowatchLocalNodeModulesOptions extends CwdOption {\n\t/**\n\t * If true, it will make sure ignore statements do not contain node_modules\n\t * so the watcher can watch the entire dependency tree.\n\t *\n\t * If false deeper node_modules will be ignored.\n\t *\n\t * @default true\n\t */\n\tdeep?: boolean | undefined;\n\n\t/**\n\t * If the default ignored files like\n\t * - 'dist'\n\t * - '.turbo'\n\t * - '.vercel'\n\t * - '.cache'\n\t * - 'coverage'\n\t * - 'build'\n\t *\n\t * Does not suffice, you can enable this and then it will read all the\n\t * .gitignore files up your project root and include those too in the do\n\t * not watch list. This could potentially ignore more than you actually\n\t * want though!\n\t *\n\t * @default false\n\t */\n\tuseGitIgnore?: boolean | undefined;\n\n\t/**\n\t * Log out changed files on every change. Useful for debugging if you\n\t * notice builds are getting triggered over and over again.\n\t *\n\t * @default false\n\t */\n\tlogChangedFiles?: boolean | undefined;\n\n\t/**\n\t * The command used to build the dependencies of this package.\n\t *\n\t * @default 'build:dependencies'\n\t */\n\tbuildDependenciesScript?: string | undefined;\n\n\t/**\n\t * Which package manager to invoke when running buildDependenciesScript\n\t *\n\t * @default 'pnpm'\n\t */\n\tpackageManagerCommand?: string | undefined;\n\n\t/**\n\t * Called the first time buildDependenciesScript finished\n\t * You can use this to start your app if the way devScript doesn't suffice.\n\t * If this is defined, devScript will not be used!\n\t *\n\t * It can be async but it won't be awaited!\n\t */\n\tonFirstBuild?: (() => ChildProcess | undefined) | undefined;\n\n\t/**\n\t * What package.json script should be started once buildDependenciesScript\n\t * is first finished. By default it's `dev_` with an underscore at the\n\t * end as this turbowatch call should be named `dev`\n\t *\n\t * @default 'dev_'\n\t */\n\tdevScript?: string | undefined;\n}\n\n// type gr= Defined<Omit<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>>\n// type asd = Pick<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>\n// type hhrt = gr | asd\n// const a :hhrt ={}\n\nexport type NormalizedTurbowatchLocalNodeModulesOptions = Defined<\n\tOmit<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>\n> &\n\tPick<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>;\n\nexport const normalizeTurbowatchLocalNodeModulesOptions = (\n\toptions?: TurbowatchLocalNodeModulesOptions,\n): NormalizedTurbowatchLocalNodeModulesOptions => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\tdeep: options?.deep ?? true,\n\t\tuseGitIgnore: options?.useGitIgnore ?? false,\n\t\tlogChangedFiles: options?.logChangedFiles ?? false,\n\t\tbuildDependenciesScript: options?.buildDependenciesScript ?? 'build:dependencies',\n\t\tpackageManagerCommand: options?.packageManagerCommand ?? 'pnpm',\n\t\tonFirstBuild: options?.onFirstBuild,\n\t\tdevScript: options?.devScript ?? 'dev_',\n\t};\n};\n","import { isNotNullish, noopAsync } from '@alexaegis/common';\nimport {\n\tNODE_MODULES_DIRECTORY_NAME,\n\tcollectIgnoreEntries,\n\tcollectWorkspacePackages,\n\tgetCurrentPackageRoot,\n} from '@alexaegis/workspace-tools';\nimport { ChildProcess, spawn } from 'node:child_process';\nimport { join } from 'node:path';\nimport type { Expression } from 'turbowatch';\nimport {\n\tnormalizeTurbowatchLocalNodeModulesOptions,\n\ttype TurbowatchLocalNodeModulesOptions,\n} from './watch-local-node-modules.options.js';\n\n/**\n * Defines a turbowatch config that runs a build command everytime something\n * changes in `node_modules`, where all the local dependencies expected to be\n * linked.\n */\nexport const turbowatchLocalNodeModules = async (\n\trawOptions?: TurbowatchLocalNodeModulesOptions,\n): Promise<Parameters<typeof import('turbowatch').watch>[0]> => {\n\tconst options = normalizeTurbowatchLocalNodeModulesOptions(rawOptions);\n\tconsole.log('turbowatch started in', options.cwd);\n\tconst currentPackagePath = getCurrentPackageRoot(options.cwd);\n\tif (!currentPackagePath) {\n\t\tthrow new Error('Not in a package!');\n\t}\n\n\tconst currentPackagesNodeModulesPath = join(currentPackagePath, NODE_MODULES_DIRECTORY_NAME);\n\n\tconst workspacePackages = await collectWorkspacePackages({\n\t\t...options,\n\t\tskipWorkspaceRoot: true,\n\t});\n\n\t/**\n\t * Pakk modifies it on build, as it's not part of the source code, and is\n\t * actually a result of build, it should be skipped.\n\t */\n\tconst doNotMatchPackageJson: Expression = ['not', ['match', 'package.json', 'basename']];\n\n\t/**\n\t * Only trigger changes within local packages in a workspace\n\t */\n\tconst matchInLocalPackageDirectories: Expression = [\n\t\t'anyof',\n\t\t...workspacePackages\n\t\t\t.map((workspacePackage) => workspacePackage.packageJson.name)\n\t\t\t.filter(isNotNullish)\n\t\t\t.map<Expression>((packageName) => ['dirname', packageName]),\n\t];\n\n\tconst commonIgnoredDirs: Expression[] = [\n\t\t['dirname', 'dist'],\n\t\t['dirname', 'out'],\n\t\t['dirname', 'build'],\n\t\t['dirname', 'coverage'],\n\t\t['dirname', '.turbo'],\n\t\t['dirname', '.vercel'],\n\t\t['dirname', '.cache'],\n\t\t['dirname', '.svelte-kit'],\n\t\t['dirname', '.next'],\n\t\t['match', 'vite(st)?.config.*'],\n\t];\n\n\tif (!options.deep) {\n\t\tcommonIgnoredDirs.push(['dirname', 'node_modules']); // This prevents deep dependencies from being watched\n\t}\n\n\tconst doNotMatchCommonOutputs: Expression = ['not', ['anyof', ...commonIgnoredDirs]];\n\n\tconst watchExpression: Expression = [\n\t\t'allof',\n\t\tmatchInLocalPackageDirectories,\n\t\tdoNotMatchCommonOutputs,\n\t\tdoNotMatchPackageJson,\n\t];\n\n\tif (options.useGitIgnore) {\n\t\tlet ignoreEntries = await collectIgnoreEntries(options);\n\n\t\tif (options.deep) {\n\t\t\tignoreEntries = ignoreEntries.filter(\n\t\t\t\t(entry) => !entry.includes(NODE_MODULES_DIRECTORY_NAME),\n\t\t\t);\n\t\t}\n\n\t\tconst ignoreMatchEntries = ignoreEntries.map<Expression>((ignoreEntry) => [\n\t\t\t'match',\n\t\t\tignoreEntry,\n\t\t]);\n\n\t\tconst doNotMatchIgnored: Expression = ['not', ['anyof', ...ignoreMatchEntries]];\n\t\twatchExpression.push(doNotMatchIgnored);\n\t}\n\n\tlet changeCount = 0;\n\n\tconst startCommand = (): ChildProcess => {\n\t\treturn spawn(options.packageManagerCommand, ['run', options.devScript], {\n\t\t\tstdio: 'inherit',\n\t\t});\n\t};\n\n\tlet spawnedOnFirstBuild: ChildProcess | undefined;\n\tconst abortController: AbortController = new AbortController();\n\n\treturn {\n\t\tproject: currentPackagesNodeModulesPath,\n\t\tdebounce: { wait: 50 },\n\t\tabortController,\n\t\ttriggers: [\n\t\t\t{\n\t\t\t\texpression: watchExpression,\n\t\t\t\tname: 'build',\n\t\t\t\tretry: { retries: 0 },\n\t\t\t\tonChange: async ({ spawn, files }) => {\n\t\t\t\t\tif (options.logChangedFiles) {\n\t\t\t\t\t\tconsole.log('changed files:', files);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait spawn`${options.packageManagerCommand} run ${options.buildDependenciesScript}`;\n\t\t\t\t\tif (changeCount < 1) {\n\t\t\t\t\t\tspawnedOnFirstBuild = options.onFirstBuild\n\t\t\t\t\t\t\t? options.onFirstBuild()\n\t\t\t\t\t\t\t: startCommand();\n\n\t\t\t\t\t\tif (spawnedOnFirstBuild) {\n\t\t\t\t\t\t\tspawnedOnFirstBuild.on('exit', () => {\n\t\t\t\t\t\t\t\tabortController.abort('onFirstBuild command exited!');\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchangeCount++;\n\t\t\t\t},\n\t\t\t\tonTeardown: async (): Promise<void> => {\n\t\t\t\t\tif (spawnedOnFirstBuild) {\n\t\t\t\t\t\tspawnedOnFirstBuild.kill();\n\t\t\t\t\t}\n\t\t\t\t\tawait noopAsync();\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n};\n"],"mappings":";;;;;;AAoFA,IAAa,8CACZ,YACiD;AACjD,QAAO;EACN,GAAG,mBAAmB,QAAQ;EAC9B,MAAM,SAAS,QAAQ;EACvB,cAAc,SAAS,gBAAgB;EACvC,iBAAiB,SAAS,mBAAmB;EAC7C,yBAAyB,SAAS,2BAA2B;EAC7D,uBAAuB,SAAS,yBAAyB;EACzD,cAAc,SAAS;EACvB,WAAW,SAAS,aAAa;EACjC;;;;;;;;;AC5EF,IAAa,6BAA6B,OACzC,eAC+D;CAC/D,MAAM,UAAU,2CAA2C,WAAW;AACtE,SAAQ,IAAI,yBAAyB,QAAQ,IAAI;CACjD,MAAM,qBAAqB,sBAAsB,QAAQ,IAAI;AAC7D,KAAI,CAAC,mBACJ,OAAM,IAAI,MAAM,oBAAoB;CAGrC,MAAM,iCAAiC,KAAK,oBAAoB,4BAA4B;CAE5F,MAAM,oBAAoB,MAAM,yBAAyB;EACxD,G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GACC,YAAY;GACZ,MAAM;GACN,OAAO,EAAE,SAAS,GAAG;GACrB,UAAU,OAAO,EAAE,OAAO,YAAY;AACrC,QAAI,QAAQ,gBACX,SAAQ,IAAI,kBAAkB,MAAM;AAGrC,UAAM,KAAK,GAAG,QAAQ,sBAAsB,OAAO,QAAQ;AAC3D,QAAI,cAAc,GAAG;AACpB,2BAAsB,QAAQ,eAC3B,QAAQ,cAAc,GACtB,cAAc;AAEjB,SAAI,oBACH,qBAAoB,GAAG,cAAc;AACpC,sBAAgB,MAAM,+BAA+B;OACpD;;AAGJ;;GAED,YAAY,YAA2B;AACtC,QAAI,oBACH,qBAAoB,MAAM;AAE3B,UAAM,WAAW;;GAElB,CACD;EACD"}
1
+ {"version":3,"file":"watch-local-node-modules-DCaYNkqS.js","names":[],"sources":["../src/internal/watch-local-node-modules.options.ts","../src/internal/watch-local-node-modules.ts"],"sourcesContent":["import type { Defined } from '@alexaegis/common';\nimport { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport type { ChildProcess } from 'node:child_process';\n\nexport interface TurbowatchLocalNodeModulesOptions extends CwdOption {\n\t/**\n\t * If true, it will make sure ignore statements do not contain node_modules\n\t * so the watcher can watch the entire dependency tree.\n\t *\n\t * If false deeper node_modules will be ignored.\n\t *\n\t * @default true\n\t */\n\tdeep?: boolean | undefined;\n\n\t/**\n\t * If the default ignored files like\n\t * - 'dist'\n\t * - '.turbo'\n\t * - '.vercel'\n\t * - '.cache'\n\t * - 'coverage'\n\t * - 'build'\n\t *\n\t * Does not suffice, you can enable this and then it will read all the\n\t * .gitignore files up your project root and include those too in the do\n\t * not watch list. This could potentially ignore more than you actually\n\t * want though!\n\t *\n\t * @default false\n\t */\n\tuseGitIgnore?: boolean | undefined;\n\n\t/**\n\t * Log out changed files on every change. Useful for debugging if you\n\t * notice builds are getting triggered over and over again.\n\t *\n\t * @default false\n\t */\n\tlogChangedFiles?: boolean | undefined;\n\n\t/**\n\t * The command used to build the dependencies of this package.\n\t *\n\t * @default 'build:dependencies'\n\t */\n\tbuildDependenciesScript?: string | undefined;\n\n\t/**\n\t * Which package manager to invoke when running buildDependenciesScript\n\t *\n\t * @default 'pnpm'\n\t */\n\tpackageManagerCommand?: string | undefined;\n\n\t/**\n\t * Called the first time buildDependenciesScript finished\n\t * You can use this to start your app if the way devScript doesn't suffice.\n\t * If this is defined, devScript will not be used!\n\t *\n\t * It can be async but it won't be awaited!\n\t */\n\tonFirstBuild?: (() => ChildProcess | undefined) | undefined;\n\n\t/**\n\t * What package.json script should be started once buildDependenciesScript\n\t * is first finished. By default it's `dev_` with an underscore at the\n\t * end as this turbowatch call should be named `dev`\n\t *\n\t * @default 'dev_'\n\t */\n\tdevScript?: string | undefined;\n}\n\n// type gr= Defined<Omit<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>>\n// type asd = Pick<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>\n// type hhrt = gr | asd\n// const a :hhrt ={}\n\nexport type NormalizedTurbowatchLocalNodeModulesOptions = Defined<\n\tOmit<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>\n> &\n\tPick<TurbowatchLocalNodeModulesOptions, 'onFirstBuild'>;\n\nexport const normalizeTurbowatchLocalNodeModulesOptions = (\n\toptions?: TurbowatchLocalNodeModulesOptions,\n): NormalizedTurbowatchLocalNodeModulesOptions => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\tdeep: options?.deep ?? true,\n\t\tuseGitIgnore: options?.useGitIgnore ?? false,\n\t\tlogChangedFiles: options?.logChangedFiles ?? false,\n\t\tbuildDependenciesScript: options?.buildDependenciesScript ?? 'build:dependencies',\n\t\tpackageManagerCommand: options?.packageManagerCommand ?? 'pnpm',\n\t\tonFirstBuild: options?.onFirstBuild,\n\t\tdevScript: options?.devScript ?? 'dev_',\n\t};\n};\n","import { isNotNullish, noopAsync } from '@alexaegis/common';\nimport {\n\tNODE_MODULES_DIRECTORY_NAME,\n\tcollectIgnoreEntries,\n\tcollectWorkspacePackages,\n\tgetCurrentPackageRoot,\n} from '@alexaegis/workspace-tools';\nimport { ChildProcess, spawn } from 'node:child_process';\nimport { join } from 'node:path';\nimport type { Expression } from 'turbowatch';\nimport {\n\tnormalizeTurbowatchLocalNodeModulesOptions,\n\ttype TurbowatchLocalNodeModulesOptions,\n} from './watch-local-node-modules.options.js';\n\n/**\n * Defines a turbowatch config that runs a build command everytime something\n * changes in `node_modules`, where all the local dependencies expected to be\n * linked.\n */\nexport const turbowatchLocalNodeModules = async (\n\trawOptions?: TurbowatchLocalNodeModulesOptions,\n): Promise<Parameters<typeof import('turbowatch').watch>[0]> => {\n\tconst options = normalizeTurbowatchLocalNodeModulesOptions(rawOptions);\n\tconsole.log('turbowatch started in', options.cwd);\n\tconst currentPackagePath = getCurrentPackageRoot(options.cwd);\n\tif (!currentPackagePath) {\n\t\tthrow new Error('Not in a package!');\n\t}\n\n\tconst currentPackagesNodeModulesPath = join(currentPackagePath, NODE_MODULES_DIRECTORY_NAME);\n\n\tconst workspacePackages = await collectWorkspacePackages({\n\t\t...options,\n\t\tskipWorkspaceRoot: true,\n\t});\n\n\t/**\n\t * Pakk modifies it on build, as it's not part of the source code, and is\n\t * actually a result of build, it should be skipped.\n\t */\n\tconst doNotMatchPackageJson: Expression = ['not', ['match', 'package.json', 'basename']];\n\n\t/**\n\t * Only trigger changes within local packages in a workspace\n\t */\n\tconst matchInLocalPackageDirectories: Expression = [\n\t\t'anyof',\n\t\t...workspacePackages\n\t\t\t.map((workspacePackage) => workspacePackage.packageJson.name)\n\t\t\t.filter(isNotNullish)\n\t\t\t.map<Expression>((packageName) => ['dirname', packageName]),\n\t];\n\n\tconst commonIgnoredDirs: Expression[] = [\n\t\t['dirname', 'dist'],\n\t\t['dirname', 'out'],\n\t\t['dirname', 'build'],\n\t\t['dirname', 'coverage'],\n\t\t['dirname', '.turbo'],\n\t\t['dirname', '.vercel'],\n\t\t['dirname', '.cache'],\n\t\t['dirname', '.svelte-kit'],\n\t\t['dirname', '.next'],\n\t\t['match', 'vite(st)?.config.*'],\n\t];\n\n\tif (!options.deep) {\n\t\tcommonIgnoredDirs.push(['dirname', 'node_modules']); // This prevents deep dependencies from being watched\n\t}\n\n\tconst doNotMatchCommonOutputs: Expression = ['not', ['anyof', ...commonIgnoredDirs]];\n\n\tconst watchExpression: Expression = [\n\t\t'allof',\n\t\tmatchInLocalPackageDirectories,\n\t\tdoNotMatchCommonOutputs,\n\t\tdoNotMatchPackageJson,\n\t];\n\n\tif (options.useGitIgnore) {\n\t\tlet ignoreEntries = await collectIgnoreEntries(options);\n\n\t\tif (options.deep) {\n\t\t\tignoreEntries = ignoreEntries.filter(\n\t\t\t\t(entry) => !entry.includes(NODE_MODULES_DIRECTORY_NAME),\n\t\t\t);\n\t\t}\n\n\t\tconst ignoreMatchEntries = ignoreEntries.map<Expression>((ignoreEntry) => [\n\t\t\t'match',\n\t\t\tignoreEntry,\n\t\t]);\n\n\t\tconst doNotMatchIgnored: Expression = ['not', ['anyof', ...ignoreMatchEntries]];\n\t\twatchExpression.push(doNotMatchIgnored);\n\t}\n\n\tlet changeCount = 0;\n\n\tconst startCommand = (): ChildProcess => {\n\t\treturn spawn(options.packageManagerCommand, ['run', options.devScript], {\n\t\t\tstdio: 'inherit',\n\t\t});\n\t};\n\n\tlet spawnedOnFirstBuild: ChildProcess | undefined;\n\tconst abortController: AbortController = new AbortController();\n\n\treturn {\n\t\tproject: currentPackagesNodeModulesPath,\n\t\tdebounce: { wait: 50 },\n\t\tabortController,\n\t\ttriggers: [\n\t\t\t{\n\t\t\t\texpression: watchExpression,\n\t\t\t\tname: 'build',\n\t\t\t\tretry: { retries: 0 },\n\t\t\t\tonChange: async ({ spawn, files }) => {\n\t\t\t\t\tif (options.logChangedFiles) {\n\t\t\t\t\t\tconsole.log('changed files:', files);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait spawn`${options.packageManagerCommand} run ${options.buildDependenciesScript}`;\n\t\t\t\t\tif (changeCount < 1) {\n\t\t\t\t\t\tspawnedOnFirstBuild = options.onFirstBuild\n\t\t\t\t\t\t\t? options.onFirstBuild()\n\t\t\t\t\t\t\t: startCommand();\n\n\t\t\t\t\t\tif (spawnedOnFirstBuild) {\n\t\t\t\t\t\t\tspawnedOnFirstBuild.on('exit', () => {\n\t\t\t\t\t\t\t\tabortController.abort('onFirstBuild command exited!');\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchangeCount++;\n\t\t\t\t},\n\t\t\t\tonTeardown: async (): Promise<void> => {\n\t\t\t\t\tif (spawnedOnFirstBuild) {\n\t\t\t\t\t\tspawnedOnFirstBuild.kill();\n\t\t\t\t\t}\n\t\t\t\t\tawait noopAsync();\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t};\n};\n"],"mappings":";;;;;;AAoFA,IAAa,8CACZ,YACiD;CACjD,OAAO;EACN,GAAG,mBAAmB,OAAO;EAC7B,MAAM,SAAS,QAAQ;EACvB,cAAc,SAAS,gBAAgB;EACvC,iBAAiB,SAAS,mBAAmB;EAC7C,yBAAyB,SAAS,2BAA2B;EAC7D,uBAAuB,SAAS,yBAAyB;EACzD,cAAc,SAAS;EACvB,WAAW,SAAS,aAAa;CAClC;AACD;;;;;;;;AC7EA,IAAa,6BAA6B,OACzC,eAC+D;CAC/D,MAAM,UAAU,2CAA2C,UAAU;CACrE,QAAQ,IAAI,yBAAyB,QAAQ,GAAG;CAChD,MAAM,qBAAqB,sBAAsB,QAAQ,GAAG;CAC5D,IAAI,CAAC,oBACJ,MAAM,IAAI,MAAM,mBAAmB;CAGpC,MAAM,iCAAiC,KAAK,oBAAoB,2BAA2B;CAE3F,MAAM,oBAAoB,MAAM,yBAAyB;EACxD,GAAG;EACH,mBAAmB;CACpB,CAAC;;;;;CAMD,MAAM,wBAAoC,CAAC,OAAO;EAAC;EAAS;EAAgB;CAAU,CAAC;;;;CAKvF,MAAM,iCAA6C,CAClD,SACA,GAAG,kBACD,KAAK,qBAAqB,iBAAiB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GAAG,QAAQ,sBAAsB,OAAO,QAAQ;IAC3D,IAAI,cAAc,GAAG;KACpB,sBAAsB,QAAQ,eAC3B,QAAQ,aAAa,IACrB,aAAa;KAEhB,IAAI,qBACH,oBAAoB,GAAG,cAAc;MACpC,gBAAgB,MAAM,8BAA8B;KACrD,CAAC;IAEH;IACA;GACD;GACA,YAAY,YAA2B;IACtC,IAAI,qBACH,oBAAoB,KAAK;IAE1B,MAAM,UAAU;GACjB;EACD,CACD;CACD;AACD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alexaegis/turbowatch",
3
3
  "description": "A turbowatch configuration to watch local dependencies through node_modules",
4
- "version": "0.15.1",
4
+ "version": "0.15.2",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "archetype": {
@@ -14,7 +14,7 @@
14
14
  "turbowatch"
15
15
  ],
16
16
  "repository": {
17
- "url": "git+https://github.com/AlexAegis/js-tooling",
17
+ "url": "git+https://github.com/AlexAegis/js-tooling.git",
18
18
  "type": "git"
19
19
  },
20
20
  "type": "module",
@@ -24,6 +24,9 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
+ "engines": {
28
+ "node": ">=22.6.0"
29
+ },
27
30
  "exports": {
28
31
  ".": {
29
32
  "types": "./dist/index.d.ts",
@@ -41,22 +44,22 @@
41
44
  "./readme": "./readme.md"
42
45
  },
43
46
  "dependencies": {
44
- "@alexaegis/common": "^0.15.1",
45
- "@alexaegis/fs": "^0.15.1",
46
- "@alexaegis/workspace-tools": "^0.15.1"
47
+ "@alexaegis/common": "^0.15.2",
48
+ "@alexaegis/workspace-tools": "^0.15.2",
49
+ "@alexaegis/fs": "^0.15.2"
47
50
  },
48
51
  "devDependencies": {
49
- "@types/node": "^25.6.0",
50
- "publint": "^0.3.18",
52
+ "@types/node": "^25.9.1",
53
+ "publint": "^0.3.21",
51
54
  "turbowatch": "^2.30.0",
52
55
  "typescript": "^6.0.3",
53
- "vite": "^8.0.10",
54
- "vite-plugin-dts": "^5.0.0",
55
- "vitest": "^4.1.5",
56
- "@alexaegis/eslint-config-vitest": "^0.15.1",
57
- "@alexaegis/ts": "^0.15.1",
58
- "@alexaegis/vitest": "^0.15.1",
59
- "@alexaegis/vite": "^0.15.1"
56
+ "vite": "^8.0.16",
57
+ "vite-plugin-dts": "^5.0.2",
58
+ "vitest": "^4.1.8",
59
+ "@alexaegis/eslint-config-vitest": "^0.15.2",
60
+ "@alexaegis/ts": "^0.15.2",
61
+ "@alexaegis/vite": "^0.15.2",
62
+ "@alexaegis/vitest": "^0.15.2"
60
63
  },
61
64
  "scripts": {
62
65
  "lint:depcheck": "turbo run lint:depcheck_ --concurrency 16 --filter @alexaegis/turbowatch",