@tailor-platform/erp-kit 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +158 -62
- package/dist/cli.js +1010 -270
- package/package.json +11 -8
- package/schemas/module/command.yml +1 -0
- package/schemas/module/model.yml +14 -0
- package/schemas/module/query.yml +53 -0
- package/skills/{app-compose-1-requirement-analysis → erp-kit-app-1-requirements}/SKILL.md +2 -2
- package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/SKILL.md +3 -3
- package/skills/{app-compose-3-doc-review → erp-kit-app-3-doc-review}/SKILL.md +2 -2
- package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/SKILL.md +3 -3
- package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/SKILL.md +4 -4
- package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/SKILL.md +3 -3
- package/skills/{mock-scenario → erp-kit-mock-scenario}/SKILL.md +1 -1
- package/skills/{1-module-docs → erp-kit-module-1-docs}/SKILL.md +2 -2
- package/skills/{2-module-feature-breakdown → erp-kit-module-2-feature-breakdown}/SKILL.md +13 -9
- package/skills/erp-kit-module-2-feature-breakdown/references/naming.md +59 -0
- package/skills/{3-module-doc-review → erp-kit-module-3-doc-review}/SKILL.md +83 -25
- package/skills/erp-kit-module-4-tdd/SKILL.md +94 -0
- package/skills/erp-kit-module-4-tdd/references/cross-module-dependency.md +133 -0
- package/skills/{4-module-tdd-implementation → erp-kit-module-4-tdd}/references/db-relations.md +5 -1
- package/skills/{4-module-tdd-implementation → erp-kit-module-4-tdd}/references/exports.md +1 -1
- package/skills/erp-kit-module-4-tdd/references/generated-code.md +32 -0
- package/skills/{5-module-implementation-review → erp-kit-module-5-impl-review}/SKILL.md +46 -44
- package/skills/erp-kit-module-5-impl-review/references/commands.md +62 -0
- package/skills/erp-kit-module-5-impl-review/references/errors.md +10 -0
- package/skills/{5-module-implementation-review → erp-kit-module-5-impl-review}/references/testing.md +1 -1
- package/skills/erp-kit-module-shared/SKILL.md +16 -0
- package/skills/erp-kit-module-shared/references/commands.md +203 -0
- package/skills/erp-kit-module-shared/references/errors.md +35 -0
- package/skills/erp-kit-module-shared/references/queries.md +168 -0
- package/skills/erp-kit-module-shared/references/structure.md +36 -0
- package/skills/{3-module-doc-review → erp-kit-module-shared}/references/testing.md +4 -3
- package/skills/erp-kit-update/SKILL.md +64 -0
- package/src/cli.doc.test.ts +65 -0
- package/src/cli.ts +3 -117
- package/src/commands/app/index.ts +74 -0
- package/src/commands/check.test.ts +3 -2
- package/src/commands/check.ts +3 -2
- package/src/commands/index.ts +73 -0
- package/src/commands/init.test.ts +22 -5
- package/src/commands/init.ts +25 -16
- package/src/commands/license.ts +193 -0
- package/src/commands/mock/index.ts +2 -2
- package/src/commands/mock/start.ts +1 -1
- package/src/commands/mock/validate.test.ts +1 -1
- package/src/commands/module/generate.ts +35 -0
- package/src/commands/module/index.ts +87 -0
- package/src/commands/module/list.test.ts +57 -0
- package/src/commands/module/list.ts +64 -0
- package/src/commands/scaffold-templates.ts +65 -0
- package/src/commands/scaffold.test.ts +97 -2
- package/src/commands/scaffold.ts +24 -3
- package/src/commands/sync-check.test.ts +88 -1
- package/src/commands/sync-check.ts +41 -2
- package/src/generator/generate-code.test.ts +200 -0
- package/src/generator/generate-code.ts +260 -0
- package/src/generator/parse-command-doc.test.ts +159 -0
- package/src/generator/parse-command-doc.ts +116 -0
- package/src/integration.test.ts +6 -8
- package/src/module.ts +10 -9
- package/src/modules/item-management/README.md +38 -0
- package/src/modules/item-management/command/activateItem.generated.ts +6 -0
- package/src/modules/item-management/command/activateItem.test.ts +76 -0
- package/src/modules/item-management/command/activateItem.ts +42 -0
- package/src/modules/item-management/command/assignItemToTaxonomy.generated.ts +6 -0
- package/src/modules/item-management/command/assignItemToTaxonomy.test.ts +88 -0
- package/src/modules/item-management/command/assignItemToTaxonomy.ts +63 -0
- package/src/modules/item-management/command/createItem.generated.ts +6 -0
- package/src/modules/item-management/command/createItem.test.ts +152 -0
- package/src/modules/item-management/command/createItem.ts +72 -0
- package/src/modules/item-management/command/createTaxonomyNode.generated.ts +6 -0
- package/src/modules/item-management/command/createTaxonomyNode.test.ts +126 -0
- package/src/modules/item-management/command/createTaxonomyNode.ts +70 -0
- package/src/modules/item-management/command/deactivateItem.generated.ts +6 -0
- package/src/modules/item-management/command/deactivateItem.test.ts +76 -0
- package/src/modules/item-management/command/deactivateItem.ts +42 -0
- package/src/modules/item-management/command/deleteItem.generated.ts +6 -0
- package/src/modules/item-management/command/deleteItem.test.ts +61 -0
- package/src/modules/item-management/command/deleteItem.ts +38 -0
- package/src/modules/item-management/command/deleteTaxonomyNode.generated.ts +6 -0
- package/src/modules/item-management/command/deleteTaxonomyNode.test.ts +73 -0
- package/src/modules/item-management/command/deleteTaxonomyNode.ts +50 -0
- package/src/modules/item-management/command/moveTaxonomyNode.generated.ts +6 -0
- package/src/modules/item-management/command/moveTaxonomyNode.test.ts +136 -0
- package/src/modules/item-management/command/moveTaxonomyNode.ts +85 -0
- package/src/modules/item-management/command/reactivateItem.generated.ts +6 -0
- package/src/modules/item-management/command/reactivateItem.test.ts +76 -0
- package/src/modules/item-management/command/reactivateItem.ts +42 -0
- package/src/modules/item-management/command/removeItemFromTaxonomy.generated.ts +6 -0
- package/src/modules/item-management/command/removeItemFromTaxonomy.test.ts +43 -0
- package/src/modules/item-management/command/removeItemFromTaxonomy.ts +30 -0
- package/src/modules/item-management/command/updateItem.generated.ts +6 -0
- package/src/modules/item-management/command/updateItem.test.ts +178 -0
- package/src/modules/item-management/command/updateItem.ts +103 -0
- package/src/modules/item-management/command/updateTaxonomyNode.generated.ts +6 -0
- package/src/modules/item-management/command/updateTaxonomyNode.test.ts +88 -0
- package/src/modules/item-management/command/updateTaxonomyNode.ts +62 -0
- package/src/modules/item-management/db/item.ts +47 -0
- package/src/modules/item-management/db/itemTaxonomyAssignment.ts +49 -0
- package/src/modules/item-management/db/taxonomyNode.ts +34 -0
- package/src/modules/item-management/docs/commands/ActivateItem.md +32 -0
- package/src/modules/item-management/docs/commands/AssignItemToTaxonomy.md +38 -0
- package/src/modules/item-management/docs/commands/CreateItem.md +44 -0
- package/src/modules/item-management/docs/commands/CreateTaxonomyNode.md +44 -0
- package/src/modules/item-management/docs/commands/DeactivateItem.md +34 -0
- package/src/modules/item-management/docs/commands/DeleteItem.md +35 -0
- package/src/modules/item-management/docs/commands/DeleteTaxonomyNode.md +39 -0
- package/src/modules/item-management/docs/commands/MoveTaxonomyNode.md +45 -0
- package/src/modules/item-management/docs/commands/ReactivateItem.md +34 -0
- package/src/modules/item-management/docs/commands/RemoveItemFromTaxonomy.md +30 -0
- package/src/modules/item-management/docs/commands/UpdateItem.md +55 -0
- package/src/modules/item-management/docs/commands/UpdateTaxonomyNode.md +36 -0
- package/src/modules/item-management/docs/features/item-lifecycle.md +60 -0
- package/src/modules/item-management/docs/features/item-taxonomy.md +65 -0
- package/src/modules/item-management/docs/models/ItemTaxonomyAssignment.md +36 -0
- package/src/modules/item-management/docs/models/TaxonomyNode.md +47 -0
- package/src/modules/item-management/docs/models/item.md +59 -0
- package/src/modules/item-management/docs/queries/CalculateNodeDepth.md +36 -0
- package/src/modules/item-management/docs/queries/CalculateSubtreeDepth.md +40 -0
- package/src/modules/item-management/docs/queries/DetectCircularReference.md +41 -0
- package/src/modules/item-management/docs/queries/GetItem.md +38 -0
- package/src/modules/item-management/docs/queries/GetItemTaxonomyAssignment.md +29 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNode.md +35 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNodeAssignments.md +29 -0
- package/src/modules/item-management/docs/queries/GetTaxonomyNodeChildren.md +29 -0
- package/src/modules/item-management/generated/enums.ts +9 -0
- package/src/modules/item-management/generated/kysely-tailordb.ts +62 -0
- package/src/modules/item-management/index.ts +53 -0
- package/src/modules/item-management/lib/_db_deps.ts +13 -0
- package/src/modules/item-management/lib/errors.generated.ts +117 -0
- package/src/modules/item-management/lib/permissions.generated.ts +17 -0
- package/src/modules/item-management/lib/types.ts +19 -0
- package/src/modules/item-management/module.ts +97 -0
- package/src/modules/item-management/query/calculateNodeDepth.generated.ts +5 -0
- package/src/modules/item-management/query/calculateNodeDepth.test.ts +56 -0
- package/src/modules/item-management/query/calculateNodeDepth.ts +28 -0
- package/src/modules/item-management/query/calculateSubtreeDepth.generated.ts +5 -0
- package/src/modules/item-management/query/calculateSubtreeDepth.test.ts +75 -0
- package/src/modules/item-management/query/calculateSubtreeDepth.ts +29 -0
- package/src/modules/item-management/query/detectCircularReference.generated.ts +5 -0
- package/src/modules/item-management/query/detectCircularReference.test.ts +61 -0
- package/src/modules/item-management/query/detectCircularReference.ts +32 -0
- package/src/modules/item-management/query/getItem.generated.ts +5 -0
- package/src/modules/item-management/query/getItem.test.ts +67 -0
- package/src/modules/item-management/query/getItem.ts +20 -0
- package/src/modules/item-management/query/getItemTaxonomyAssignment.generated.ts +5 -0
- package/src/modules/item-management/query/getItemTaxonomyAssignment.test.ts +25 -0
- package/src/modules/item-management/query/getItemTaxonomyAssignment.ts +18 -0
- package/src/modules/item-management/query/getTaxonomyNode.generated.ts +5 -0
- package/src/modules/item-management/query/getTaxonomyNode.test.ts +47 -0
- package/src/modules/item-management/query/getTaxonomyNode.ts +18 -0
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.generated.ts +5 -0
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.test.ts +25 -0
- package/src/modules/item-management/query/getTaxonomyNodeAssignments.ts +16 -0
- package/src/modules/item-management/query/getTaxonomyNodeChildren.generated.ts +5 -0
- package/src/modules/item-management/query/getTaxonomyNodeChildren.test.ts +34 -0
- package/src/modules/item-management/query/getTaxonomyNodeChildren.ts +16 -0
- package/src/modules/item-management/tailor.config.ts +11 -0
- package/src/modules/item-management/testing/fixtures.ts +81 -0
- package/src/modules/primitives/command/activateCategory.generated.ts +6 -0
- package/src/modules/primitives/command/activateCategory.test.ts +11 -29
- package/src/modules/primitives/command/activateCategory.ts +27 -34
- package/src/modules/primitives/command/activateCurrency.generated.ts +6 -0
- package/src/modules/primitives/command/activateCurrency.test.ts +11 -29
- package/src/modules/primitives/command/activateCurrency.ts +27 -34
- package/src/modules/primitives/command/activateUnit.generated.ts +6 -0
- package/src/modules/primitives/command/activateUnit.test.ts +11 -15
- package/src/modules/primitives/command/activateUnit.ts +27 -34
- package/src/modules/primitives/command/createCategory.generated.ts +6 -0
- package/src/modules/primitives/command/createCategory.test.ts +27 -39
- package/src/modules/primitives/command/createCategory.ts +53 -62
- package/src/modules/primitives/command/createCurrency.generated.ts +6 -0
- package/src/modules/primitives/command/createCurrency.test.ts +78 -71
- package/src/modules/primitives/command/createCurrency.ts +43 -48
- package/src/modules/primitives/command/createExchangeRate.generated.ts +6 -0
- package/src/modules/primitives/command/createExchangeRate.test.ts +101 -100
- package/src/modules/primitives/command/createExchangeRate.ts +50 -59
- package/src/modules/primitives/command/createUnit.generated.ts +6 -0
- package/src/modules/primitives/command/createUnit.test.ts +92 -95
- package/src/modules/primitives/command/createUnit.ts +54 -57
- package/src/modules/primitives/command/deactivateCategory.generated.ts +6 -0
- package/src/modules/primitives/command/deactivateCategory.test.ts +27 -28
- package/src/modules/primitives/command/deactivateCategory.ts +43 -50
- package/src/modules/primitives/command/deactivateCurrency.generated.ts +6 -0
- package/src/modules/primitives/command/deactivateCurrency.test.ts +23 -38
- package/src/modules/primitives/command/deactivateCurrency.ts +31 -38
- package/src/modules/primitives/command/deactivateUnit.generated.ts +6 -0
- package/src/modules/primitives/command/deactivateUnit.test.ts +27 -23
- package/src/modules/primitives/command/deactivateUnit.ts +39 -49
- package/src/modules/primitives/command/setBaseCurrency.generated.ts +6 -0
- package/src/modules/primitives/command/setBaseCurrency.test.ts +40 -33
- package/src/modules/primitives/command/setBaseCurrency.ts +43 -50
- package/src/modules/primitives/command/setReferenceUnit.generated.ts +6 -0
- package/src/modules/primitives/command/setReferenceUnit.test.ts +39 -35
- package/src/modules/primitives/command/setReferenceUnit.ts +46 -59
- package/src/modules/primitives/db/unit.ts +13 -3
- package/src/modules/primitives/docs/commands/ActivateCategory.md +1 -2
- package/src/modules/primitives/docs/commands/ActivateCurrency.md +1 -2
- package/src/modules/primitives/docs/commands/ActivateUnit.md +1 -2
- package/src/modules/primitives/docs/commands/CreateCategory.md +1 -4
- package/src/modules/primitives/docs/commands/CreateCurrency.md +3 -4
- package/src/modules/primitives/docs/commands/CreateExchangeRate.md +4 -5
- package/src/modules/primitives/docs/commands/CreateUnit.md +5 -5
- package/src/modules/primitives/docs/commands/DeactivateCategory.md +2 -3
- package/src/modules/primitives/docs/commands/DeactivateCurrency.md +2 -3
- package/src/modules/primitives/docs/commands/DeactivateUnit.md +2 -3
- package/src/modules/primitives/docs/commands/SetBaseCurrency.md +2 -3
- package/src/modules/primitives/docs/commands/SetReferenceUnit.md +2 -3
- package/src/modules/primitives/docs/models/Currency.md +4 -0
- package/src/modules/primitives/docs/models/ExchangeRate.md +4 -1
- package/src/modules/primitives/docs/models/Unit.md +4 -1
- package/src/modules/primitives/docs/models/UoMCategory.md +2 -0
- package/src/modules/primitives/docs/{commands → queries}/ConvertAmount.md +3 -5
- package/src/modules/primitives/docs/{commands → queries}/ConvertQuantity.md +3 -5
- package/src/modules/primitives/docs/queries/GetBaseCurrency.md +32 -0
- package/src/modules/primitives/docs/queries/GetCurrency.md +36 -0
- package/src/modules/primitives/docs/queries/GetUnit.md +36 -0
- package/src/modules/primitives/docs/queries/GetUoMCategory.md +36 -0
- package/src/modules/primitives/docs/queries/ListUnitsByCategory.md +26 -0
- package/src/modules/primitives/generated/kysely-tailordb.ts +24 -45
- package/src/modules/primitives/index.ts +17 -6
- package/src/modules/primitives/lib/errors.generated.ts +112 -0
- package/src/modules/primitives/{permissions.ts → lib/permissions.generated.ts} +9 -10
- package/src/modules/primitives/module.ts +39 -27
- package/src/modules/primitives/query/convertAmount.generated.ts +5 -0
- package/src/modules/primitives/{command → query}/convertAmount.test.ts +4 -21
- package/src/modules/primitives/query/convertAmount.ts +121 -0
- package/src/modules/primitives/query/convertQuantity.generated.ts +5 -0
- package/src/modules/primitives/{command → query}/convertQuantity.test.ts +8 -15
- package/src/modules/primitives/query/convertQuantity.ts +63 -0
- package/src/modules/primitives/query/getBaseCurrency.generated.ts +5 -0
- package/src/modules/primitives/query/getBaseCurrency.test.ts +28 -0
- package/src/modules/primitives/query/getBaseCurrency.ts +16 -0
- package/src/modules/primitives/query/getCurrency.generated.ts +5 -0
- package/src/modules/primitives/query/getCurrency.test.ts +47 -0
- package/src/modules/primitives/query/getCurrency.ts +18 -0
- package/src/modules/primitives/query/getUnit.generated.ts +5 -0
- package/src/modules/primitives/query/getUnit.test.ts +47 -0
- package/src/modules/primitives/query/getUnit.ts +18 -0
- package/src/modules/primitives/query/getUoMCategory.generated.ts +5 -0
- package/src/modules/primitives/query/getUoMCategory.test.ts +47 -0
- package/src/modules/primitives/query/getUoMCategory.ts +18 -0
- package/src/modules/primitives/query/listUnitsByCategory.generated.ts +5 -0
- package/src/modules/primitives/query/listUnitsByCategory.ts +16 -0
- package/src/modules/primitives/tailor.config.ts +3 -3
- package/src/modules/shared/defineCommand.test.ts +23 -10
- package/src/modules/shared/defineCommand.ts +23 -10
- package/src/modules/shared/defineQuery.test.ts +28 -0
- package/src/modules/shared/defineQuery.ts +16 -0
- package/src/modules/shared/internal.ts +3 -1
- package/src/modules/shared/requirePermission.test.ts +22 -21
- package/src/modules/shared/requirePermission.ts +8 -2
- package/src/modules/shared/result.ts +12 -0
- package/src/modules/shared/types.ts +8 -0
- package/src/modules/testing/index.ts +36 -11
- package/src/modules/user-management/command/activateUser.generated.ts +6 -0
- package/src/modules/user-management/command/activateUser.test.ts +27 -27
- package/src/modules/user-management/command/activateUser.ts +40 -48
- package/src/modules/user-management/command/assignPermissionToRole.generated.ts +6 -0
- package/src/modules/user-management/command/assignPermissionToRole.test.ts +42 -43
- package/src/modules/user-management/command/assignPermissionToRole.ts +59 -62
- package/src/modules/user-management/command/assignRoleToUser.generated.ts +6 -0
- package/src/modules/user-management/command/assignRoleToUser.test.ts +70 -63
- package/src/modules/user-management/command/assignRoleToUser.ts +63 -66
- package/src/modules/user-management/command/createPermission.generated.ts +6 -0
- package/src/modules/user-management/command/createPermission.test.ts +45 -38
- package/src/modules/user-management/command/createPermission.ts +42 -46
- package/src/modules/user-management/command/createRole.generated.ts +6 -0
- package/src/modules/user-management/command/createRole.test.ts +30 -29
- package/src/modules/user-management/command/createRole.ts +33 -33
- package/src/modules/user-management/command/createUser.generated.ts +6 -0
- package/src/modules/user-management/command/createUser.test.ts +64 -42
- package/src/modules/user-management/command/createUser.ts +54 -56
- package/src/modules/user-management/command/deactivateUser.generated.ts +6 -0
- package/src/modules/user-management/command/deactivateUser.test.ts +27 -27
- package/src/modules/user-management/command/deactivateUser.ts +40 -48
- package/src/modules/user-management/command/logAuditEvent.generated.ts +6 -0
- package/src/modules/user-management/command/logAuditEvent.test.ts +50 -42
- package/src/modules/user-management/command/logAuditEvent.ts +25 -28
- package/src/modules/user-management/command/reactivateUser.generated.ts +6 -0
- package/src/modules/user-management/command/reactivateUser.test.ts +31 -27
- package/src/modules/user-management/command/reactivateUser.ts +40 -48
- package/src/modules/user-management/command/revokePermissionFromRole.generated.ts +6 -0
- package/src/modules/user-management/command/revokePermissionFromRole.test.ts +52 -51
- package/src/modules/user-management/command/revokePermissionFromRole.ts +60 -57
- package/src/modules/user-management/command/revokeRoleFromUser.generated.ts +6 -0
- package/src/modules/user-management/command/revokeRoleFromUser.test.ts +53 -48
- package/src/modules/user-management/command/revokeRoleFromUser.ts +58 -57
- package/src/modules/user-management/docs/commands/CreatePermission.md +2 -2
- package/src/modules/user-management/docs/commands/CreateRole.md +1 -1
- package/src/modules/user-management/docs/models/AuditEvent.md +2 -0
- package/src/modules/user-management/docs/models/Permission.md +2 -0
- package/src/modules/user-management/docs/models/Role.md +2 -0
- package/src/modules/user-management/docs/models/RolePermission.md +2 -0
- package/src/modules/user-management/docs/models/User.md +2 -0
- package/src/modules/user-management/docs/models/UserRole.md +2 -0
- package/src/modules/user-management/generated/enums.ts +11 -11
- package/src/modules/user-management/generated/kysely-tailordb.ts +27 -56
- package/src/modules/user-management/index.ts +2 -2
- package/src/modules/user-management/lib/errors.generated.ts +67 -0
- package/src/modules/user-management/{permissions.ts → lib/permissions.generated.ts} +8 -7
- package/src/modules/user-management/module.ts +22 -22
- package/src/modules/user-management/tailor.config.ts +3 -3
- package/src/schemas.ts +2 -1
- package/skills/1-module-docs/references/structure.md +0 -22
- package/skills/2-module-feature-breakdown/references/commands.md +0 -48
- package/skills/2-module-feature-breakdown/references/structure.md +0 -22
- package/skills/3-module-doc-review/references/commands.md +0 -54
- package/skills/3-module-doc-review/references/models.md +0 -29
- package/skills/4-module-tdd-implementation/SKILL.md +0 -74
- package/skills/4-module-tdd-implementation/references/commands.md +0 -45
- package/skills/4-module-tdd-implementation/references/errors.md +0 -7
- package/skills/4-module-tdd-implementation/references/models.md +0 -30
- package/skills/4-module-tdd-implementation/references/structure.md +0 -22
- package/skills/4-module-tdd-implementation/references/testing.md +0 -37
- package/skills/5-module-implementation-review/references/commands.md +0 -45
- package/skills/5-module-implementation-review/references/errors.md +0 -7
- package/skills/5-module-implementation-review/references/exports.md +0 -8
- package/skills/5-module-implementation-review/references/models.md +0 -30
- package/src/modules/primitives/command/convertAmount.ts +0 -126
- package/src/modules/primitives/command/convertQuantity.ts +0 -73
- package/src/modules/primitives/lib/errors.ts +0 -138
- package/src/modules/user-management/lib/errors.ts +0 -81
- /package/skills/{app-compose-1-requirement-analysis → erp-kit-app-1-requirements}/references/structure.md +0 -0
- /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-detailview.md +0 -0
- /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-form.md +0 -0
- /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/screen-listview.md +0 -0
- /package/skills/{app-compose-2-requirements-breakdown → erp-kit-app-2-breakdown}/references/structure.md +0 -0
- /package/skills/{app-compose-3-doc-review → erp-kit-app-3-doc-review}/references/structure.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/component.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-detailview.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-form.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/screen-listview.md +0 -0
- /package/skills/{app-compose-4-design-mock → erp-kit-app-4-design}/references/structure.md +0 -0
- /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/component.md +0 -0
- /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-detailview.md +0 -0
- /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-form.md +0 -0
- /package/skills/{app-compose-5-design-mock-review → erp-kit-app-5-design-review}/references/screen-listview.md +0 -0
- /package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/references/auth.md +0 -0
- /package/skills/{app-compose-6-implementation-spec → erp-kit-app-6-impl-spec}/references/structure.md +0 -0
- /package/skills/{2-module-feature-breakdown → erp-kit-module-4-tdd}/references/models.md +0 -0
package/src/cli.ts
CHANGED
|
@@ -1,120 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { runCheck } from "./commands/check.js";
|
|
6
|
-
import { runSyncCheck, formatSyncCheckReport } from "./commands/sync-check.js";
|
|
7
|
-
import { runScaffold, ALL_TYPES, isModuleType, type ScaffoldType } from "./commands/scaffold.js";
|
|
8
|
-
import { runInit } from "./commands/init.js";
|
|
9
|
-
import { mockCommand } from "./commands/mock/index.js";
|
|
3
|
+
import { runMain } from "politty";
|
|
4
|
+
import { mainCommand } from "./commands/index";
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const rootArgs = z.object({
|
|
14
|
-
modulesRoot: arg(z.string().optional(), {
|
|
15
|
-
alias: "m",
|
|
16
|
-
description: "Path to modules directory",
|
|
17
|
-
}),
|
|
18
|
-
appRoot: arg(z.string().optional(), {
|
|
19
|
-
alias: "a",
|
|
20
|
-
description: "Path to app-compose directory (apps/ or examples/)",
|
|
21
|
-
}),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
function requireRoot(args: { modulesRoot?: string; appRoot?: string }) {
|
|
25
|
-
const paths = { modulesRoot: args.modulesRoot, appRoot: args.appRoot };
|
|
26
|
-
if (!paths.modulesRoot && !paths.appRoot) {
|
|
27
|
-
console.error("At least one of --modules-root or --app-root is required.");
|
|
28
|
-
process.exit(2);
|
|
29
|
-
}
|
|
30
|
-
return paths;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const checkCommand = defineCommand({
|
|
34
|
-
name: "check",
|
|
35
|
-
description: "Validate docs against schemas",
|
|
36
|
-
args: rootArgs,
|
|
37
|
-
run: async (args) => {
|
|
38
|
-
const paths = requireRoot(args);
|
|
39
|
-
const exitCode = await runCheck(paths, cwd);
|
|
40
|
-
process.exit(exitCode);
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const syncCheckCommand = defineCommand({
|
|
45
|
-
name: "sync-check",
|
|
46
|
-
description: "Validate source <-> doc correspondence",
|
|
47
|
-
args: rootArgs,
|
|
48
|
-
run: async (args) => {
|
|
49
|
-
const paths = requireRoot(args);
|
|
50
|
-
const result = await runSyncCheck(paths, cwd);
|
|
51
|
-
console.log(formatSyncCheckReport(result));
|
|
52
|
-
process.exit(result.exitCode);
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const scaffoldCommand = defineCommand({
|
|
57
|
-
name: "scaffold",
|
|
58
|
-
description: "Generate doc file from schema template",
|
|
59
|
-
args: rootArgs.extend({
|
|
60
|
-
type: arg(z.enum(ALL_TYPES as unknown as [string, ...string[]]), {
|
|
61
|
-
positional: true,
|
|
62
|
-
description: `Scaffold type (${ALL_TYPES.join(", ")})`,
|
|
63
|
-
}),
|
|
64
|
-
parent: arg(z.string(), {
|
|
65
|
-
positional: true,
|
|
66
|
-
description: "Parent name (module or app name)",
|
|
67
|
-
}),
|
|
68
|
-
name: arg(z.string().optional(), {
|
|
69
|
-
positional: true,
|
|
70
|
-
description: "Item name (required for most types)",
|
|
71
|
-
}),
|
|
72
|
-
}),
|
|
73
|
-
run: async (args) => {
|
|
74
|
-
const paths = requireRoot(args);
|
|
75
|
-
const root = isModuleType(args.type) ? paths.modulesRoot : paths.appRoot;
|
|
76
|
-
if (!root) {
|
|
77
|
-
console.error(
|
|
78
|
-
`--${isModuleType(args.type) ? "modules-root" : "app-root"} is required for scaffold type "${args.type}".`,
|
|
79
|
-
);
|
|
80
|
-
process.exit(2);
|
|
81
|
-
}
|
|
82
|
-
const exitCode = await runScaffold(
|
|
83
|
-
args.type as ScaffoldType,
|
|
84
|
-
args.parent,
|
|
85
|
-
args.name,
|
|
86
|
-
root,
|
|
87
|
-
cwd,
|
|
88
|
-
);
|
|
89
|
-
process.exit(exitCode);
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const initCommand = defineCommand({
|
|
94
|
-
name: "init",
|
|
95
|
-
description: "Set up consumer repo with framework skills",
|
|
96
|
-
args: z.object({
|
|
97
|
-
force: arg(z.boolean().default(false), {
|
|
98
|
-
alias: "f",
|
|
99
|
-
description: "Overwrite existing skills",
|
|
100
|
-
}),
|
|
101
|
-
}),
|
|
102
|
-
run: (args) => {
|
|
103
|
-
const exitCode = runInit(cwd, args.force);
|
|
104
|
-
process.exit(exitCode);
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const main = defineCommand({
|
|
109
|
-
name: "erp-kit",
|
|
110
|
-
description: "Documentation validation and scaffolding tool",
|
|
111
|
-
subCommands: {
|
|
112
|
-
check: checkCommand,
|
|
113
|
-
"sync-check": syncCheckCommand,
|
|
114
|
-
scaffold: scaffoldCommand,
|
|
115
|
-
init: initCommand,
|
|
116
|
-
mock: mockCommand,
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
void runMain(main);
|
|
6
|
+
void runMain(mainCommand);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineCommand, arg } from "politty";
|
|
3
|
+
import { runCheck } from "../check";
|
|
4
|
+
import { runSyncCheck, formatSyncCheckReport } from "../sync-check";
|
|
5
|
+
import { runScaffold, APP_TYPES, type ScaffoldType } from "../scaffold";
|
|
6
|
+
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
|
|
9
|
+
const rootArgs = z.object({
|
|
10
|
+
root: arg(z.string(), {
|
|
11
|
+
alias: "r",
|
|
12
|
+
description: "Path to app-compose directory",
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const checkCommand = defineCommand({
|
|
17
|
+
name: "check",
|
|
18
|
+
description: "Validate app docs against schemas",
|
|
19
|
+
args: rootArgs,
|
|
20
|
+
run: async (args) => {
|
|
21
|
+
const exitCode = await runCheck({ appRoot: args.root }, cwd);
|
|
22
|
+
process.exit(exitCode);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const syncCheckCommand = defineCommand({
|
|
27
|
+
name: "sync-check",
|
|
28
|
+
description: "Validate source <-> doc correspondence",
|
|
29
|
+
args: rootArgs,
|
|
30
|
+
run: async (args) => {
|
|
31
|
+
const result = await runSyncCheck({ appRoot: args.root }, cwd);
|
|
32
|
+
console.log(formatSyncCheckReport(result));
|
|
33
|
+
process.exit(result.exitCode);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const scaffoldCommand = defineCommand({
|
|
38
|
+
name: "scaffold",
|
|
39
|
+
description: "Generate app doc from schema template",
|
|
40
|
+
args: rootArgs.extend({
|
|
41
|
+
type: arg(z.enum(APP_TYPES as unknown as [string, ...string[]]), {
|
|
42
|
+
positional: true,
|
|
43
|
+
description: `Scaffold type (${APP_TYPES.join(", ")})`,
|
|
44
|
+
}),
|
|
45
|
+
parent: arg(z.string(), {
|
|
46
|
+
positional: true,
|
|
47
|
+
description: "App name",
|
|
48
|
+
}),
|
|
49
|
+
name: arg(z.string().optional(), {
|
|
50
|
+
positional: true,
|
|
51
|
+
description: "Item name (required for most types)",
|
|
52
|
+
}),
|
|
53
|
+
}),
|
|
54
|
+
run: async (args) => {
|
|
55
|
+
const exitCode = await runScaffold(
|
|
56
|
+
args.type as ScaffoldType,
|
|
57
|
+
args.parent,
|
|
58
|
+
args.name,
|
|
59
|
+
args.root,
|
|
60
|
+
cwd,
|
|
61
|
+
);
|
|
62
|
+
process.exit(exitCode);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const appCommand = defineCommand({
|
|
67
|
+
name: "app",
|
|
68
|
+
description: "App-compose management",
|
|
69
|
+
subCommands: {
|
|
70
|
+
check: checkCommand,
|
|
71
|
+
"sync-check": syncCheckCommand,
|
|
72
|
+
scaffold: scaffoldCommand,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { buildCheckTargets } from "./check
|
|
2
|
+
import { buildCheckTargets } from "./check";
|
|
3
3
|
|
|
4
4
|
describe("buildCheckTargets", () => {
|
|
5
5
|
it("generates module targets when modulesRoot is set", () => {
|
|
@@ -8,6 +8,7 @@ describe("buildCheckTargets", () => {
|
|
|
8
8
|
{ glob: "modules/[a-zA-Z]*/docs/features/*.md", schemaKey: "feature" },
|
|
9
9
|
{ glob: "modules/[a-zA-Z]*/docs/commands/*.md", schemaKey: "command" },
|
|
10
10
|
{ glob: "modules/[a-zA-Z]*/docs/models/*.md", schemaKey: "model" },
|
|
11
|
+
{ glob: "modules/[a-zA-Z]*/docs/queries/*.md", schemaKey: "query" },
|
|
11
12
|
{ glob: "modules/[a-zA-Z]*/README.md", schemaKey: "module" },
|
|
12
13
|
]);
|
|
13
14
|
});
|
|
@@ -20,7 +21,7 @@ describe("buildCheckTargets", () => {
|
|
|
20
21
|
|
|
21
22
|
it("generates both when both roots are set", () => {
|
|
22
23
|
const targets = buildCheckTargets({ modulesRoot: "modules", appRoot: "examples" });
|
|
23
|
-
expect(targets).toHaveLength(
|
|
24
|
+
expect(targets).toHaveLength(11);
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
it("returns empty when neither root is set", () => {
|
package/src/commands/check.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { runMdschema } from "../mdschema
|
|
2
|
-
import { ALL_SCHEMAS } from "../schemas
|
|
1
|
+
import { runMdschema } from "../mdschema";
|
|
2
|
+
import { ALL_SCHEMAS } from "../schemas";
|
|
3
3
|
export interface CheckTarget {
|
|
4
4
|
glob: string;
|
|
5
5
|
schemaKey: string;
|
|
@@ -17,6 +17,7 @@ export function buildCheckTargets(config: {
|
|
|
17
17
|
{ glob: `${m}/[a-zA-Z]*/docs/features/*.md`, schemaKey: "feature" },
|
|
18
18
|
{ glob: `${m}/[a-zA-Z]*/docs/commands/*.md`, schemaKey: "command" },
|
|
19
19
|
{ glob: `${m}/[a-zA-Z]*/docs/models/*.md`, schemaKey: "model" },
|
|
20
|
+
{ glob: `${m}/[a-zA-Z]*/docs/queries/*.md`, schemaKey: "query" },
|
|
20
21
|
{ glob: `${m}/[a-zA-Z]*/README.md`, schemaKey: "module" },
|
|
21
22
|
);
|
|
22
23
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineCommand, arg } from "politty";
|
|
3
|
+
import { runInit } from "./init";
|
|
4
|
+
import { runLicenseCheck, runLicenseList } from "./license";
|
|
5
|
+
import { moduleCommand } from "./module/index";
|
|
6
|
+
import { appCommand } from "./app/index";
|
|
7
|
+
import { mockCommand } from "./mock/index";
|
|
8
|
+
|
|
9
|
+
export { moduleCommand } from "./module/index";
|
|
10
|
+
export { appCommand } from "./app/index";
|
|
11
|
+
export { mockCommand } from "./mock/index";
|
|
12
|
+
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
|
|
15
|
+
export const initCommand = defineCommand({
|
|
16
|
+
name: "init",
|
|
17
|
+
description: "Set up consumer repo with framework skills",
|
|
18
|
+
args: z.object({
|
|
19
|
+
force: arg(z.boolean().default(false), {
|
|
20
|
+
alias: "f",
|
|
21
|
+
description: "Overwrite existing skills",
|
|
22
|
+
}),
|
|
23
|
+
}),
|
|
24
|
+
run: (args) => {
|
|
25
|
+
const exitCode = runInit(cwd, args.force);
|
|
26
|
+
process.exit(exitCode);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const licenseCheckCommand = defineCommand({
|
|
31
|
+
name: "check",
|
|
32
|
+
description: "Check dependency licenses against allowlist",
|
|
33
|
+
args: z.object({
|
|
34
|
+
config: arg(z.string(), {
|
|
35
|
+
alias: "c",
|
|
36
|
+
description: "Path to license config JSON file",
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
run: (args) => {
|
|
40
|
+
const exitCode = runLicenseCheck(args.config);
|
|
41
|
+
process.exit(exitCode);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const licenseListCommand = defineCommand({
|
|
46
|
+
name: "list",
|
|
47
|
+
description: "List available license groups",
|
|
48
|
+
run: () => {
|
|
49
|
+
const exitCode = runLicenseList();
|
|
50
|
+
process.exit(exitCode);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const licenseCommand = defineCommand({
|
|
55
|
+
name: "license",
|
|
56
|
+
description: "License management",
|
|
57
|
+
subCommands: {
|
|
58
|
+
check: licenseCheckCommand,
|
|
59
|
+
list: licenseListCommand,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const mainCommand = defineCommand({
|
|
64
|
+
name: "erp-kit",
|
|
65
|
+
description: "ERP module framework CLI",
|
|
66
|
+
subCommands: {
|
|
67
|
+
module: moduleCommand,
|
|
68
|
+
app: appCommand,
|
|
69
|
+
mock: mockCommand,
|
|
70
|
+
init: initCommand,
|
|
71
|
+
license: licenseCommand,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
5
|
-
import { runInit } from "./init
|
|
5
|
+
import { runInit } from "./init";
|
|
6
6
|
|
|
7
7
|
describe("runInit", () => {
|
|
8
8
|
let tmpDir: string;
|
|
@@ -17,7 +17,7 @@ describe("runInit", () => {
|
|
|
17
17
|
|
|
18
18
|
it("copies framework skills to .agents/skills/", () => {
|
|
19
19
|
runInit(tmpDir, false);
|
|
20
|
-
const skillPath = path.join(tmpDir, ".agents", "skills", "
|
|
20
|
+
const skillPath = path.join(tmpDir, ".agents", "skills", "erp-kit-module-1-docs", "SKILL.md");
|
|
21
21
|
expect(fs.existsSync(skillPath)).toBe(true);
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ describe("runInit", () => {
|
|
|
27
27
|
tmpDir,
|
|
28
28
|
".agents",
|
|
29
29
|
"skills",
|
|
30
|
-
"
|
|
30
|
+
"erp-kit-module-4-tdd",
|
|
31
31
|
"references",
|
|
32
32
|
"models.md",
|
|
33
33
|
);
|
|
@@ -47,7 +47,7 @@ describe("runInit", () => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it("does not overwrite existing framework skills", () => {
|
|
50
|
-
const skillDir = path.join(tmpDir, ".agents", "skills", "
|
|
50
|
+
const skillDir = path.join(tmpDir, ".agents", "skills", "erp-kit-module-1-docs");
|
|
51
51
|
fs.mkdirSync(skillDir, { recursive: true });
|
|
52
52
|
fs.writeFileSync(path.join(skillDir, "SKILL.md"), "# Customized");
|
|
53
53
|
runInit(tmpDir, false);
|
|
@@ -56,7 +56,7 @@ describe("runInit", () => {
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it("overwrites existing framework skills with --force", () => {
|
|
59
|
-
const skillDir = path.join(tmpDir, ".agents", "skills", "
|
|
59
|
+
const skillDir = path.join(tmpDir, ".agents", "skills", "erp-kit-module-1-docs");
|
|
60
60
|
fs.mkdirSync(skillDir, { recursive: true });
|
|
61
61
|
fs.writeFileSync(path.join(skillDir, "SKILL.md"), "# Customized");
|
|
62
62
|
runInit(tmpDir, true);
|
|
@@ -78,6 +78,23 @@ describe("runInit", () => {
|
|
|
78
78
|
expect(fs.lstatSync(claudeSkills).isSymbolicLink()).toBe(false);
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
it("removes stale erp-kit-* skills with --force", () => {
|
|
82
|
+
const staleDir = path.join(tmpDir, ".agents", "skills", "erp-kit-old-skill");
|
|
83
|
+
fs.mkdirSync(staleDir, { recursive: true });
|
|
84
|
+
fs.writeFileSync(path.join(staleDir, "SKILL.md"), "# Stale");
|
|
85
|
+
runInit(tmpDir, true);
|
|
86
|
+
expect(fs.existsSync(staleDir)).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("preserves non-erp-kit skills with --force", () => {
|
|
90
|
+
const customDir = path.join(tmpDir, ".agents", "skills", "my-custom-skill");
|
|
91
|
+
fs.mkdirSync(customDir, { recursive: true });
|
|
92
|
+
fs.writeFileSync(path.join(customDir, "SKILL.md"), "# Custom");
|
|
93
|
+
runInit(tmpDir, true);
|
|
94
|
+
expect(fs.existsSync(path.join(customDir, "SKILL.md"))).toBe(true);
|
|
95
|
+
expect(fs.readFileSync(path.join(customDir, "SKILL.md"), "utf-8")).toBe("# Custom");
|
|
96
|
+
});
|
|
97
|
+
|
|
81
98
|
it("relinks symlink with --force when target differs", () => {
|
|
82
99
|
const claudeSkills = path.join(tmpDir, ".claude", "skills");
|
|
83
100
|
fs.mkdirSync(path.dirname(claudeSkills), { recursive: true });
|
package/src/commands/init.ts
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import { PACKAGE_ROOT } from "../util
|
|
4
|
+
import { PACKAGE_ROOT } from "../util";
|
|
5
5
|
|
|
6
6
|
const SKILLS_SRC = path.join(PACKAGE_ROOT, "skills");
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"app-compose-2-requirements-breakdown",
|
|
16
|
-
"app-compose-3-doc-review",
|
|
17
|
-
"app-compose-4-design-mock",
|
|
18
|
-
"app-compose-5-design-mock-review",
|
|
19
|
-
"app-compose-6-implementation-spec",
|
|
20
|
-
"mock-scenario",
|
|
21
|
-
];
|
|
8
|
+
function discoverFrameworkSkills(): string[] {
|
|
9
|
+
if (!fs.existsSync(SKILLS_SRC)) return [];
|
|
10
|
+
return fs
|
|
11
|
+
.readdirSync(SKILLS_SRC, { withFileTypes: true })
|
|
12
|
+
.filter((entry) => entry.isDirectory() && entry.name.startsWith("erp-kit-"))
|
|
13
|
+
.map((entry) => entry.name);
|
|
14
|
+
}
|
|
22
15
|
|
|
23
16
|
function copyDirectoryRecursive(
|
|
24
17
|
srcDir: string,
|
|
@@ -55,9 +48,25 @@ export function runInit(cwd: string, force: boolean): number {
|
|
|
55
48
|
|
|
56
49
|
// --- Skills ---
|
|
57
50
|
const skillsDest = path.join(cwd, ".agents", "skills");
|
|
51
|
+
|
|
52
|
+
// Clean up existing erp-kit-* skills before copying to remove stale names
|
|
53
|
+
if (force && fs.existsSync(skillsDest)) {
|
|
54
|
+
let removedCount = 0;
|
|
55
|
+
for (const entry of fs.readdirSync(skillsDest)) {
|
|
56
|
+
if (entry.startsWith("erp-kit-")) {
|
|
57
|
+
fs.rmSync(path.join(skillsDest, entry), { recursive: true, force: true });
|
|
58
|
+
removedCount++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (removedCount > 0) {
|
|
62
|
+
console.log(chalk.green(` Removed ${removedCount} existing erp-kit-* skills`));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
let copiedCount = 0;
|
|
59
67
|
let skippedCount = 0;
|
|
60
|
-
|
|
68
|
+
const frameworkSkills = discoverFrameworkSkills();
|
|
69
|
+
for (const skill of frameworkSkills) {
|
|
61
70
|
const srcSkillDir = path.join(SKILLS_SRC, skill);
|
|
62
71
|
if (!fs.existsSync(srcSkillDir)) continue;
|
|
63
72
|
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
|
|
4
|
+
// License groups based on Google licenseclassifier categories
|
|
5
|
+
// https://github.com/google/licenseclassifier/blob/e6a9bb99b5a6f71d5a34336b8245e305f5430f99/license_type.go
|
|
6
|
+
export const licenseGroups = {
|
|
7
|
+
// https://github.com/google/licenseclassifier/blob/e6a9bb99b5a6f71d5a34336b8245e305f5430f99/license_type.go#L225
|
|
8
|
+
reciprocal: [
|
|
9
|
+
"APSL-1.0",
|
|
10
|
+
"APSL-1.1",
|
|
11
|
+
"APSL-1.2",
|
|
12
|
+
"APSL-2.0",
|
|
13
|
+
"CDDL-1.0",
|
|
14
|
+
"CDDL-1.1",
|
|
15
|
+
"CPL-1.0",
|
|
16
|
+
"EPL-1.0",
|
|
17
|
+
"EPL-2.0",
|
|
18
|
+
"FreeImage",
|
|
19
|
+
"IPL-1.0",
|
|
20
|
+
"MPL-1.0",
|
|
21
|
+
"MPL-1.1",
|
|
22
|
+
"MPL-2.0",
|
|
23
|
+
"Ruby",
|
|
24
|
+
],
|
|
25
|
+
// https://github.com/google/licenseclassifier/blob/e6a9bb99b5a6f71d5a34336b8245e305f5430f99/license_type.go#L249
|
|
26
|
+
notice: [
|
|
27
|
+
"AFL-1.1",
|
|
28
|
+
"AFL-1.2",
|
|
29
|
+
"AFL-2.0",
|
|
30
|
+
"AFL-2.1",
|
|
31
|
+
"AFL-3.0",
|
|
32
|
+
"Apache-1.0",
|
|
33
|
+
"Apache-1.1",
|
|
34
|
+
"Apache-2.0",
|
|
35
|
+
"Artistic-1.0-cl8",
|
|
36
|
+
"Artistic-1.0-Perl",
|
|
37
|
+
"Artistic-1.0",
|
|
38
|
+
"Artistic-2.0",
|
|
39
|
+
"BSL-1.0",
|
|
40
|
+
"BSD-2-Clause-FreeBSD",
|
|
41
|
+
"BSD-2-Clause-NetBSD",
|
|
42
|
+
"BSD-2-Clause",
|
|
43
|
+
"BSD-3-Clause-Attribution",
|
|
44
|
+
"BSD-3-Clause-Clear",
|
|
45
|
+
"BSD-3-Clause-LBNL",
|
|
46
|
+
"BSD-3-Clause",
|
|
47
|
+
"BSD-4-Clause",
|
|
48
|
+
"BSD-4-Clause-UC",
|
|
49
|
+
"BSD-Protection",
|
|
50
|
+
"CC-BY-1.0",
|
|
51
|
+
"CC-BY-2.0",
|
|
52
|
+
"CC-BY-2.5",
|
|
53
|
+
"CC-BY-3.0",
|
|
54
|
+
"CC-BY-4.0",
|
|
55
|
+
"FTL",
|
|
56
|
+
"ISC",
|
|
57
|
+
"ImageMagick",
|
|
58
|
+
"Libpng",
|
|
59
|
+
"Lil-1.0",
|
|
60
|
+
"Linux-OpenIB",
|
|
61
|
+
"LPL-1.02",
|
|
62
|
+
"LPL-1.0",
|
|
63
|
+
"MS-PL",
|
|
64
|
+
"MIT",
|
|
65
|
+
"NCSA",
|
|
66
|
+
"OpenSSL",
|
|
67
|
+
"PHP-3.01",
|
|
68
|
+
"PHP-3.0",
|
|
69
|
+
"PIL",
|
|
70
|
+
"Python-2.0",
|
|
71
|
+
"Python-2.0-complete",
|
|
72
|
+
"PostgreSQL",
|
|
73
|
+
"SGI-B-1.0",
|
|
74
|
+
"SGI-B-1.1",
|
|
75
|
+
"SGI-B-2.0",
|
|
76
|
+
"Unicode-DFS-2015",
|
|
77
|
+
"Unicode-DFS-2016",
|
|
78
|
+
"Unicode-TOU",
|
|
79
|
+
"UPL-1.0",
|
|
80
|
+
"W3C-19980720",
|
|
81
|
+
"W3C-20150513",
|
|
82
|
+
"W3C",
|
|
83
|
+
"X11",
|
|
84
|
+
"Xnet",
|
|
85
|
+
"Zend-2.0",
|
|
86
|
+
"zlib-acknowledgement",
|
|
87
|
+
"Zlib",
|
|
88
|
+
"ZPL-1.1",
|
|
89
|
+
"ZPL-2.0",
|
|
90
|
+
"ZPL-2.1",
|
|
91
|
+
],
|
|
92
|
+
// https://github.com/google/licenseclassifier/blob/e6a9bb99b5a6f71d5a34336b8245e305f5430f99/license_type.go#L324
|
|
93
|
+
unencumbered: ["CC0-1.0", "Unlicense", "0BSD"],
|
|
94
|
+
} as const;
|
|
95
|
+
|
|
96
|
+
export type LicenseGroup = keyof typeof licenseGroups;
|
|
97
|
+
|
|
98
|
+
interface LicenseConfig {
|
|
99
|
+
groups: LicenseGroup[];
|
|
100
|
+
allow?: string[];
|
|
101
|
+
deny?: string[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function buildAllowSet(config: LicenseConfig): Set<string> {
|
|
105
|
+
const set = new Set<string>();
|
|
106
|
+
for (const group of config.groups) {
|
|
107
|
+
for (const license of licenseGroups[group]) {
|
|
108
|
+
set.add(license);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (config.allow) {
|
|
112
|
+
for (const license of config.allow) {
|
|
113
|
+
set.add(license);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (config.deny) {
|
|
117
|
+
for (const license of config.deny) {
|
|
118
|
+
set.delete(license);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return set;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function isLicenseAllowed(licenseString: string, allowSet: Set<string>): boolean {
|
|
125
|
+
if (/\s+(?:OR|AND)\s+/i.test(licenseString)) {
|
|
126
|
+
const licenses = licenseString
|
|
127
|
+
.replace(/[()]/g, "")
|
|
128
|
+
.trim()
|
|
129
|
+
.split(/\s+(?:OR|AND)\s+/i)
|
|
130
|
+
.map((l) => l.trim())
|
|
131
|
+
.filter((l) => l.length > 0);
|
|
132
|
+
return licenses.every((l) => allowSet.has(l));
|
|
133
|
+
}
|
|
134
|
+
return allowSet.has(licenseString);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface LicenseViolation {
|
|
138
|
+
package: string;
|
|
139
|
+
license: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function runLicenseList(): number {
|
|
143
|
+
for (const [group, licenses] of Object.entries(licenseGroups)) {
|
|
144
|
+
console.log(`${group} (${licenses.length} licenses):`);
|
|
145
|
+
for (const license of licenses) {
|
|
146
|
+
console.log(` ${license}`);
|
|
147
|
+
}
|
|
148
|
+
console.log();
|
|
149
|
+
}
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function runLicenseCheck(configPath: string): number {
|
|
154
|
+
const raw = fs.readFileSync(configPath, "utf-8");
|
|
155
|
+
const config = JSON.parse(raw) as LicenseConfig;
|
|
156
|
+
|
|
157
|
+
const validGroups = Object.keys(licenseGroups);
|
|
158
|
+
for (const group of config.groups) {
|
|
159
|
+
if (!validGroups.includes(group)) {
|
|
160
|
+
console.error(`Unknown license group: "${group}". Valid groups: ${validGroups.join(", ")}`);
|
|
161
|
+
return 2;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const allowSet = buildAllowSet(config);
|
|
166
|
+
|
|
167
|
+
console.log("Checking licenses...\n");
|
|
168
|
+
execSync("pnpm licenses list", { stdio: "inherit" });
|
|
169
|
+
|
|
170
|
+
const output = execSync("pnpm licenses list --json");
|
|
171
|
+
const licensesJson = JSON.parse(output.toString()) as Record<string, { name: string }[]>;
|
|
172
|
+
|
|
173
|
+
const violations: LicenseViolation[] = [];
|
|
174
|
+
for (const [license, packages] of Object.entries(licensesJson)) {
|
|
175
|
+
if (!isLicenseAllowed(license, allowSet)) {
|
|
176
|
+
for (const pkg of packages) {
|
|
177
|
+
violations.push({ package: pkg.name, license });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (violations.length === 0) {
|
|
183
|
+
console.log("All licenses are allowed.");
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
console.error("Found dependencies with disallowed licenses:\n");
|
|
188
|
+
for (const violation of violations) {
|
|
189
|
+
console.error(` - ${violation.package}`);
|
|
190
|
+
console.error(` License: ${violation.license}\n`);
|
|
191
|
+
}
|
|
192
|
+
return 1;
|
|
193
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineCommand, arg } from "politty";
|
|
3
|
-
import { runMockStart } from "./start
|
|
4
|
-
import { runMockValidate } from "./validate
|
|
3
|
+
import { runMockStart } from "./start";
|
|
4
|
+
import { runMockValidate } from "./validate";
|
|
5
5
|
|
|
6
6
|
const startCommand = defineCommand({
|
|
7
7
|
name: "start",
|
|
@@ -2,7 +2,7 @@ import { createServer, request as httpRequest } from "node:http";
|
|
|
2
2
|
import { createServer as createNetServer } from "node:net";
|
|
3
3
|
import { existsSync, readdirSync } from "node:fs";
|
|
4
4
|
import { resolve, relative, join } from "node:path";
|
|
5
|
-
import { createMockServer, type MockServer } from "../../mockServer
|
|
5
|
+
import { createMockServer, type MockServer } from "../../mockServer";
|
|
6
6
|
|
|
7
7
|
interface MockEntry {
|
|
8
8
|
provider: string;
|
|
@@ -2,7 +2,7 @@ import { mkdtemp, mkdir, writeFile, rm } from "node:fs/promises";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
5
|
-
import { runMockValidate } from "./validate
|
|
5
|
+
import { runMockValidate } from "./validate";
|
|
6
6
|
|
|
7
7
|
let tempDir: string;
|
|
8
8
|
|