@codyswann/lisa 1.0.0 → 1.0.5
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/README.md +244 -36
- package/all/copy-overwrite/.claude/README.md +1 -3
- package/all/copy-overwrite/.claude/REFERENCE.md +519 -0
- package/all/copy-overwrite/.claude/agents/skill-evaluator.md +7 -7
- package/all/copy-overwrite/.claude/agents/test-coverage-agent.md +17 -0
- package/all/copy-overwrite/.claude/commands/git/commit.md +9 -5
- package/all/copy-overwrite/.claude/commands/git/submit-pr.md +1 -1
- package/all/copy-overwrite/.claude/commands/lisa/review-implementation.md +209 -0
- package/all/copy-overwrite/.claude/commands/project/add-test-coverage.md +58 -0
- package/all/copy-overwrite/.claude/commands/project/archive.md +1 -1
- package/all/copy-overwrite/.claude/commands/project/complete-task.md +53 -1
- package/all/copy-overwrite/.claude/commands/project/debrief.md +12 -23
- package/all/copy-overwrite/.claude/commands/project/execute.md +33 -77
- package/all/copy-overwrite/.claude/commands/project/fix-linter-error.md +87 -0
- package/all/copy-overwrite/.claude/commands/project/implement.md +24 -28
- package/all/copy-overwrite/.claude/commands/project/lower-code-complexity.md +30 -55
- package/all/copy-overwrite/.claude/commands/project/plan.md +87 -242
- package/all/copy-overwrite/.claude/commands/project/reduce-max-lines-per-function.md +76 -0
- package/all/copy-overwrite/.claude/commands/project/reduce-max-lines.md +75 -0
- package/all/copy-overwrite/.claude/commands/project/research.md +86 -188
- package/all/copy-overwrite/.claude/commands/project/review.md +19 -38
- package/all/copy-overwrite/.claude/commands/project/setup.md +1 -1
- package/all/copy-overwrite/.claude/commands/project/verify.md +62 -25
- package/all/copy-overwrite/.claude/commands/pull-request/review.md +25 -7
- package/all/copy-overwrite/.claude/commands/tasks/load.md +63 -0
- package/all/copy-overwrite/.claude/commands/tasks/sync.md +84 -0
- package/all/copy-overwrite/.claude/hooks/README.md +75 -0
- package/all/copy-overwrite/.claude/hooks/check-tired-boss.sh +61 -0
- package/all/copy-overwrite/.claude/hooks/debug-hook.sh +47 -0
- package/all/copy-overwrite/.claude/hooks/notify-ntfy.sh +2 -0
- package/all/copy-overwrite/.claude/hooks/sync-tasks.sh +95 -0
- package/all/copy-overwrite/.claude/{skills/coding-philosophy/SKILL.md → rules/coding-philosophy.md} +93 -70
- package/all/copy-overwrite/.claude/settings.json +35 -14
- package/all/copy-overwrite/.claude/skills/prompt-complexity-scorer/SKILL.md +41 -9
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/init_skill.py +2 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/package_skill.py +2 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/quick_validate.py +2 -0
- package/all/copy-overwrite/.safety-net.json +25 -0
- package/all/copy-overwrite/CLAUDE.md +8 -30
- package/all/copy-overwrite/HUMAN.md +517 -17
- package/all/create-only/.claude/rules/PROJECT_RULES.md +9 -0
- package/all/create-only/scripts/setup-deploy-key.sh +190 -0
- package/all/deletions.json +5 -0
- package/cdk/copy-overwrite/.github/workflows/ci.yml +142 -0
- package/cdk/copy-overwrite/.github/workflows/deploy.yml +59 -0
- package/cdk/copy-overwrite/eslint.cdk.ts +175 -0
- package/cdk/copy-overwrite/eslint.config.ts +51 -0
- package/cdk/copy-overwrite/eslint.slow.config.ts +80 -0
- package/cdk/copy-overwrite/knip.json +53 -0
- package/cdk/copy-overwrite/tsconfig.eslint.json +11 -0
- package/cdk/merge/package.json +17 -1
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +83 -64
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/prompts.d.ts +17 -3
- package/dist/cli/prompts.d.ts.map +1 -1
- package/dist/cli/prompts.js +52 -16
- package/dist/cli/prompts.js.map +1 -1
- package/dist/core/config.d.ts +13 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +17 -9
- package/dist/core/config.js.map +1 -1
- package/dist/core/git-service.d.ts +40 -0
- package/dist/core/git-service.d.ts.map +1 -0
- package/dist/core/git-service.js +52 -0
- package/dist/core/git-service.js.map +1 -0
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +3 -3
- package/dist/core/lisa.d.ts +124 -7
- package/dist/core/lisa.d.ts.map +1 -1
- package/dist/core/lisa.js +423 -221
- package/dist/core/lisa.js.map +1 -1
- package/dist/core/manifest.d.ts +5 -1
- package/dist/core/manifest.d.ts.map +1 -1
- package/dist/core/manifest.js +22 -16
- package/dist/core/manifest.js.map +1 -1
- package/dist/detection/detector.interface.d.ts +1 -1
- package/dist/detection/detectors/cdk.d.ts +6 -1
- package/dist/detection/detectors/cdk.d.ts.map +1 -1
- package/dist/detection/detectors/cdk.js +16 -8
- package/dist/detection/detectors/cdk.js.map +1 -1
- package/dist/detection/detectors/expo.d.ts +6 -1
- package/dist/detection/detectors/expo.d.ts.map +1 -1
- package/dist/detection/detectors/expo.js +13 -8
- package/dist/detection/detectors/expo.js.map +1 -1
- package/dist/detection/detectors/nestjs.d.ts +7 -2
- package/dist/detection/detectors/nestjs.d.ts.map +1 -1
- package/dist/detection/detectors/nestjs.js +17 -9
- package/dist/detection/detectors/nestjs.js.map +1 -1
- package/dist/detection/detectors/npm-package.d.ts +6 -1
- package/dist/detection/detectors/npm-package.d.ts.map +1 -1
- package/dist/detection/detectors/npm-package.js +9 -4
- package/dist/detection/detectors/npm-package.js.map +1 -1
- package/dist/detection/detectors/typescript.d.ts +6 -1
- package/dist/detection/detectors/typescript.d.ts.map +1 -1
- package/dist/detection/detectors/typescript.js +12 -7
- package/dist/detection/detectors/typescript.js.map +1 -1
- package/dist/detection/index.d.ts +13 -3
- package/dist/detection/index.d.ts.map +1 -1
- package/dist/detection/index.js +17 -7
- package/dist/detection/index.js.map +1 -1
- package/dist/errors/index.d.ts +66 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +89 -17
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/logging/console-logger.d.ts +21 -1
- package/dist/logging/console-logger.d.ts.map +1 -1
- package/dist/logging/console-logger.js +26 -6
- package/dist/logging/console-logger.js.map +1 -1
- package/dist/logging/index.d.ts +3 -3
- package/dist/logging/index.js +2 -2
- package/dist/logging/logger.interface.d.ts +1 -1
- package/dist/logging/silent-logger.d.ts +21 -1
- package/dist/logging/silent-logger.d.ts.map +1 -1
- package/dist/logging/silent-logger.js +20 -0
- package/dist/logging/silent-logger.js.map +1 -1
- package/dist/strategies/copy-contents.d.ts +47 -6
- package/dist/strategies/copy-contents.d.ts.map +1 -1
- package/dist/strategies/copy-contents.js +99 -49
- package/dist/strategies/copy-contents.js.map +1 -1
- package/dist/strategies/copy-overwrite.d.ts +10 -2
- package/dist/strategies/copy-overwrite.d.ts.map +1 -1
- package/dist/strategies/copy-overwrite.js +17 -9
- package/dist/strategies/copy-overwrite.js.map +1 -1
- package/dist/strategies/create-only.d.ts +10 -2
- package/dist/strategies/create-only.d.ts.map +1 -1
- package/dist/strategies/create-only.js +14 -6
- package/dist/strategies/create-only.js.map +1 -1
- package/dist/strategies/index.d.ts +17 -7
- package/dist/strategies/index.d.ts.map +1 -1
- package/dist/strategies/index.js +19 -9
- package/dist/strategies/index.js.map +1 -1
- package/dist/strategies/merge.d.ts +10 -2
- package/dist/strategies/merge.d.ts.map +1 -1
- package/dist/strategies/merge.js +21 -21
- package/dist/strategies/merge.js.map +1 -1
- package/dist/strategies/strategy.interface.d.ts +1 -1
- package/dist/strategies/strategy.interface.d.ts.map +1 -1
- package/dist/transaction/backup.d.ts +15 -1
- package/dist/transaction/backup.d.ts.map +1 -1
- package/dist/transaction/backup.js +47 -12
- package/dist/transaction/backup.js.map +1 -1
- package/dist/transaction/index.d.ts +3 -3
- package/dist/transaction/index.js +2 -2
- package/dist/transaction/transaction.d.ts +25 -2
- package/dist/transaction/transaction.d.ts.map +1 -1
- package/dist/transaction/transaction.js +25 -2
- package/dist/transaction/transaction.js.map +1 -1
- package/dist/utils/file-operations.d.ts +21 -0
- package/dist/utils/file-operations.d.ts.map +1 -1
- package/dist/utils/file-operations.js +48 -12
- package/dist/utils/file-operations.js.map +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +3 -3
- package/dist/utils/json-utils.d.ts +12 -0
- package/dist/utils/json-utils.d.ts.map +1 -1
- package/dist/utils/json-utils.js +17 -5
- package/dist/utils/json-utils.js.map +1 -1
- package/dist/utils/path-utils.d.ts +11 -0
- package/dist/utils/path-utils.d.ts.map +1 -1
- package/dist/utils/path-utils.js +12 -1
- package/dist/utils/path-utils.js.map +1 -1
- package/eslint-plugin-code-organization/__tests__/enforce-statement-order.test.js +5 -0
- package/eslint-plugin-code-organization/index.js +5 -0
- package/eslint-plugin-code-organization/rules/enforce-statement-order.js +5 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/scripts/validate_atomic_structure.py +2 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/scripts/create_component.py +2 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/scripts/validate_component.py +2 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/scripts/validate_cross_platform.py +2 -0
- package/expo/copy-overwrite/.claude/skills/directory-structure/scripts/validate_structure.py +2 -0
- package/expo/copy-overwrite/.claude/skills/expo-router-best-practices/scripts/generate-route.py +2 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/scripts/validate_styling.py +2 -41
- package/{typescript → expo}/copy-overwrite/.github/workflows/build.yml +3 -0
- package/expo/copy-overwrite/.github/workflows/ci.yml +36 -0
- package/{typescript → expo}/copy-overwrite/.github/workflows/deploy.yml +22 -26
- package/{typescript → expo}/copy-overwrite/.github/workflows/lighthouse.yml +4 -1
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/plugin-index.test.js +5 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/require-memo-in-view.test.js +5 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/single-component-per-file.test.js +5 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/index.js +5 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/enforce-component-structure.js +5 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/no-return-in-view.js +6 -1
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/require-memo-in-view.js +5 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/single-component-per-file.js +5 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/README.md +0 -68
- package/expo/copy-overwrite/eslint-plugin-ui-standards/index.js +5 -3
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-classname-outside-ui.js +5 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-direct-rn-imports.js +5 -0
- package/expo/copy-overwrite/eslint.config.ts +53 -0
- package/expo/copy-overwrite/eslint.expo.ts +330 -0
- package/expo/copy-overwrite/eslint.slow.config.ts +86 -0
- package/expo/copy-overwrite/knip.json +132 -0
- package/expo/copy-overwrite/lighthouserc.js +27 -0
- package/expo/copy-overwrite/tsconfig.eslint.json +25 -0
- package/expo/create-only/lighthouserc-config.json +6 -1
- package/expo/merge/package.json +16 -3
- package/nestjs/copy-overwrite/.claude/skills/nestjs-rules/SKILL.md +1 -1
- package/{typescript → nestjs}/copy-overwrite/.github/k6/README.md +2 -2
- package/{typescript → nestjs}/copy-overwrite/.github/k6/examples/customer-deploy-integration.yml +3 -0
- package/{typescript → nestjs}/copy-overwrite/.github/k6/examples/data-driven-test.js +5 -0
- package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/load.js +6 -2
- package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/smoke.js +5 -0
- package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/soak.js +5 -0
- package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/spike.js +5 -0
- package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/stress.js +5 -0
- package/{typescript → nestjs}/copy-overwrite/.github/k6/scripts/api-test.js +5 -0
- package/{typescript → nestjs}/copy-overwrite/.github/k6/scripts/default-test.js +5 -0
- package/nestjs/copy-overwrite/.github/workflows/ci.yml +29 -0
- package/nestjs/copy-overwrite/.github/workflows/deploy.yml +291 -0
- package/{typescript → nestjs}/copy-overwrite/.github/workflows/load-test.yml +3 -0
- package/nestjs/copy-overwrite/eslint.config.ts +53 -0
- package/nestjs/copy-overwrite/eslint.nestjs.ts +178 -0
- package/nestjs/merge/package.json +11 -3
- package/package.json +34 -40
- package/typescript/copy-contents/.husky/pre-commit +1 -1
- package/typescript/copy-contents/.husky/pre-push +99 -118
- package/typescript/copy-overwrite/.claude/hooks/format-on-edit.sh +2 -0
- package/typescript/copy-overwrite/.claude/hooks/install_pkgs.sh +3 -11
- package/typescript/copy-overwrite/.claude/hooks/lint-on-edit.sh +2 -0
- package/typescript/copy-overwrite/.claude/hooks/sg-scan-on-edit.sh +68 -0
- package/typescript/copy-overwrite/.claude/settings.json +79 -0
- package/typescript/copy-overwrite/.claude/skills/jsdoc-best-practices/SKILL.md +44 -0
- package/typescript/copy-overwrite/.github/README.md +49 -1
- package/typescript/copy-overwrite/.github/dependabot.yml +3 -0
- package/typescript/copy-overwrite/.github/workflows/ci.yml +7 -29
- package/typescript/copy-overwrite/.github/workflows/claude.yml +3 -0
- package/typescript/copy-overwrite/.github/workflows/create-github-issue-on-failure.yml +6 -4
- package/typescript/copy-overwrite/.github/workflows/create-issue-on-failure.yml +176 -0
- package/typescript/copy-overwrite/.github/workflows/create-jira-issue-on-failure.yml +3 -1
- package/typescript/copy-overwrite/.github/workflows/create-sentry-issue-on-failure.yml +3 -1
- package/typescript/copy-overwrite/.github/workflows/lint-slow.yml +40 -0
- package/typescript/copy-overwrite/.github/workflows/quality.yml +151 -38
- package/typescript/copy-overwrite/.github/workflows/release.yml +3 -0
- package/typescript/copy-overwrite/.gitleaksignore +3 -0
- package/typescript/copy-overwrite/.lintstagedrc.json +6 -0
- package/typescript/copy-overwrite/.prettierignore +2 -1
- package/typescript/copy-overwrite/.yamllint +2 -0
- package/typescript/copy-overwrite/ast-grep/rule-tests/.gitkeep +3 -0
- package/typescript/copy-overwrite/ast-grep/rules/.gitkeep +3 -0
- package/typescript/copy-overwrite/ast-grep/utils/.gitkeep +3 -0
- package/typescript/copy-overwrite/{commitlint.config.js → commitlint.config.cjs} +5 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/__tests__/enforce-statement-order.test.js +5 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/index.js +5 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/rules/enforce-statement-order.js +5 -0
- package/typescript/copy-overwrite/eslint.base.ts +430 -0
- package/typescript/copy-overwrite/eslint.config.ts +52 -0
- package/typescript/copy-overwrite/eslint.ignore.config.json +19 -2
- package/typescript/copy-overwrite/eslint.slow.config.ts +69 -0
- package/typescript/copy-overwrite/eslint.typescript.ts +142 -0
- package/typescript/copy-overwrite/knip.json +64 -0
- package/typescript/copy-overwrite/sgconfig.yml +11 -0
- package/typescript/copy-overwrite/tsconfig.eslint.json +9 -0
- package/typescript/create-only/eslint.config.local.ts +24 -0
- package/typescript/{copy-overwrite/eslint.thresholds.config.json → create-only/eslint.thresholds.json} +1 -1
- package/typescript/github-rulesets/base.json +2 -75
- package/typescript/merge/.claude/settings.json +160 -0
- package/typescript/merge/package.json +35 -34
- package/all/copy-overwrite/.claude/commands/rules/format-md.md +0 -72
- package/all/copy-overwrite/.claude/skills/coding-philosophy/references/function-structure.md +0 -416
- package/all/copy-overwrite/.claude/skills/coding-philosophy/references/immutable-patterns.md +0 -316
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-inline-styles.js +0 -73
- package/expo/copy-overwrite/eslint.config.mjs +0 -560
- package/lisa.sh +0 -35
- package/typescript/copy-overwrite/eslint.config.mjs +0 -390
- /package/{all/create-only/PROJECT_RULES.md → cdk/copy-overwrite/.github/workflows/.keep} +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/BROWSER_TESTING_NOTE.md +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/INTEGRATION_GUIDE.md +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/SCENARIO_SELECTION_GUIDE.md +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/load.json +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/smoke.json +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/soak.json +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/spike.json +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/scenarios/stress.json +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/thresholds/normal.json +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/thresholds/relaxed.json +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/k6/thresholds/strict.json +0 -0
- /package/{typescript → nestjs}/copy-overwrite/.github/workflows/k6-load-test-README.md +0 -0
|
@@ -2,18 +2,38 @@
|
|
|
2
2
|
* Silent logger that produces no output (for testing)
|
|
3
3
|
*/
|
|
4
4
|
export class SilentLogger {
|
|
5
|
+
/**
|
|
6
|
+
* Silently ignore info-level messages
|
|
7
|
+
* @param _message - Message to ignore
|
|
8
|
+
*/
|
|
5
9
|
info(_message) {
|
|
6
10
|
// Silent
|
|
7
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Silently ignore success-level messages
|
|
14
|
+
* @param _message - Message to ignore
|
|
15
|
+
*/
|
|
8
16
|
success(_message) {
|
|
9
17
|
// Silent
|
|
10
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Silently ignore warning-level messages
|
|
21
|
+
* @param _message - Message to ignore
|
|
22
|
+
*/
|
|
11
23
|
warn(_message) {
|
|
12
24
|
// Silent
|
|
13
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Silently ignore error-level messages
|
|
28
|
+
* @param _message - Message to ignore
|
|
29
|
+
*/
|
|
14
30
|
error(_message) {
|
|
15
31
|
// Silent
|
|
16
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Silently ignore dry-run-level messages
|
|
35
|
+
* @param _message - Message to ignore
|
|
36
|
+
*/
|
|
17
37
|
dry(_message) {
|
|
18
38
|
// Silent
|
|
19
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"silent-logger.js","sourceRoot":"","sources":["../../src/logging/silent-logger.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB,IAAI,CAAC,QAAgB;QACnB,SAAS;IACX,CAAC;IAED,OAAO,CAAC,QAAgB;QACtB,SAAS;IACX,CAAC;IAED,IAAI,CAAC,QAAgB;QACnB,SAAS;IACX,CAAC;IAED,KAAK,CAAC,QAAgB;QACpB,SAAS;IACX,CAAC;IAED,GAAG,CAAC,QAAgB;QAClB,SAAS;IACX,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"silent-logger.js","sourceRoot":"","sources":["../../src/logging/silent-logger.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB;;;OAGG;IACH,IAAI,CAAC,QAAgB;QACnB,SAAS;IACX,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,QAAgB;QACtB,SAAS;IACX,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,QAAgB;QACnB,SAAS;IACX,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAgB;QACpB,SAAS;IACX,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,QAAgB;QAClB,SAAS;IACX,CAAC;CACF"}
|
|
@@ -1,14 +1,55 @@
|
|
|
1
|
-
import type { FileOperationResult } from
|
|
2
|
-
import type { ICopyStrategy, StrategyContext } from
|
|
1
|
+
import type { FileOperationResult } from "../core/config.js";
|
|
2
|
+
import type { ICopyStrategy, StrategyContext } from "./strategy.interface.js";
|
|
3
3
|
/**
|
|
4
|
-
* Copy-contents strategy:
|
|
4
|
+
* Copy-contents strategy: Block-based merge for .gitignore-style files
|
|
5
5
|
* - Create new files silently
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
6
|
+
* - Replace content between "# BEGIN: AI GUARDRAILS" and "# END: AI GUARDRAILS" markers
|
|
7
|
+
* - If markers don't exist, append entire content to bottom
|
|
8
|
+
* - Preserves all custom user-added content outside the block
|
|
9
9
|
*/
|
|
10
10
|
export declare class CopyContentsStrategy implements ICopyStrategy {
|
|
11
11
|
readonly name: "copy-contents";
|
|
12
|
+
private readonly BEGIN_MARKER;
|
|
13
|
+
private readonly END_MARKER;
|
|
14
|
+
/**
|
|
15
|
+
* Find the guardrails block in content
|
|
16
|
+
* @param content File content to search
|
|
17
|
+
* @returns Object with start/end indices or null if not found
|
|
18
|
+
*/
|
|
19
|
+
private findGuardrailsBlock;
|
|
20
|
+
/**
|
|
21
|
+
* Merge source content with destination, replacing or appending guardrails block
|
|
22
|
+
* @param sourceContent Source file content
|
|
23
|
+
* @param destContent Destination file content
|
|
24
|
+
* @returns Merged content
|
|
25
|
+
*/
|
|
26
|
+
private mergeContent;
|
|
27
|
+
/**
|
|
28
|
+
* Handle the case where destination doesn't exist
|
|
29
|
+
* @param sourcePath Source file path
|
|
30
|
+
* @param destPath Destination file path
|
|
31
|
+
* @param relativePath Relative path
|
|
32
|
+
* @param context Strategy context
|
|
33
|
+
* @returns Result of copying the file
|
|
34
|
+
*/
|
|
35
|
+
private handleNewFile;
|
|
36
|
+
/**
|
|
37
|
+
* Handle merging content into existing file
|
|
38
|
+
* @param destPath Destination file path
|
|
39
|
+
* @param relativePath Relative path
|
|
40
|
+
* @param mergedContent The merged content
|
|
41
|
+
* @param context Strategy context
|
|
42
|
+
* @returns Result of the merge operation
|
|
43
|
+
*/
|
|
44
|
+
private handleMerge;
|
|
45
|
+
/**
|
|
46
|
+
* Apply copy-contents strategy: Create, replace block, or append to file
|
|
47
|
+
* @param sourcePath - Source file path
|
|
48
|
+
* @param destPath - Destination file path
|
|
49
|
+
* @param relativePath - Relative path for recording
|
|
50
|
+
* @param context - Strategy context with config and callbacks
|
|
51
|
+
* @returns Result of the copy-contents operation
|
|
52
|
+
*/
|
|
12
53
|
apply(sourcePath: string, destPath: string, relativePath: string, context: StrategyContext): Promise<FileOperationResult>;
|
|
13
54
|
}
|
|
14
55
|
//# sourceMappingURL=copy-contents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-contents.d.ts","sourceRoot":"","sources":["../../src/strategies/copy-contents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG9E;;;;;;GAMG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACxD,QAAQ,CAAC,IAAI,EAAG,eAAe,CAAU;
|
|
1
|
+
{"version":3,"file":"copy-contents.d.ts","sourceRoot":"","sources":["../../src/strategies/copy-contents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG9E;;;;;;GAMG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACxD,QAAQ,CAAC,IAAI,EAAG,eAAe,CAAU;IAEzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0B;IAErD;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAmB3B;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAiBpB;;;;;;;OAOG;YACW,aAAa;IAe3B;;;;;;;OAOG;YACW,WAAW;IAmBzB;;;;;;;OAOG;IACG,KAAK,CACT,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,mBAAmB,CAAC;CA4BhC"}
|
|
@@ -1,69 +1,119 @@
|
|
|
1
|
-
import * as fse from
|
|
2
|
-
import { readFile, copyFile,
|
|
3
|
-
import { filesIdentical, ensureParentDir } from
|
|
1
|
+
import * as fse from "fs-extra";
|
|
2
|
+
import { readFile, copyFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { filesIdentical, ensureParentDir } from "../utils/file-operations.js";
|
|
4
4
|
/**
|
|
5
|
-
* Copy-contents strategy:
|
|
5
|
+
* Copy-contents strategy: Block-based merge for .gitignore-style files
|
|
6
6
|
* - Create new files silently
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
7
|
+
* - Replace content between "# BEGIN: AI GUARDRAILS" and "# END: AI GUARDRAILS" markers
|
|
8
|
+
* - If markers don't exist, append entire content to bottom
|
|
9
|
+
* - Preserves all custom user-added content outside the block
|
|
10
10
|
*/
|
|
11
11
|
export class CopyContentsStrategy {
|
|
12
|
-
name =
|
|
13
|
-
|
|
12
|
+
name = "copy-contents";
|
|
13
|
+
BEGIN_MARKER = "# BEGIN: AI GUARDRAILS";
|
|
14
|
+
END_MARKER = "# END: AI GUARDRAILS";
|
|
15
|
+
/**
|
|
16
|
+
* Find the guardrails block in content
|
|
17
|
+
* @param content File content to search
|
|
18
|
+
* @returns Object with start/end indices or null if not found
|
|
19
|
+
*/
|
|
20
|
+
findGuardrailsBlock(content) {
|
|
21
|
+
const startIndex = content.indexOf(this.BEGIN_MARKER);
|
|
22
|
+
if (startIndex === -1) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const endIndex = content.indexOf(this.END_MARKER, startIndex + this.BEGIN_MARKER.length);
|
|
26
|
+
if (endIndex === -1) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return { start: startIndex, end: endIndex + this.END_MARKER.length };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Merge source content with destination, replacing or appending guardrails block
|
|
33
|
+
* @param sourceContent Source file content
|
|
34
|
+
* @param destContent Destination file content
|
|
35
|
+
* @returns Merged content
|
|
36
|
+
*/
|
|
37
|
+
mergeContent(sourceContent, destContent) {
|
|
38
|
+
const block = this.findGuardrailsBlock(destContent);
|
|
39
|
+
if (block) {
|
|
40
|
+
// Replace existing block
|
|
41
|
+
return (destContent.slice(0, block.start) +
|
|
42
|
+
sourceContent +
|
|
43
|
+
destContent.slice(block.end));
|
|
44
|
+
}
|
|
45
|
+
// Append if no block exists
|
|
46
|
+
const prefix = destContent.endsWith("\n") ? "\n" : "\n\n";
|
|
47
|
+
return destContent + prefix + sourceContent;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Handle the case where destination doesn't exist
|
|
51
|
+
* @param sourcePath Source file path
|
|
52
|
+
* @param destPath Destination file path
|
|
53
|
+
* @param relativePath Relative path
|
|
54
|
+
* @param context Strategy context
|
|
55
|
+
* @returns Result of copying the file
|
|
56
|
+
*/
|
|
57
|
+
async handleNewFile(sourcePath, destPath, relativePath, context) {
|
|
58
|
+
const { config, recordFile } = context;
|
|
59
|
+
if (!config.dryRun) {
|
|
60
|
+
await ensureParentDir(destPath);
|
|
61
|
+
await copyFile(sourcePath, destPath);
|
|
62
|
+
recordFile(relativePath, this.name);
|
|
63
|
+
}
|
|
64
|
+
return { relativePath, strategy: this.name, action: "copied" };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Handle merging content into existing file
|
|
68
|
+
* @param destPath Destination file path
|
|
69
|
+
* @param relativePath Relative path
|
|
70
|
+
* @param mergedContent The merged content
|
|
71
|
+
* @param context Strategy context
|
|
72
|
+
* @returns Result of the merge operation
|
|
73
|
+
*/
|
|
74
|
+
async handleMerge(destPath, relativePath, mergedContent, context) {
|
|
14
75
|
const { config, recordFile, backupFile } = context;
|
|
76
|
+
if (!config.dryRun) {
|
|
77
|
+
await backupFile(destPath);
|
|
78
|
+
await writeFile(destPath, mergedContent, "utf-8");
|
|
79
|
+
recordFile(relativePath, this.name);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
relativePath,
|
|
83
|
+
strategy: this.name,
|
|
84
|
+
action: "merged",
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Apply copy-contents strategy: Create, replace block, or append to file
|
|
89
|
+
* @param sourcePath - Source file path
|
|
90
|
+
* @param destPath - Destination file path
|
|
91
|
+
* @param relativePath - Relative path for recording
|
|
92
|
+
* @param context - Strategy context with config and callbacks
|
|
93
|
+
* @returns Result of the copy-contents operation
|
|
94
|
+
*/
|
|
95
|
+
async apply(sourcePath, destPath, relativePath, context) {
|
|
96
|
+
const { config, recordFile } = context;
|
|
15
97
|
const destExists = await fse.pathExists(destPath);
|
|
16
98
|
if (!destExists) {
|
|
17
|
-
|
|
18
|
-
if (!config.dryRun) {
|
|
19
|
-
await ensureParentDir(destPath);
|
|
20
|
-
await copyFile(sourcePath, destPath);
|
|
21
|
-
recordFile(relativePath, this.name);
|
|
22
|
-
}
|
|
23
|
-
return { relativePath, strategy: this.name, action: 'copied' };
|
|
99
|
+
return this.handleNewFile(sourcePath, destPath, relativePath, context);
|
|
24
100
|
}
|
|
25
|
-
// Check if files are identical
|
|
26
101
|
if (await filesIdentical(sourcePath, destPath)) {
|
|
27
102
|
if (!config.dryRun) {
|
|
28
103
|
recordFile(relativePath, this.name);
|
|
29
104
|
}
|
|
30
|
-
return { relativePath, strategy: this.name, action:
|
|
105
|
+
return { relativePath, strategy: this.name, action: "skipped" };
|
|
31
106
|
}
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const sourceLines = sourceContent
|
|
37
|
-
.split('\n')
|
|
38
|
-
.map((line) => line.trimEnd())
|
|
39
|
-
.filter((line) => line.length > 0);
|
|
40
|
-
// Get all lines from destination
|
|
41
|
-
const destLines = new Set(destContent.split('\n').map((line) => line.trimEnd()));
|
|
42
|
-
// Find lines that need to be added
|
|
43
|
-
const newLines = sourceLines.filter((line) => !destLines.has(line));
|
|
44
|
-
if (newLines.length === 0) {
|
|
107
|
+
const sourceContent = await readFile(sourcePath, "utf-8");
|
|
108
|
+
const destContent = await readFile(destPath, "utf-8");
|
|
109
|
+
const mergedContent = this.mergeContent(sourceContent, destContent);
|
|
110
|
+
if (mergedContent === destContent) {
|
|
45
111
|
if (!config.dryRun) {
|
|
46
112
|
recordFile(relativePath, this.name);
|
|
47
113
|
}
|
|
48
|
-
return { relativePath, strategy: this.name, action:
|
|
49
|
-
}
|
|
50
|
-
if (!config.dryRun) {
|
|
51
|
-
await backupFile(destPath);
|
|
52
|
-
// Ensure destination ends with newline before appending
|
|
53
|
-
let appendContent = newLines.join('\n');
|
|
54
|
-
if (!destContent.endsWith('\n')) {
|
|
55
|
-
appendContent = '\n' + appendContent;
|
|
56
|
-
}
|
|
57
|
-
appendContent += '\n';
|
|
58
|
-
await appendFile(destPath, appendContent, 'utf-8');
|
|
59
|
-
recordFile(relativePath, this.name);
|
|
114
|
+
return { relativePath, strategy: this.name, action: "skipped" };
|
|
60
115
|
}
|
|
61
|
-
return
|
|
62
|
-
relativePath,
|
|
63
|
-
strategy: this.name,
|
|
64
|
-
action: 'appended',
|
|
65
|
-
linesAdded: newLines.length,
|
|
66
|
-
};
|
|
116
|
+
return this.handleMerge(destPath, relativePath, mergedContent, context);
|
|
67
117
|
}
|
|
68
118
|
}
|
|
69
119
|
//# sourceMappingURL=copy-contents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-contents.js","sourceRoot":"","sources":["../../src/strategies/copy-contents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"copy-contents.js","sourceRoot":"","sources":["../../src/strategies/copy-contents.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1
|
-
import type { FileOperationResult } from
|
|
2
|
-
import type { ICopyStrategy, StrategyContext } from
|
|
1
|
+
import type { FileOperationResult } from "../core/config.js";
|
|
2
|
+
import type { ICopyStrategy, StrategyContext } from "./strategy.interface.js";
|
|
3
3
|
/**
|
|
4
4
|
* Copy-overwrite strategy: Replace file if exists (prompts on conflict)
|
|
5
5
|
* - Create new files silently
|
|
@@ -9,6 +9,14 @@ import type { ICopyStrategy, StrategyContext } from './strategy.interface.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class CopyOverwriteStrategy implements ICopyStrategy {
|
|
11
11
|
readonly name: "copy-overwrite";
|
|
12
|
+
/**
|
|
13
|
+
* Apply copy-overwrite strategy: Create, skip, or prompt to overwrite file
|
|
14
|
+
* @param sourcePath - Source file path
|
|
15
|
+
* @param destPath - Destination file path
|
|
16
|
+
* @param relativePath - Relative path for recording
|
|
17
|
+
* @param context - Strategy context with config and callbacks
|
|
18
|
+
* @returns Result of the copy-overwrite operation
|
|
19
|
+
*/
|
|
12
20
|
apply(sourcePath: string, destPath: string, relativePath: string, context: StrategyContext): Promise<FileOperationResult>;
|
|
13
21
|
}
|
|
14
22
|
//# sourceMappingURL=copy-overwrite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-overwrite.d.ts","sourceRoot":"","sources":["../../src/strategies/copy-overwrite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG9E;;;;;;GAMG;AACH,qBAAa,qBAAsB,YAAW,aAAa;IACzD,QAAQ,CAAC,IAAI,EAAG,gBAAgB,CAAU;
|
|
1
|
+
{"version":3,"file":"copy-overwrite.d.ts","sourceRoot":"","sources":["../../src/strategies/copy-overwrite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG9E;;;;;;GAMG;AACH,qBAAa,qBAAsB,YAAW,aAAa;IACzD,QAAQ,CAAC,IAAI,EAAG,gBAAgB,CAAU;IAE1C;;;;;;;OAOG;IACG,KAAK,CACT,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,mBAAmB,CAAC;CA2ChC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fse from
|
|
2
|
-
import { copyFile } from
|
|
3
|
-
import { filesIdentical, ensureParentDir } from
|
|
1
|
+
import * as fse from "fs-extra";
|
|
2
|
+
import { copyFile } from "node:fs/promises";
|
|
3
|
+
import { filesIdentical, ensureParentDir } from "../utils/file-operations.js";
|
|
4
4
|
/**
|
|
5
5
|
* Copy-overwrite strategy: Replace file if exists (prompts on conflict)
|
|
6
6
|
* - Create new files silently
|
|
@@ -9,7 +9,15 @@ import { filesIdentical, ensureParentDir } from '../utils/file-operations.js';
|
|
|
9
9
|
* - Backup before overwriting
|
|
10
10
|
*/
|
|
11
11
|
export class CopyOverwriteStrategy {
|
|
12
|
-
name =
|
|
12
|
+
name = "copy-overwrite";
|
|
13
|
+
/**
|
|
14
|
+
* Apply copy-overwrite strategy: Create, skip, or prompt to overwrite file
|
|
15
|
+
* @param sourcePath - Source file path
|
|
16
|
+
* @param destPath - Destination file path
|
|
17
|
+
* @param relativePath - Relative path for recording
|
|
18
|
+
* @param context - Strategy context with config and callbacks
|
|
19
|
+
* @returns Result of the copy-overwrite operation
|
|
20
|
+
*/
|
|
13
21
|
async apply(sourcePath, destPath, relativePath, context) {
|
|
14
22
|
const { config, recordFile, backupFile, promptOverwrite } = context;
|
|
15
23
|
const destExists = await fse.pathExists(destPath);
|
|
@@ -20,7 +28,7 @@ export class CopyOverwriteStrategy {
|
|
|
20
28
|
await copyFile(sourcePath, destPath);
|
|
21
29
|
recordFile(relativePath, this.name);
|
|
22
30
|
}
|
|
23
|
-
return { relativePath, strategy: this.name, action:
|
|
31
|
+
return { relativePath, strategy: this.name, action: "copied" };
|
|
24
32
|
}
|
|
25
33
|
// Check if files are identical
|
|
26
34
|
if (await filesIdentical(sourcePath, destPath)) {
|
|
@@ -28,20 +36,20 @@ export class CopyOverwriteStrategy {
|
|
|
28
36
|
if (!config.dryRun) {
|
|
29
37
|
recordFile(relativePath, this.name);
|
|
30
38
|
}
|
|
31
|
-
return { relativePath, strategy: this.name, action:
|
|
39
|
+
return { relativePath, strategy: this.name, action: "skipped" };
|
|
32
40
|
}
|
|
33
41
|
// Files differ - need to prompt or auto-accept
|
|
34
42
|
if (config.dryRun) {
|
|
35
|
-
return { relativePath, strategy: this.name, action:
|
|
43
|
+
return { relativePath, strategy: this.name, action: "overwritten" };
|
|
36
44
|
}
|
|
37
45
|
const shouldOverwrite = await promptOverwrite(relativePath, sourcePath, destPath);
|
|
38
46
|
if (shouldOverwrite) {
|
|
39
47
|
await backupFile(destPath);
|
|
40
48
|
await copyFile(sourcePath, destPath);
|
|
41
49
|
recordFile(relativePath, this.name);
|
|
42
|
-
return { relativePath, strategy: this.name, action:
|
|
50
|
+
return { relativePath, strategy: this.name, action: "overwritten" };
|
|
43
51
|
}
|
|
44
|
-
return { relativePath, strategy: this.name, action:
|
|
52
|
+
return { relativePath, strategy: this.name, action: "skipped" };
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
//# sourceMappingURL=copy-overwrite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-overwrite.js","sourceRoot":"","sources":["../../src/strategies/copy-overwrite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,eAAe,EA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AQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAClE,CAAC;QAED,+CAA+C;QAC/C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACtE,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,eAAe,CAC3C,YAAY,EACZ,UAAU,EACV,QAAQ,CACT,CAAC;QAEF,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC3B,MAAM,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACrC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACpC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACtE,CAAC;QAED,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FileOperationResult } from
|
|
2
|
-
import type { ICopyStrategy, StrategyContext } from
|
|
1
|
+
import type { FileOperationResult } from "../core/config.js";
|
|
2
|
+
import type { ICopyStrategy, StrategyContext } from "./strategy.interface.js";
|
|
3
3
|
/**
|
|
4
4
|
* Create-only strategy: Create file if not exists, never update
|
|
5
5
|
* - Create if not exists
|
|
@@ -8,6 +8,14 @@ import type { ICopyStrategy, StrategyContext } from './strategy.interface.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class CreateOnlyStrategy implements ICopyStrategy {
|
|
10
10
|
readonly name: "create-only";
|
|
11
|
+
/**
|
|
12
|
+
* Apply create-only strategy: Create file if not exists, never update
|
|
13
|
+
* @param sourcePath - Source file path
|
|
14
|
+
* @param destPath - Destination file path
|
|
15
|
+
* @param relativePath - Relative path for recording
|
|
16
|
+
* @param context - Strategy context with config and callbacks
|
|
17
|
+
* @returns Result of the create-only operation
|
|
18
|
+
*/
|
|
11
19
|
apply(sourcePath: string, destPath: string, relativePath: string, context: StrategyContext): Promise<FileOperationResult>;
|
|
12
20
|
}
|
|
13
21
|
//# sourceMappingURL=create-only.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-only.d.ts","sourceRoot":"","sources":["../../src/strategies/create-only.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG9E;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IACtD,QAAQ,CAAC,IAAI,EAAG,aAAa,CAAU;
|
|
1
|
+
{"version":3,"file":"create-only.d.ts","sourceRoot":"","sources":["../../src/strategies/create-only.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG9E;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IACtD,QAAQ,CAAC,IAAI,EAAG,aAAa,CAAU;IAEvC;;;;;;;OAOG;IACG,KAAK,CACT,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,mBAAmB,CAAC;CAmBhC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fse from
|
|
2
|
-
import { copyFile } from
|
|
3
|
-
import { ensureParentDir } from
|
|
1
|
+
import * as fse from "fs-extra";
|
|
2
|
+
import { copyFile } from "node:fs/promises";
|
|
3
|
+
import { ensureParentDir } from "../utils/file-operations.js";
|
|
4
4
|
/**
|
|
5
5
|
* Create-only strategy: Create file if not exists, never update
|
|
6
6
|
* - Create if not exists
|
|
@@ -8,7 +8,15 @@ import { ensureParentDir } from '../utils/file-operations.js';
|
|
|
8
8
|
* - Record in manifest even when skipping
|
|
9
9
|
*/
|
|
10
10
|
export class CreateOnlyStrategy {
|
|
11
|
-
name =
|
|
11
|
+
name = "create-only";
|
|
12
|
+
/**
|
|
13
|
+
* Apply create-only strategy: Create file if not exists, never update
|
|
14
|
+
* @param sourcePath - Source file path
|
|
15
|
+
* @param destPath - Destination file path
|
|
16
|
+
* @param relativePath - Relative path for recording
|
|
17
|
+
* @param context - Strategy context with config and callbacks
|
|
18
|
+
* @returns Result of the create-only operation
|
|
19
|
+
*/
|
|
12
20
|
async apply(sourcePath, destPath, relativePath, context) {
|
|
13
21
|
const { config, recordFile } = context;
|
|
14
22
|
const destExists = await fse.pathExists(destPath);
|
|
@@ -19,12 +27,12 @@ export class CreateOnlyStrategy {
|
|
|
19
27
|
await copyFile(sourcePath, destPath);
|
|
20
28
|
recordFile(relativePath, this.name);
|
|
21
29
|
}
|
|
22
|
-
return { relativePath, strategy: this.name, action:
|
|
30
|
+
return { relativePath, strategy: this.name, action: "created" };
|
|
23
31
|
}
|
|
24
32
|
// Destination exists - skip silently (but still track for potential uninstall)
|
|
25
33
|
// Note: We don't record to manifest when skipping in create-only mode
|
|
26
34
|
// because the user's file takes precedence
|
|
27
|
-
return { relativePath, strategy: this.name, action:
|
|
35
|
+
return { relativePath, strategy: this.name, action: "skipped" };
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
//# sourceMappingURL=create-only.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-only.js","sourceRoot":"","sources":["../../src/strategies/create-only.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAk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,CACT,UAAkB,EAClB,QAAgB,EAChB,YAAoB,EACpB,OAAwB;QAExB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QACvC,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAElD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,4CAA4C;YAC5C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;gBAChC,MAAM,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;gBACrC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAClE,CAAC;QAED,+EAA+E;QAC/E,sEAAsE;QACtE,2CAA2C;QAC3C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -1,31 +1,41 @@
|
|
|
1
|
-
import type { CopyStrategy } from
|
|
2
|
-
import type { ICopyStrategy } from
|
|
3
|
-
export type { ICopyStrategy, StrategyContext } from
|
|
4
|
-
export { CopyOverwriteStrategy } from
|
|
5
|
-
export { CopyContentsStrategy } from
|
|
6
|
-
export { CreateOnlyStrategy } from
|
|
7
|
-
export { MergeStrategy } from
|
|
1
|
+
import type { CopyStrategy } from "../core/config.js";
|
|
2
|
+
import type { ICopyStrategy } from "./strategy.interface.js";
|
|
3
|
+
export type { ICopyStrategy, StrategyContext } from "./strategy.interface.js";
|
|
4
|
+
export { CopyOverwriteStrategy } from "./copy-overwrite.js";
|
|
5
|
+
export { CopyContentsStrategy } from "./copy-contents.js";
|
|
6
|
+
export { CreateOnlyStrategy } from "./create-only.js";
|
|
7
|
+
export { MergeStrategy } from "./merge.js";
|
|
8
8
|
/**
|
|
9
9
|
* Registry for copy strategies
|
|
10
10
|
*/
|
|
11
11
|
export declare class StrategyRegistry {
|
|
12
12
|
private readonly strategies;
|
|
13
|
+
/**
|
|
14
|
+
* Initialize strategy registry with provided or default strategies
|
|
15
|
+
* @param strategies - Optional array of strategies (uses defaults if omitted)
|
|
16
|
+
*/
|
|
13
17
|
constructor(strategies?: readonly ICopyStrategy[]);
|
|
14
18
|
/**
|
|
15
19
|
* Get a strategy by name
|
|
20
|
+
* @param name - Name of the strategy to retrieve
|
|
21
|
+
* @returns The strategy instance with the given name
|
|
16
22
|
*/
|
|
17
23
|
get(name: CopyStrategy): ICopyStrategy;
|
|
18
24
|
/**
|
|
19
25
|
* Check if a strategy exists
|
|
26
|
+
* @param name - Name of the strategy to check
|
|
27
|
+
* @returns True if the strategy is registered
|
|
20
28
|
*/
|
|
21
29
|
has(name: CopyStrategy): boolean;
|
|
22
30
|
/**
|
|
23
31
|
* Get all registered strategies
|
|
32
|
+
* @returns Array of all strategy instances
|
|
24
33
|
*/
|
|
25
34
|
getAll(): readonly ICopyStrategy[];
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
37
|
* Create default strategy registry
|
|
38
|
+
* @returns New StrategyRegistry instance with all default strategies
|
|
29
39
|
*/
|
|
30
40
|
export declare function createStrategyRegistry(): StrategyRegistry;
|
|
31
41
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/strategies/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAM7D,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/strategies/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAM7D,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAE9D;;;OAGG;gBACS,UAAU,CAAC,EAAE,SAAS,aAAa,EAAE;IAWjD;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,aAAa;IAQtC;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;IAIhC;;;OAGG;IACH,MAAM,IAAI,SAAS,aAAa,EAAE;CAGnC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD"}
|
package/dist/strategies/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { CopyOverwriteStrategy } from
|
|
2
|
-
import { CopyContentsStrategy } from
|
|
3
|
-
import { CreateOnlyStrategy } from
|
|
4
|
-
import { MergeStrategy } from
|
|
5
|
-
export { CopyOverwriteStrategy } from
|
|
6
|
-
export { CopyContentsStrategy } from
|
|
7
|
-
export { CreateOnlyStrategy } from
|
|
8
|
-
export { MergeStrategy } from
|
|
1
|
+
import { CopyOverwriteStrategy } from "./copy-overwrite.js";
|
|
2
|
+
import { CopyContentsStrategy } from "./copy-contents.js";
|
|
3
|
+
import { CreateOnlyStrategy } from "./create-only.js";
|
|
4
|
+
import { MergeStrategy } from "./merge.js";
|
|
5
|
+
export { CopyOverwriteStrategy } from "./copy-overwrite.js";
|
|
6
|
+
export { CopyContentsStrategy } from "./copy-contents.js";
|
|
7
|
+
export { CreateOnlyStrategy } from "./create-only.js";
|
|
8
|
+
export { MergeStrategy } from "./merge.js";
|
|
9
9
|
/**
|
|
10
10
|
* Registry for copy strategies
|
|
11
11
|
*/
|
|
12
12
|
export class StrategyRegistry {
|
|
13
13
|
strategies;
|
|
14
|
+
/**
|
|
15
|
+
* Initialize strategy registry with provided or default strategies
|
|
16
|
+
* @param strategies - Optional array of strategies (uses defaults if omitted)
|
|
17
|
+
*/
|
|
14
18
|
constructor(strategies) {
|
|
15
19
|
const allStrategies = strategies ?? [
|
|
16
20
|
new CopyOverwriteStrategy(),
|
|
@@ -18,10 +22,12 @@ export class StrategyRegistry {
|
|
|
18
22
|
new CreateOnlyStrategy(),
|
|
19
23
|
new MergeStrategy(),
|
|
20
24
|
];
|
|
21
|
-
this.strategies = new Map(allStrategies.map(
|
|
25
|
+
this.strategies = new Map(allStrategies.map(s => [s.name, s]));
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
28
|
* Get a strategy by name
|
|
29
|
+
* @param name - Name of the strategy to retrieve
|
|
30
|
+
* @returns The strategy instance with the given name
|
|
25
31
|
*/
|
|
26
32
|
get(name) {
|
|
27
33
|
const strategy = this.strategies.get(name);
|
|
@@ -32,12 +38,15 @@ export class StrategyRegistry {
|
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
40
|
* Check if a strategy exists
|
|
41
|
+
* @param name - Name of the strategy to check
|
|
42
|
+
* @returns True if the strategy is registered
|
|
35
43
|
*/
|
|
36
44
|
has(name) {
|
|
37
45
|
return this.strategies.has(name);
|
|
38
46
|
}
|
|
39
47
|
/**
|
|
40
48
|
* Get all registered strategies
|
|
49
|
+
* @returns Array of all strategy instances
|
|
41
50
|
*/
|
|
42
51
|
getAll() {
|
|
43
52
|
return Array.from(this.strategies.values());
|
|
@@ -45,6 +54,7 @@ export class StrategyRegistry {
|
|
|
45
54
|
}
|
|
46
55
|
/**
|
|
47
56
|
* Create default strategy registry
|
|
57
|
+
* @returns New StrategyRegistry instance with all default strategies
|
|
48
58
|
*/
|
|
49
59
|
export function createStrategyRegistry() {
|
|
50
60
|
return new StrategyRegistry();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strategies/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACV,UAAU,CAAmC;IAE9D,YAAY,UAAqC;QAC/C,MAAM,aAAa,GAAG,UAAU,IAAI;YAClC,IAAI,qBAAqB,EAAE;YAC3B,IAAI,oBAAoB,EAAE;YAC1B,IAAI,kBAAkB,EAAE;YACxB,IAAI,aAAa,EAAE;SACpB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