@mytechtoday/augment-extensions 0.1.2 → 0.4.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/README.md +614 -39
- package/augment-extensions/coding-standards/bash/README.md +196 -0
- package/augment-extensions/coding-standards/bash/module.json +163 -0
- package/augment-extensions/coding-standards/bash/rules/naming-conventions.md +336 -0
- package/augment-extensions/coding-standards/bash/rules/universal-standards.md +289 -0
- package/augment-extensions/coding-standards/css/README.md +40 -0
- package/augment-extensions/coding-standards/css/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/css/module.json +44 -0
- package/augment-extensions/coding-standards/css/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/css/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html/README.md +40 -0
- package/augment-extensions/coding-standards/html/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html/module.json +44 -0
- package/augment-extensions/coding-standards/html/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/README.md +194 -0
- package/augment-extensions/coding-standards/html-css-js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/html-css-js/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/html-css-js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/html-css-js/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html-css-js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/html-css-js/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html-css-js/module.json +48 -0
- package/augment-extensions/coding-standards/html-css-js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html-css-js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/html-css-js/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/html-css-js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/html-css-js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/js/README.md +46 -0
- package/augment-extensions/coding-standards/js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/js/module.json +49 -0
- package/augment-extensions/coding-standards/js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/php/README.md +248 -0
- package/augment-extensions/coding-standards/php/examples/api-endpoint-example.php +204 -0
- package/augment-extensions/coding-standards/php/examples/cli-command-example.php +206 -0
- package/augment-extensions/coding-standards/php/examples/legacy-refactoring-example.php +234 -0
- package/augment-extensions/coding-standards/php/examples/web-application-example.php +211 -0
- package/augment-extensions/coding-standards/php/examples/woocommerce-extension-example.php +215 -0
- package/augment-extensions/coding-standards/php/examples/wordpress-plugin-example.php +189 -0
- package/augment-extensions/coding-standards/php/module.json +166 -0
- package/augment-extensions/coding-standards/php/rules/api-development.md +480 -0
- package/augment-extensions/coding-standards/php/rules/category-configuration.md +332 -0
- package/augment-extensions/coding-standards/php/rules/cli-tools.md +472 -0
- package/augment-extensions/coding-standards/php/rules/cms-integration.md +561 -0
- package/augment-extensions/coding-standards/php/rules/code-quality.md +402 -0
- package/augment-extensions/coding-standards/php/rules/documentation.md +425 -0
- package/augment-extensions/coding-standards/php/rules/ecommerce.md +627 -0
- package/augment-extensions/coding-standards/php/rules/error-handling.md +336 -0
- package/augment-extensions/coding-standards/php/rules/legacy-migration.md +677 -0
- package/augment-extensions/coding-standards/php/rules/naming-conventions.md +279 -0
- package/augment-extensions/coding-standards/php/rules/performance.md +392 -0
- package/augment-extensions/coding-standards/php/rules/psr-standards.md +186 -0
- package/augment-extensions/coding-standards/php/rules/security.md +358 -0
- package/augment-extensions/coding-standards/php/rules/testing.md +403 -0
- package/augment-extensions/coding-standards/php/rules/type-declarations.md +331 -0
- package/augment-extensions/coding-standards/php/rules/web-applications.md +426 -0
- package/augment-extensions/coding-standards/powershell/README.md +154 -0
- package/augment-extensions/coding-standards/powershell/examples/admin-example.ps1 +272 -0
- package/augment-extensions/coding-standards/powershell/examples/automation-example.ps1 +173 -0
- package/augment-extensions/coding-standards/powershell/examples/cloud-example.ps1 +243 -0
- package/augment-extensions/coding-standards/powershell/examples/cross-platform-example.ps1 +297 -0
- package/augment-extensions/coding-standards/powershell/examples/dsc-example.ps1 +224 -0
- package/augment-extensions/coding-standards/powershell/examples/legacy-migration-example.ps1 +340 -0
- package/augment-extensions/coding-standards/powershell/examples/module-example.psm1 +255 -0
- package/augment-extensions/coding-standards/powershell/module.json +165 -0
- package/augment-extensions/coding-standards/powershell/rules/administrative-tools.md +439 -0
- package/augment-extensions/coding-standards/powershell/rules/automation-scripts.md +240 -0
- package/augment-extensions/coding-standards/powershell/rules/cloud-orchestration.md +384 -0
- package/augment-extensions/coding-standards/powershell/rules/configuration-schema.md +383 -0
- package/augment-extensions/coding-standards/powershell/rules/cross-platform-scripts.md +482 -0
- package/augment-extensions/coding-standards/powershell/rules/dsc-configurations.md +296 -0
- package/augment-extensions/coding-standards/powershell/rules/error-handling.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/legacy-migrations.md +466 -0
- package/augment-extensions/coding-standards/powershell/rules/modules-functions.md +244 -0
- package/augment-extensions/coding-standards/powershell/rules/naming-conventions.md +266 -0
- package/augment-extensions/coding-standards/powershell/rules/performance-optimization.md +209 -0
- package/augment-extensions/coding-standards/powershell/rules/security-practices.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/testing-guidelines.md +268 -0
- package/augment-extensions/coding-standards/powershell/rules/universal-standards.md +197 -0
- package/augment-extensions/coding-standards/python/README.md +12 -8
- package/augment-extensions/coding-standards/python/examples/best-practices.py +373 -0
- package/augment-extensions/coding-standards/python/module.json +8 -4
- package/augment-extensions/coding-standards/python/rules/async-patterns.md +884 -0
- package/augment-extensions/coding-standards/python/rules/documentation.md +831 -0
- package/augment-extensions/coding-standards/python/rules/error-handling.md +855 -68
- package/augment-extensions/coding-standards/python/rules/testing.md +409 -0
- package/augment-extensions/coding-standards/python/rules/tooling.md +446 -0
- package/augment-extensions/coding-standards/python/rules/type-hints.md +115 -50
- package/augment-extensions/collections/html-css-js/README.md +82 -0
- package/augment-extensions/collections/html-css-js/collection.json +41 -0
- package/augment-extensions/domain-rules/database/README.md +161 -0
- package/augment-extensions/domain-rules/database/examples/flat-database-example.md +793 -0
- package/augment-extensions/domain-rules/database/examples/hybrid-database-example.md +1132 -0
- package/augment-extensions/domain-rules/database/examples/nosql-document-example.md +868 -0
- package/augment-extensions/domain-rules/database/examples/nosql-graph-example.md +805 -0
- package/augment-extensions/domain-rules/database/examples/relational-schema-example.md +621 -0
- package/augment-extensions/domain-rules/database/examples/vector-database-example.md +965 -0
- package/augment-extensions/domain-rules/database/module.json +28 -0
- package/augment-extensions/domain-rules/database/rules/flat-databases.md +624 -0
- package/augment-extensions/domain-rules/database/rules/nosql-databases.md +588 -0
- package/augment-extensions/domain-rules/database/rules/nosql-document-stores.md +856 -0
- package/augment-extensions/domain-rules/database/rules/nosql-graph-databases.md +778 -0
- package/augment-extensions/domain-rules/database/rules/nosql-key-value-stores.md +963 -0
- package/augment-extensions/domain-rules/database/rules/performance-optimization.md +1076 -0
- package/augment-extensions/domain-rules/database/rules/relational-databases.md +697 -0
- package/augment-extensions/domain-rules/database/rules/relational-indexing.md +671 -0
- package/augment-extensions/domain-rules/database/rules/relational-query-optimization.md +607 -0
- package/augment-extensions/domain-rules/database/rules/relational-schema-design.md +907 -0
- package/augment-extensions/domain-rules/database/rules/relational-transactions.md +783 -0
- package/augment-extensions/domain-rules/database/rules/security-standards.md +980 -0
- package/augment-extensions/domain-rules/database/rules/universal-best-practices.md +485 -0
- package/augment-extensions/domain-rules/database/rules/vector-databases.md +521 -0
- package/augment-extensions/domain-rules/database/rules/vector-embeddings.md +858 -0
- package/augment-extensions/domain-rules/database/rules/vector-indexing.md +934 -0
- package/augment-extensions/domain-rules/mcp/README.md +150 -0
- package/augment-extensions/domain-rules/mcp/examples/compressed-example.md +522 -0
- package/augment-extensions/domain-rules/mcp/examples/graph-augmented-example.md +520 -0
- package/augment-extensions/domain-rules/mcp/examples/hybrid-example.md +570 -0
- package/augment-extensions/domain-rules/mcp/examples/state-based-example.md +427 -0
- package/augment-extensions/domain-rules/mcp/examples/token-based-example.md +435 -0
- package/augment-extensions/domain-rules/mcp/examples/vector-based-example.md +502 -0
- package/augment-extensions/domain-rules/mcp/module.json +49 -0
- package/augment-extensions/domain-rules/mcp/rules/compressed-mcp.md +595 -0
- package/augment-extensions/domain-rules/mcp/rules/configuration.md +345 -0
- package/augment-extensions/domain-rules/mcp/rules/graph-augmented-mcp.md +687 -0
- package/augment-extensions/domain-rules/mcp/rules/hybrid-mcp.md +636 -0
- package/augment-extensions/domain-rules/mcp/rules/state-based-mcp.md +484 -0
- package/augment-extensions/domain-rules/mcp/rules/testing-validation.md +360 -0
- package/augment-extensions/domain-rules/mcp/rules/token-based-mcp.md +393 -0
- package/augment-extensions/domain-rules/mcp/rules/universal-rules.md +194 -0
- package/augment-extensions/domain-rules/mcp/rules/vector-based-mcp.md +625 -0
- package/augment-extensions/domain-rules/wordpress/README.md +163 -0
- package/augment-extensions/domain-rules/wordpress/module.json +32 -0
- package/augment-extensions/domain-rules/wordpress/rules/coding-standards.md +617 -0
- package/augment-extensions/domain-rules/wordpress/rules/directory-structure.md +270 -0
- package/augment-extensions/domain-rules/wordpress/rules/file-patterns.md +423 -0
- package/augment-extensions/domain-rules/wordpress/rules/gutenberg-blocks.md +493 -0
- package/augment-extensions/domain-rules/wordpress/rules/performance.md +568 -0
- package/augment-extensions/domain-rules/wordpress/rules/plugin-development.md +510 -0
- package/augment-extensions/domain-rules/wordpress/rules/project-detection.md +251 -0
- package/augment-extensions/domain-rules/wordpress/rules/rest-api.md +501 -0
- package/augment-extensions/domain-rules/wordpress/rules/security.md +564 -0
- package/augment-extensions/domain-rules/wordpress/rules/theme-development.md +388 -0
- package/augment-extensions/domain-rules/wordpress/rules/woocommerce.md +441 -0
- package/augment-extensions/domain-rules/wordpress-plugin/README.md +139 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/ajax-plugin.md +1599 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/custom-post-type-plugin.md +1727 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block-plugin.md +428 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block.md +422 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/mvc-plugin.md +1623 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/object-oriented-plugin.md +1343 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/rest-endpoint.md +734 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/settings-page-plugin.md +1350 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/simple-procedural-plugin.md +503 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/singleton-plugin.md +971 -0
- package/augment-extensions/domain-rules/wordpress-plugin/module.json +53 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/activation-hooks.md +770 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/admin-interface.md +874 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/ajax-handlers.md +629 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/asset-management.md +559 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/context-providers.md +709 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/cron-jobs.md +736 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/database-management.md +1057 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/documentation-standards.md +463 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/frontend-functionality.md +478 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/gutenberg-blocks.md +818 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/internationalization.md +416 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/migration.md +667 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/performance-optimization.md +878 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-architecture.md +693 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-structure.md +352 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/rest-api.md +818 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/scaffolding-workflow.md +624 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/security-best-practices.md +866 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/testing-patterns.md +1165 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/testing.md +414 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/vscode-integration.md +751 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/woocommerce-integration.md +949 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/wordpress-org-submission.md +458 -0
- package/augment-extensions/examples/gutenberg-block-plugin/README.md +101 -0
- package/augment-extensions/examples/gutenberg-block-plugin/examples/testimonial-block.md +428 -0
- package/augment-extensions/examples/gutenberg-block-plugin/module.json +40 -0
- package/augment-extensions/examples/rest-api-plugin/README.md +98 -0
- package/augment-extensions/examples/rest-api-plugin/examples/task-manager-api.md +1299 -0
- package/augment-extensions/examples/rest-api-plugin/module.json +40 -0
- package/augment-extensions/examples/woocommerce-extension/README.md +98 -0
- package/augment-extensions/examples/woocommerce-extension/examples/product-customizer.md +763 -0
- package/augment-extensions/examples/woocommerce-extension/module.json +40 -0
- package/augment-extensions/workflows/beads/module.json +4 -3
- package/augment-extensions/workflows/database/README.md +195 -0
- package/augment-extensions/workflows/database/ai-prompt-testing.md +295 -0
- package/augment-extensions/workflows/database/examples/migration-example.md +498 -0
- package/augment-extensions/workflows/database/examples/optimization-example.md +496 -0
- package/augment-extensions/workflows/database/examples/schema-design-example.md +444 -0
- package/augment-extensions/workflows/database/module.json +42 -0
- package/augment-extensions/workflows/database/rules/data-migration.md +249 -0
- package/augment-extensions/workflows/database/rules/documentation-standards.md +339 -0
- package/augment-extensions/workflows/database/rules/migration-workflow.md +352 -0
- package/augment-extensions/workflows/database/rules/optimization-workflow.md +435 -0
- package/augment-extensions/workflows/database/rules/schema-design-workflow.md +535 -0
- package/augment-extensions/workflows/database/rules/testing-patterns.md +305 -0
- package/augment-extensions/workflows/database/rules/workflow.md +458 -0
- package/augment-extensions/workflows/openspec/module.json +4 -3
- package/augment-extensions/workflows/wordpress-plugin/README.md +232 -0
- package/augment-extensions/workflows/wordpress-plugin/ai-prompts.md +839 -0
- package/augment-extensions/workflows/wordpress-plugin/bead-decomposition-patterns.md +854 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/complete-plugin-example.md +540 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/custom-post-type-example.md +1083 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/feature-addition-workflow.md +669 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/plugin-creation-workflow.md +597 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/secure-form-handler-example.md +925 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/security-audit-workflow.md +752 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/wordpress-org-submission-workflow.md +773 -0
- package/augment-extensions/workflows/wordpress-plugin/module.json +49 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/best-practices.md +942 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/development-workflow.md +702 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/submission-workflow.md +728 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/testing-workflow.md +775 -0
- package/augment-extensions/writing-standards/screenplay/README.md +171 -0
- package/augment-extensions/writing-standards/screenplay/examples/aaa-hollywood-scene.fountain +164 -0
- package/augment-extensions/writing-standards/screenplay/module.json +124 -0
- package/augment-extensions/writing-standards/screenplay/rules/universal-formatting.md +339 -0
- package/cli/MODULES.md +302 -0
- package/cli/dist/cli.js +142 -9
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/catalog.d.ts +13 -0
- package/cli/dist/commands/catalog.d.ts.map +1 -0
- package/cli/dist/commands/catalog.js +104 -0
- package/cli/dist/commands/catalog.js.map +1 -0
- package/cli/dist/commands/gui.d.ts +6 -0
- package/cli/dist/commands/gui.d.ts.map +1 -0
- package/cli/dist/commands/gui.js +211 -0
- package/cli/dist/commands/gui.js.map +1 -0
- package/cli/dist/commands/init.d.ts.map +1 -1
- package/cli/dist/commands/init.js +12 -0
- package/cli/dist/commands/init.js.map +1 -1
- package/cli/dist/commands/install-rules.d.ts +14 -0
- package/cli/dist/commands/install-rules.d.ts.map +1 -0
- package/cli/dist/commands/install-rules.js +127 -0
- package/cli/dist/commands/install-rules.js.map +1 -0
- package/cli/dist/commands/link.d.ts.map +1 -1
- package/cli/dist/commands/link.js +9 -11
- package/cli/dist/commands/link.js.map +1 -1
- package/cli/dist/commands/list.d.ts.map +1 -1
- package/cli/dist/commands/list.js +11 -28
- package/cli/dist/commands/list.js.map +1 -1
- package/cli/dist/commands/mcp.d.ts +48 -0
- package/cli/dist/commands/mcp.d.ts.map +1 -0
- package/cli/dist/commands/mcp.js +229 -0
- package/cli/dist/commands/mcp.js.map +1 -0
- package/cli/dist/commands/self-remove.d.ts +7 -0
- package/cli/dist/commands/self-remove.d.ts.map +1 -0
- package/cli/dist/commands/self-remove.js +179 -0
- package/cli/dist/commands/self-remove.js.map +1 -0
- package/cli/dist/commands/show.d.ts.map +1 -1
- package/cli/dist/commands/show.js +42 -71
- package/cli/dist/commands/show.js.map +1 -1
- package/cli/dist/commands/skill.d.ts +67 -0
- package/cli/dist/commands/skill.d.ts.map +1 -0
- package/cli/dist/commands/skill.js +513 -0
- package/cli/dist/commands/skill.js.map +1 -0
- package/cli/dist/commands/unlink.d.ts +6 -0
- package/cli/dist/commands/unlink.d.ts.map +1 -0
- package/cli/dist/commands/unlink.js +115 -0
- package/cli/dist/commands/unlink.js.map +1 -0
- package/cli/dist/commands/validate.d.ts +6 -0
- package/cli/dist/commands/validate.d.ts.map +1 -0
- package/cli/dist/commands/validate.js +159 -0
- package/cli/dist/commands/validate.js.map +1 -0
- package/cli/dist/utils/catalog-sync.d.ts +22 -0
- package/cli/dist/utils/catalog-sync.d.ts.map +1 -0
- package/cli/dist/utils/catalog-sync.js +157 -0
- package/cli/dist/utils/catalog-sync.js.map +1 -0
- package/cli/dist/utils/character-count.d.ts +56 -0
- package/cli/dist/utils/character-count.d.ts.map +1 -0
- package/cli/dist/utils/character-count.js +190 -0
- package/cli/dist/utils/character-count.js.map +1 -0
- package/cli/dist/utils/documentation-validator.d.ts +18 -0
- package/cli/dist/utils/documentation-validator.d.ts.map +1 -0
- package/cli/dist/utils/documentation-validator.js +233 -0
- package/cli/dist/utils/documentation-validator.js.map +1 -0
- package/cli/dist/utils/install-rules.d.ts +32 -0
- package/cli/dist/utils/install-rules.d.ts.map +1 -0
- package/cli/dist/utils/install-rules.js +375 -0
- package/cli/dist/utils/install-rules.js.map +1 -0
- package/cli/dist/utils/mcp-integration.d.ts +70 -0
- package/cli/dist/utils/mcp-integration.d.ts.map +1 -0
- package/cli/dist/utils/mcp-integration.js +292 -0
- package/cli/dist/utils/mcp-integration.js.map +1 -0
- package/cli/dist/utils/module-system.d.ts +153 -0
- package/cli/dist/utils/module-system.d.ts.map +1 -0
- package/cli/dist/utils/module-system.js +528 -0
- package/cli/dist/utils/module-system.js.map +1 -0
- package/cli/dist/utils/modules-catalog.d.ts +33 -0
- package/cli/dist/utils/modules-catalog.d.ts.map +1 -0
- package/cli/dist/utils/modules-catalog.js +163 -0
- package/cli/dist/utils/modules-catalog.js.map +1 -0
- package/cli/dist/utils/rule-install-hooks.d.ts +19 -0
- package/cli/dist/utils/rule-install-hooks.d.ts.map +1 -0
- package/cli/dist/utils/rule-install-hooks.js +224 -0
- package/cli/dist/utils/rule-install-hooks.js.map +1 -0
- package/cli/dist/utils/skill-system.d.ts +95 -0
- package/cli/dist/utils/skill-system.d.ts.map +1 -0
- package/cli/dist/utils/skill-system.js +313 -0
- package/cli/dist/utils/skill-system.js.map +1 -0
- package/modules.md +534 -70
- package/package.json +12 -3
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
Before/after migration example showing Windows PowerShell to PowerShell Core migration.
|
|
4
|
+
|
|
5
|
+
.DESCRIPTION
|
|
6
|
+
Complete example demonstrating:
|
|
7
|
+
- Migration from Windows PowerShell 5.1 to PowerShell 7.4+
|
|
8
|
+
- WMI to CIM cmdlet migration
|
|
9
|
+
- Deprecated feature replacement
|
|
10
|
+
- Cross-platform compatibility improvements
|
|
11
|
+
- Version detection and compatibility checks
|
|
12
|
+
|
|
13
|
+
This file shows BEFORE and AFTER versions of common patterns.
|
|
14
|
+
|
|
15
|
+
.NOTES
|
|
16
|
+
Migration Guide:
|
|
17
|
+
1. Replace Get-WmiObject with Get-CimInstance
|
|
18
|
+
2. Replace ConvertTo-SecureString -AsPlainText with SecureString
|
|
19
|
+
3. Replace Windows-only cmdlets with cross-platform alternatives
|
|
20
|
+
4. Add #Requires -Version 7.4 directive
|
|
21
|
+
5. Test on target platforms (Windows, Linux, macOS)
|
|
22
|
+
#>
|
|
23
|
+
|
|
24
|
+
#region BEFORE: Windows PowerShell 5.1 Code
|
|
25
|
+
|
|
26
|
+
<#
|
|
27
|
+
# ❌ OLD: Windows PowerShell 5.1 - DO NOT USE
|
|
28
|
+
|
|
29
|
+
function Get-SystemInfoOld
|
|
30
|
+
{
|
|
31
|
+
param(
|
|
32
|
+
[string]$ComputerName = $env:COMPUTERNAME
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# ❌ DEPRECATED: Get-WmiObject (removed in PowerShell Core)
|
|
36
|
+
$os = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $ComputerName
|
|
37
|
+
$cpu = Get-WmiObject -Class Win32_Processor -ComputerName $ComputerName
|
|
38
|
+
|
|
39
|
+
# ❌ DEPRECATED: ConvertTo-SecureString -AsPlainText without -Force
|
|
40
|
+
$password = ConvertTo-SecureString "P@ssw0rd" -AsPlainText
|
|
41
|
+
|
|
42
|
+
# ❌ WINDOWS-ONLY: Get-EventLog (not available on Linux/macOS)
|
|
43
|
+
$events = Get-EventLog -LogName System -Newest 10
|
|
44
|
+
|
|
45
|
+
# ❌ BAD: No error handling
|
|
46
|
+
# ❌ BAD: No type constraints
|
|
47
|
+
# ❌ BAD: No CmdletBinding
|
|
48
|
+
|
|
49
|
+
return @{
|
|
50
|
+
OS = $os.Caption
|
|
51
|
+
CPU = $cpu.Name
|
|
52
|
+
Events = $events
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function Set-UserPasswordOld
|
|
57
|
+
{
|
|
58
|
+
param(
|
|
59
|
+
$Username, # ❌ No type constraint
|
|
60
|
+
$Password # ❌ Plain text password parameter
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# ❌ DEPRECATED: ConvertTo-SecureString -AsPlainText
|
|
64
|
+
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
|
|
65
|
+
|
|
66
|
+
# ❌ No validation
|
|
67
|
+
# ❌ No error handling
|
|
68
|
+
# ❌ No ShouldProcess support
|
|
69
|
+
|
|
70
|
+
Set-ADAccountPassword -Identity $Username -NewPassword $securePassword
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function Get-ServiceStatusOld
|
|
74
|
+
{
|
|
75
|
+
param($ServiceName) # ❌ No type constraint
|
|
76
|
+
|
|
77
|
+
# ❌ No error handling
|
|
78
|
+
# ❌ No validation
|
|
79
|
+
# ❌ No verbose output
|
|
80
|
+
|
|
81
|
+
$service = Get-Service $ServiceName
|
|
82
|
+
return $service.Status
|
|
83
|
+
}
|
|
84
|
+
#>
|
|
85
|
+
|
|
86
|
+
#endregion
|
|
87
|
+
|
|
88
|
+
#region AFTER: PowerShell 7.4+ Code
|
|
89
|
+
|
|
90
|
+
#Requires -Version 7.4
|
|
91
|
+
|
|
92
|
+
# ✅ NEW: PowerShell 7.4+ - RECOMMENDED
|
|
93
|
+
|
|
94
|
+
function Get-SystemInfoNew
|
|
95
|
+
{
|
|
96
|
+
[CmdletBinding()]
|
|
97
|
+
[OutputType([PSCustomObject])]
|
|
98
|
+
param(
|
|
99
|
+
[Parameter()]
|
|
100
|
+
[ValidateNotNullOrEmpty()]
|
|
101
|
+
[string]$ComputerName = $env:COMPUTERNAME
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
try
|
|
105
|
+
{
|
|
106
|
+
# ✅ GOOD: Get-CimInstance (cross-platform compatible)
|
|
107
|
+
$cimSession = if ($ComputerName -eq $env:COMPUTERNAME)
|
|
108
|
+
{
|
|
109
|
+
New-CimSession -ErrorAction Stop
|
|
110
|
+
}
|
|
111
|
+
else
|
|
112
|
+
{
|
|
113
|
+
New-CimSession -ComputerName $ComputerName -ErrorAction Stop
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
$os = Get-CimInstance -ClassName Win32_OperatingSystem -CimSession $cimSession -ErrorAction Stop
|
|
117
|
+
$cpu = Get-CimInstance -ClassName Win32_Processor -CimSession $cimSession -ErrorAction Stop | Select-Object -First 1
|
|
118
|
+
|
|
119
|
+
# ✅ GOOD: Cross-platform event log alternative
|
|
120
|
+
$events = if ($IsWindows)
|
|
121
|
+
{
|
|
122
|
+
# Use Get-WinEvent on Windows (more powerful than Get-EventLog)
|
|
123
|
+
Get-WinEvent -LogName System -MaxEvents 10 -ErrorAction SilentlyContinue
|
|
124
|
+
}
|
|
125
|
+
else
|
|
126
|
+
{
|
|
127
|
+
# Alternative for Linux/macOS
|
|
128
|
+
Write-Verbose "Event logs not available on this platform"
|
|
129
|
+
@()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# ✅ GOOD: Structured output with type
|
|
133
|
+
$result = [PSCustomObject]@{
|
|
134
|
+
ComputerName = $ComputerName
|
|
135
|
+
OperatingSystem = $os.Caption
|
|
136
|
+
OSVersion = $os.Version
|
|
137
|
+
Architecture = $os.OSArchitecture
|
|
138
|
+
Processor = $cpu.Name
|
|
139
|
+
ProcessorCores = $cpu.NumberOfCores
|
|
140
|
+
TotalMemoryGB = [math]::Round($os.TotalVisibleMemorySize / 1MB, 2)
|
|
141
|
+
FreeMemoryGB = [math]::Round($os.FreePhysicalMemory / 1MB, 2)
|
|
142
|
+
LastBootTime = $os.LastBootUpTime
|
|
143
|
+
RecentEvents = $events.Count
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# ✅ GOOD: Clean up CIM session
|
|
147
|
+
Remove-CimSession -CimSession $cimSession -ErrorAction SilentlyContinue
|
|
148
|
+
|
|
149
|
+
return $result
|
|
150
|
+
}
|
|
151
|
+
catch
|
|
152
|
+
{
|
|
153
|
+
Write-Error "Failed to get system information: $_"
|
|
154
|
+
throw
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function Set-UserPasswordNew
|
|
159
|
+
{
|
|
160
|
+
[CmdletBinding(SupportsShouldProcess)]
|
|
161
|
+
param(
|
|
162
|
+
[Parameter(Mandatory)]
|
|
163
|
+
[ValidateNotNullOrEmpty()]
|
|
164
|
+
[string]$Username,
|
|
165
|
+
|
|
166
|
+
[Parameter(Mandatory)]
|
|
167
|
+
[ValidateNotNull()]
|
|
168
|
+
[SecureString]$SecurePassword # ✅ GOOD: SecureString parameter
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
if ($PSCmdlet.ShouldProcess($Username, 'Set user password'))
|
|
172
|
+
{
|
|
173
|
+
try
|
|
174
|
+
{
|
|
175
|
+
# ✅ GOOD: Direct SecureString usage (no conversion needed)
|
|
176
|
+
Set-ADAccountPassword -Identity $Username -NewPassword $SecurePassword -ErrorAction Stop
|
|
177
|
+
Write-Verbose "Password updated for user: $Username"
|
|
178
|
+
}
|
|
179
|
+
catch
|
|
180
|
+
{
|
|
181
|
+
Write-Error "Failed to set password for $Username: $_"
|
|
182
|
+
throw
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function Get-ServiceStatusNew
|
|
188
|
+
{
|
|
189
|
+
[CmdletBinding()]
|
|
190
|
+
[OutputType([string])]
|
|
191
|
+
param(
|
|
192
|
+
[Parameter(Mandatory, ValueFromPipeline)]
|
|
193
|
+
[ValidateNotNullOrEmpty()]
|
|
194
|
+
[string]$ServiceName
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
process
|
|
198
|
+
{
|
|
199
|
+
try
|
|
200
|
+
{
|
|
201
|
+
# ✅ GOOD: Error handling with specific error action
|
|
202
|
+
$service = Get-Service -Name $ServiceName -ErrorAction Stop
|
|
203
|
+
|
|
204
|
+
Write-Verbose "Service '$ServiceName' status: $($service.Status)"
|
|
205
|
+
|
|
206
|
+
# ✅ GOOD: Return typed output
|
|
207
|
+
return $service.Status.ToString()
|
|
208
|
+
}
|
|
209
|
+
catch [Microsoft.PowerShell.Commands.ServiceCommandException]
|
|
210
|
+
{
|
|
211
|
+
Write-Error "Service '$ServiceName' not found"
|
|
212
|
+
throw
|
|
213
|
+
}
|
|
214
|
+
catch
|
|
215
|
+
{
|
|
216
|
+
Write-Error "Failed to get service status: $_"
|
|
217
|
+
throw
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
#endregion
|
|
223
|
+
|
|
224
|
+
#region Migration Compatibility Helpers
|
|
225
|
+
|
|
226
|
+
function Test-PowerShellVersion
|
|
227
|
+
{
|
|
228
|
+
[CmdletBinding()]
|
|
229
|
+
[OutputType([PSCustomObject])]
|
|
230
|
+
param(
|
|
231
|
+
[Parameter()]
|
|
232
|
+
[version]$MinimumVersion = '7.4.0'
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
$currentVersion = $PSVersionTable.PSVersion
|
|
236
|
+
$edition = $PSVersionTable.PSEdition
|
|
237
|
+
|
|
238
|
+
$result = [PSCustomObject]@{
|
|
239
|
+
CurrentVersion = $currentVersion
|
|
240
|
+
Edition = $edition
|
|
241
|
+
IsCore = $edition -eq 'Core'
|
|
242
|
+
IsDesktop = $edition -eq 'Desktop'
|
|
243
|
+
MeetsMinimum = $currentVersion -ge $MinimumVersion
|
|
244
|
+
Platform = if ($IsWindows) { 'Windows' }
|
|
245
|
+
elseif ($IsLinux) { 'Linux' }
|
|
246
|
+
elseif ($IsMacOS) { 'macOS' }
|
|
247
|
+
else { 'Unknown' }
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (-not $result.MeetsMinimum)
|
|
251
|
+
{
|
|
252
|
+
Write-Warning "Current version ($currentVersion) is below minimum ($MinimumVersion)"
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return $result
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function Test-ScriptCompatibility
|
|
259
|
+
{
|
|
260
|
+
[CmdletBinding()]
|
|
261
|
+
param(
|
|
262
|
+
[Parameter(Mandatory)]
|
|
263
|
+
[ValidateScript({ Test-Path $_ })]
|
|
264
|
+
[string]$ScriptPath
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
$issues = [System.Collections.Generic.List[PSObject]]::new()
|
|
268
|
+
$content = Get-Content -Path $ScriptPath -Raw
|
|
269
|
+
|
|
270
|
+
# Check for deprecated cmdlets
|
|
271
|
+
$deprecatedPatterns = @{
|
|
272
|
+
'Get-WmiObject' = 'Use Get-CimInstance instead'
|
|
273
|
+
'Set-WmiInstance' = 'Use Set-CimInstance instead'
|
|
274
|
+
'ConvertTo-SecureString.*-AsPlainText' = 'Use SecureString parameter directly'
|
|
275
|
+
'Get-EventLog' = 'Use Get-WinEvent (Windows only) or alternative'
|
|
276
|
+
'New-WebServiceProxy' = 'Use Invoke-RestMethod or Invoke-WebRequest'
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
foreach ($pattern in $deprecatedPatterns.GetEnumerator())
|
|
280
|
+
{
|
|
281
|
+
if ($content -match $pattern.Key)
|
|
282
|
+
{
|
|
283
|
+
$issues.Add([PSCustomObject]@{
|
|
284
|
+
Type = 'Deprecated'
|
|
285
|
+
Pattern = $pattern.Key
|
|
286
|
+
Recommendation = $pattern.Value
|
|
287
|
+
})
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return $issues
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
#endregion
|
|
295
|
+
|
|
296
|
+
#region Example Usage
|
|
297
|
+
|
|
298
|
+
if ($MyInvocation.InvocationName -ne '.')
|
|
299
|
+
{
|
|
300
|
+
Write-Host "`n=== PowerShell Migration Example ===" -ForegroundColor Cyan
|
|
301
|
+
|
|
302
|
+
# Check PowerShell version
|
|
303
|
+
Write-Host "`n--- Version Check ---" -ForegroundColor Yellow
|
|
304
|
+
$versionInfo = Test-PowerShellVersion
|
|
305
|
+
$versionInfo | Format-List
|
|
306
|
+
|
|
307
|
+
if ($versionInfo.MeetsMinimum)
|
|
308
|
+
{
|
|
309
|
+
# Demonstrate new functions
|
|
310
|
+
Write-Host "`n--- System Information (New Method) ---" -ForegroundColor Yellow
|
|
311
|
+
try
|
|
312
|
+
{
|
|
313
|
+
$systemInfo = Get-SystemInfoNew -Verbose
|
|
314
|
+
$systemInfo | Format-List
|
|
315
|
+
}
|
|
316
|
+
catch
|
|
317
|
+
{
|
|
318
|
+
Write-Warning "System info retrieval failed (may require Windows): $_"
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
# Demonstrate service status
|
|
322
|
+
Write-Host "`n--- Service Status (New Method) ---" -ForegroundColor Yellow
|
|
323
|
+
try
|
|
324
|
+
{
|
|
325
|
+
$status = Get-ServiceStatusNew -ServiceName 'Winmgmt' -Verbose
|
|
326
|
+
Write-Host "Service status: $status" -ForegroundColor Green
|
|
327
|
+
}
|
|
328
|
+
catch
|
|
329
|
+
{
|
|
330
|
+
Write-Warning "Service check failed: $_"
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else
|
|
334
|
+
{
|
|
335
|
+
Write-Host "`n✗ PowerShell version does not meet minimum requirements" -ForegroundColor Red
|
|
336
|
+
Write-Host "Please upgrade to PowerShell 7.4 or later" -ForegroundColor Yellow
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
#endregion
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
Example PowerShell module demonstrating best practices.
|
|
4
|
+
|
|
5
|
+
.DESCRIPTION
|
|
6
|
+
This module demonstrates:
|
|
7
|
+
- Advanced functions with CmdletBinding
|
|
8
|
+
- Parameter validation
|
|
9
|
+
- Pipeline support
|
|
10
|
+
- Error handling
|
|
11
|
+
- Module-scoped variables
|
|
12
|
+
- Public/private function separation
|
|
13
|
+
#>
|
|
14
|
+
|
|
15
|
+
#Requires -Version 7.4
|
|
16
|
+
|
|
17
|
+
# Module-scoped variables
|
|
18
|
+
$script:ModuleConfig = @{
|
|
19
|
+
DefaultTimeout = 30
|
|
20
|
+
MaxRetries = 3
|
|
21
|
+
LogLevel = 'Info'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#region Private Functions
|
|
25
|
+
|
|
26
|
+
function Write-ModuleLog
|
|
27
|
+
{
|
|
28
|
+
[CmdletBinding()]
|
|
29
|
+
param(
|
|
30
|
+
[Parameter(Mandatory)]
|
|
31
|
+
[ValidateSet('Info', 'Warning', 'Error')]
|
|
32
|
+
[string]$Level,
|
|
33
|
+
|
|
34
|
+
[Parameter(Mandatory)]
|
|
35
|
+
[string]$Message
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
$timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
|
|
39
|
+
$logMessage = "[$timestamp] [$Level] $Message"
|
|
40
|
+
|
|
41
|
+
switch ($Level)
|
|
42
|
+
{
|
|
43
|
+
'Info' { Write-Verbose $logMessage }
|
|
44
|
+
'Warning' { Write-Warning $logMessage }
|
|
45
|
+
'Error' { Write-Error $logMessage }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function Invoke-WithRetry
|
|
50
|
+
{
|
|
51
|
+
[CmdletBinding()]
|
|
52
|
+
param(
|
|
53
|
+
[Parameter(Mandatory)]
|
|
54
|
+
[scriptblock]$ScriptBlock,
|
|
55
|
+
|
|
56
|
+
[Parameter()]
|
|
57
|
+
[int]$MaxRetries = $script:ModuleConfig.MaxRetries,
|
|
58
|
+
|
|
59
|
+
[Parameter()]
|
|
60
|
+
[int]$DelaySeconds = 2
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
$attempt = 0
|
|
64
|
+
|
|
65
|
+
while ($attempt -lt $MaxRetries)
|
|
66
|
+
{
|
|
67
|
+
$attempt++
|
|
68
|
+
|
|
69
|
+
try
|
|
70
|
+
{
|
|
71
|
+
return & $ScriptBlock
|
|
72
|
+
}
|
|
73
|
+
catch
|
|
74
|
+
{
|
|
75
|
+
Write-ModuleLog -Level Warning -Message "Attempt $attempt failed: $($_.Exception.Message)"
|
|
76
|
+
|
|
77
|
+
if ($attempt -lt $MaxRetries)
|
|
78
|
+
{
|
|
79
|
+
Start-Sleep -Seconds $DelaySeconds
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
{
|
|
83
|
+
throw
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#endregion
|
|
90
|
+
|
|
91
|
+
#region Public Functions
|
|
92
|
+
|
|
93
|
+
function Get-UserData
|
|
94
|
+
{
|
|
95
|
+
<#
|
|
96
|
+
.SYNOPSIS
|
|
97
|
+
Retrieves user data with validation and error handling.
|
|
98
|
+
|
|
99
|
+
.DESCRIPTION
|
|
100
|
+
Demonstrates advanced function with CmdletBinding, parameter validation,
|
|
101
|
+
pipeline support, and comprehensive error handling.
|
|
102
|
+
|
|
103
|
+
.PARAMETER UserName
|
|
104
|
+
Username(s) to retrieve data for.
|
|
105
|
+
|
|
106
|
+
.PARAMETER IncludeDetails
|
|
107
|
+
Include detailed user information.
|
|
108
|
+
|
|
109
|
+
.EXAMPLE
|
|
110
|
+
Get-UserData -UserName 'jdoe'
|
|
111
|
+
Get basic user data for jdoe.
|
|
112
|
+
|
|
113
|
+
.EXAMPLE
|
|
114
|
+
'jdoe','asmith' | Get-UserData -IncludeDetails
|
|
115
|
+
Get detailed user data for multiple users via pipeline.
|
|
116
|
+
#>
|
|
117
|
+
|
|
118
|
+
[CmdletBinding()]
|
|
119
|
+
[OutputType([PSCustomObject])]
|
|
120
|
+
param(
|
|
121
|
+
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
|
|
122
|
+
[ValidateNotNullOrEmpty()]
|
|
123
|
+
[ValidatePattern('^[a-zA-Z0-9._-]+$')]
|
|
124
|
+
[Alias('Name', 'User')]
|
|
125
|
+
[string[]]$UserName,
|
|
126
|
+
|
|
127
|
+
[Parameter()]
|
|
128
|
+
[switch]$IncludeDetails
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
begin
|
|
132
|
+
{
|
|
133
|
+
Write-ModuleLog -Level Info -Message "Starting Get-UserData"
|
|
134
|
+
$results = [System.Collections.Generic.List[PSCustomObject]]::new()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
process
|
|
138
|
+
{
|
|
139
|
+
foreach ($user in $UserName)
|
|
140
|
+
{
|
|
141
|
+
try
|
|
142
|
+
{
|
|
143
|
+
Write-ModuleLog -Level Info -Message "Processing user: $user"
|
|
144
|
+
|
|
145
|
+
# Simulate data retrieval with retry logic
|
|
146
|
+
$userData = Invoke-WithRetry -ScriptBlock {
|
|
147
|
+
# Simulated API call
|
|
148
|
+
[PSCustomObject]@{
|
|
149
|
+
UserName = $user
|
|
150
|
+
DisplayName = "$user Display Name"
|
|
151
|
+
Email = "$user@example.com"
|
|
152
|
+
Created = (Get-Date).AddDays(-365)
|
|
153
|
+
LastLogin = Get-Date
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if ($IncludeDetails)
|
|
158
|
+
{
|
|
159
|
+
# Add detailed information
|
|
160
|
+
$userData | Add-Member -NotePropertyName 'Department' -NotePropertyValue 'IT'
|
|
161
|
+
$userData | Add-Member -NotePropertyName 'Manager' -NotePropertyValue 'manager@example.com'
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
$results.Add($userData)
|
|
165
|
+
|
|
166
|
+
# Output to pipeline immediately
|
|
167
|
+
Write-Output $userData
|
|
168
|
+
}
|
|
169
|
+
catch
|
|
170
|
+
{
|
|
171
|
+
Write-ModuleLog -Level Error -Message "Failed to get data for $user: $($_.Exception.Message)"
|
|
172
|
+
|
|
173
|
+
# Write non-terminating error
|
|
174
|
+
Write-Error -Message "Failed to retrieve user data for $user" -Category ObjectNotFound -TargetObject $user
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
end
|
|
180
|
+
{
|
|
181
|
+
Write-ModuleLog -Level Info -Message "Completed Get-UserData. Processed $($results.Count) users"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function Set-UserData
|
|
186
|
+
{
|
|
187
|
+
<#
|
|
188
|
+
.SYNOPSIS
|
|
189
|
+
Updates user data with ShouldProcess support.
|
|
190
|
+
|
|
191
|
+
.DESCRIPTION
|
|
192
|
+
Demonstrates ShouldProcess for -WhatIf and -Confirm support.
|
|
193
|
+
|
|
194
|
+
.PARAMETER UserName
|
|
195
|
+
Username to update.
|
|
196
|
+
|
|
197
|
+
.PARAMETER Department
|
|
198
|
+
New department value.
|
|
199
|
+
|
|
200
|
+
.PARAMETER Force
|
|
201
|
+
Skip confirmation prompts.
|
|
202
|
+
|
|
203
|
+
.EXAMPLE
|
|
204
|
+
Set-UserData -UserName 'jdoe' -Department 'Engineering' -WhatIf
|
|
205
|
+
Preview changes without applying them.
|
|
206
|
+
#>
|
|
207
|
+
|
|
208
|
+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
|
|
209
|
+
param(
|
|
210
|
+
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
|
|
211
|
+
[ValidateNotNullOrEmpty()]
|
|
212
|
+
[string]$UserName,
|
|
213
|
+
|
|
214
|
+
[Parameter(Mandatory)]
|
|
215
|
+
[ValidateNotNullOrEmpty()]
|
|
216
|
+
[string]$Department,
|
|
217
|
+
|
|
218
|
+
[Parameter()]
|
|
219
|
+
[switch]$Force
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
process
|
|
223
|
+
{
|
|
224
|
+
if ($Force -or $PSCmdlet.ShouldProcess($UserName, "Update department to $Department"))
|
|
225
|
+
{
|
|
226
|
+
try
|
|
227
|
+
{
|
|
228
|
+
Write-ModuleLog -Level Info -Message "Updating $UserName department to $Department"
|
|
229
|
+
|
|
230
|
+
# Simulated update operation
|
|
231
|
+
Start-Sleep -Milliseconds 100
|
|
232
|
+
|
|
233
|
+
Write-ModuleLog -Level Info -Message "Successfully updated $UserName"
|
|
234
|
+
|
|
235
|
+
[PSCustomObject]@{
|
|
236
|
+
UserName = $UserName
|
|
237
|
+
Department = $Department
|
|
238
|
+
Updated = Get-Date
|
|
239
|
+
Success = $true
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch
|
|
243
|
+
{
|
|
244
|
+
Write-ModuleLog -Level Error -Message "Failed to update $UserName: $($_.Exception.Message)"
|
|
245
|
+
throw
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
#endregion
|
|
252
|
+
|
|
253
|
+
# Export public functions
|
|
254
|
+
Export-ModuleMember -Function Get-UserData, Set-UserData
|
|
255
|
+
|