├── .github
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE
│ ├── bug-report.md
│ └── feature_request.md
├── PULL_REQUEST_TEMPLATE.md
├── SECURITY.md
└── workflows
│ ├── wf_Linux.yml
│ ├── wf_MacOS.yml
│ ├── wf_Windows.yml
│ └── wf_Windows_Core.yml
├── .gitignore
├── .readthedocs.yaml
├── .vscode
├── extensions.json
├── settings.json
└── tasks.json
├── CodeBuild
├── IntegrationTest
│ ├── New-IntegrationInfrastructure.ps1
│ ├── Remove-IntegrationInfrastructure.ps1
│ ├── Tests
│ │ └── Integration.Tests.ps1
│ └── buildspec.yml
├── UnitTestAndBuild
│ ├── Publish-CFNTemplatesToS3.ps1
│ ├── Validate-CFNTemplates.Tests.ps1
│ ├── Validate-JSONConfigurations.Tests.ps1
│ ├── buildspec.yml
│ ├── dotnet-install.ps1
│ └── dotnet-install.sh
├── configure_aws_credential.ps1
└── install_modules.ps1
├── LICENSE
├── README.md
├── actions_bootstrap.ps1
├── cloudformation
├── childtemplates
│ ├── psee.yml
│ └── psee_alarms.yml
├── control_plane_parameters
│ └── parameters.json
├── controlplane.yml
└── manual
│ └── pwshEmojiExplorer_pipeline.yml
├── docs
├── Add-EmojiToText.md
├── CHANGELOG.md
├── Get-AllEmoji.md
├── Get-Emoji.md
├── assets
│ ├── diagrams
│ │ └── pwshEmojiExplorer_datapull.drawio
│ ├── pwshEmojiExplorer.png
│ ├── pwshEmojiExplorer_datapull.png
│ ├── pwshEmojiExplorer_favicon_32x32.png
│ └── pwshEmojiExplorer_icon.png
├── index.md
├── pwshEmojiExplorer-Basics.md
├── pwshEmojiExplorer-FAQ.md
├── pwshEmojiExplorer-Metrics.md
├── pwshEmojiExplorer.md
├── pwshEmojiExplorer_data_workflow.md
└── requirements.txt
├── lambdafunctions
└── PowerShell
│ └── pwshEEUnicodeVersionMonitor
│ ├── pwshEEUnicodeVersionMonitor.build.ps1
│ ├── pwshEEUnicodeVersionMonitor.ps1
│ └── pwshEEUnicodeVersionMonitor.settings.ps1
├── mkdocs.yml
└── src
├── MarkdownRepair.ps1
├── PSScriptAnalyzerSettings.psd1
├── Tests
├── Integration
│ └── pwshEmojiExplorer-Integration.Tests.ps1
├── Unit
│ ├── ExportedFunctions.Tests.ps1
│ ├── Private
│ │ ├── Confirm-DataLocation.Tests.ps1
│ │ ├── Confirm-MetadataUpdate.Tests.ps1
│ │ ├── Confirm-XMLDataSet.Tests.ps1
│ │ ├── Convert-EmojiToHexCodePoint.Tests.ps1
│ │ ├── ConvertTo-PSEmoji.Tests.ps1
│ │ ├── Expand-XMLDataSet.Tests.ps1
│ │ ├── Get-RemoteFile.Tests.ps1
│ │ ├── Import-XMLDataSet.Tests.ps1
│ │ └── Invoke-XMLDataCheck.Tests.ps1
│ ├── Public
│ │ ├── Add-EmojiToText.Tests.ps1
│ │ ├── Get-AllEmoji.Tests.ps1
│ │ └── Get-Emoji.Tests.ps1
│ └── pwshEmojiExplorer-Module.Tests.ps1
└── asset
│ └── emojiTestData.ps1
├── pwshEmojiExplorer.Settings.ps1
├── pwshEmojiExplorer.build.ps1
└── pwshEmojiExplorer
├── ArgumentCompleters.ps1
├── Imports.ps1
├── Private
├── Confirm-DataLocation.ps1
├── Confirm-MetadataUpdate.ps1
├── Confirm-XMLDataSet.ps1
├── Convert-EmojiToHexCodePoint.ps1
├── ConvertTo-PSEmoji.ps1
├── Expand-XMLDataSet.ps1
├── Get-RemoteFile.ps1
├── Import-XMLDataSet.ps1
└── Invoke-XMLDataCheck.ps1
├── Public
├── Add-EmojiToText.ps1
├── Get-AllEmoji.ps1
└── Get-Emoji.ps1
├── pwshEmojiExplorer.Format.ps1xml
├── pwshEmojiExplorer.psd1
└── pwshEmojiExplorer.psm1
/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at **[EMAIL REQUIRED]**. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html)
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq)
76 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Thanks for your interest in contributing to the **pwshEmojiExplorer Project**.
4 |
5 | Whether it's a bug report, new feature, correction, or additional documentation, your feedback and contributions are appreciated.
6 |
7 | Please read through this document before submitting any issues or pull requests to ensure all the necessary information is provided to effectively respond to your bug report or contribution.
8 |
9 | Please note there is a code of conduct, please follow it in all your interactions with the project.
10 |
11 | ## Reporting Bugs/Feature Requests
12 |
13 | When filing an issue, please check [existing open](https://github.com/techthoughts2/pwshEmojiExplorer/issues), or [recently closed](https://github.com/techthoughts2/pwshEmojiExplorer/issues?q=is%3Aissue+is%3Aclosed), issues to make sure somebody else hasn't already reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
14 |
15 | * A reproducible test case or series of steps
16 | * The version of the module being used
17 | * Any modifications you've made relevant to the bug
18 | * Anything unusual about your environment or deployment
19 |
20 | ## Contributing via Pull Requests
21 |
22 | Contributions via pull requests are much appreciated. Before sending a pull request, please ensure that:
23 |
24 | 1. You are working against the latest source on the *Enhancements* branch.
25 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
26 | 3. You open an issue to discuss any significant work - I'd hate for your time to be wasted.
27 |
28 | To send a pull request, please:
29 |
30 | 1. Fork the repository.
31 | 2. Checkout the *Enhancements* branch
32 | 3. Modify the source; please focus on the specific change you are contributing. Please refrain from code styling changes, it will be harder to focus on your change.
33 | 4. Ensure local tests pass.
34 | 5. Commit to your fork using clear commit messages.
35 | 6. Send a pull request, answering any default questions in the pull request interface.
36 |
37 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
38 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
39 |
40 | ## Finding contributions to work on
41 |
42 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (dev/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/techthoughts2/pwshEmojiExplorer/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) issues is a great place to start.
43 |
44 | ## Code of Conduct
45 |
46 | This project has a [Code of Conduct](CODE_OF_CONDUCT.md).
47 |
48 | ## Licensing
49 |
50 | See the [LICENSE](../LICENSE) file for our project's licensing.
51 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Submit a new bug
4 | title: Bug report
5 | labels: 'bug'
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
12 | ### Expected Behavior
13 |
14 |
15 | ### Current Behavior
16 |
17 |
18 | ### Possible Solution
19 |
20 |
21 | ### Steps to Reproduce
22 |
23 |
24 |
25 | 1.
26 | 2.
27 | 3.
28 | 4.
29 |
30 | ### Context (Environment)
31 |
32 |
33 | * Operating System and version as reported by `$PSVersionTable.OS`:
34 | * PowerShell versions as reported by `$PSVersionTable.PSEdition`:
35 |
36 |
37 |
38 | ### Detailed Description
39 |
40 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: 'Feature request'
5 | labels: 'enhancement'
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### Description
11 |
12 |
13 | ### Describe the solution you'd like
14 |
15 |
16 | ### Describe any alternatives you've considered
17 |
18 |
19 | ### Additional context
20 |
21 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Pull Request
2 |
3 | ## Issue
4 |
5 | Issue #, if available:
6 |
7 | ## Description
8 |
9 | Description of changes:
10 |
11 | ## License
12 |
13 | By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.
14 |
--------------------------------------------------------------------------------
/.github/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Reporting a Vulnerability
4 |
5 |
8 |
9 | If you discover a vulnerability in pwshEmojiExplorer, please follow the _following process_:
10 |
11 | 1. Open a generic bug issue advising you have discovered a vulnerability.
12 | - Avoid sharing specifics or details of the vulnerability in an open GitHub issue.
13 | 2. A repo owner will reach out to you to establish a private form of communication.
14 | 3. We will evaluate the vulnerability and, if necessary, release a fix or mitigating steps to address it. We will contact you to let you know the outcome, and will credit you in the report.
15 |
16 | Please **do not disclose the vulnerability publicly** until a fix is released!
17 |
18 | 4. Once we have either a) published a fix, or b) declined to address the vulnerability for whatever reason, you are free to publicly disclose it.
19 |
20 |
--------------------------------------------------------------------------------
/.github/workflows/wf_Linux.yml:
--------------------------------------------------------------------------------
1 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions
2 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners
3 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
4 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell
5 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
6 | # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-powershell
7 | # https://github.com/actions/upload-artifact#where-does-the-upload-go
8 | name: ActionsTest-Linux-Build
9 | on:
10 | pull_request:
11 | paths-ignore:
12 | - '**.md'
13 | - 'docs/**'
14 | branches-ignore:
15 | - 'pipeline'
16 | - 'doctesting'
17 | push:
18 | paths-ignore:
19 | - '**.md'
20 | - 'docs/**'
21 | branches-ignore:
22 | - 'pipeline'
23 | - 'doctesting'
24 | jobs:
25 | test:
26 | name: Run Tests
27 | runs-on: ubuntu-latest
28 | strategy:
29 | fail-fast: false
30 | steps:
31 | - name: Check out repository
32 | uses: actions/checkout@v3
33 | - name: Display the path
34 | shell: pwsh
35 | run: echo ${env:PATH}
36 | - name: Version Display
37 | shell: pwsh
38 | run: $PSVersionTable
39 | # uncomment below to explore what modules/variables/env variables are available in the build image
40 | # - name: Modules and Variables Display
41 | # shell: pwsh
42 | # run: Get-Module -ListAvailable; (Get-Variable).GetEnumerator() | Sort-Object Name | Out-String; (Get-ChildItem env:*).GetEnumerator() | Sort-Object Name | Out-String
43 | - name: Bootstrap
44 | shell: pwsh
45 | run: ./actions_bootstrap.ps1
46 | - name: Test and Build
47 | shell: pwsh
48 | run: Invoke-Build -File .\src\pwshEmojiExplorer.build.ps1
49 | - name: Upload pester results
50 | uses: actions/upload-artifact@v3
51 | with:
52 | name: pester-results
53 | path: ./src/Artifacts/testOutput
54 | if-no-files-found: warn
55 | - name: Upload zip module archive build
56 | uses: actions/upload-artifact@v3
57 | with:
58 | name: zip-archive
59 | path: ./src/Archive
60 | if-no-files-found: warn
61 |
62 |
--------------------------------------------------------------------------------
/.github/workflows/wf_MacOS.yml:
--------------------------------------------------------------------------------
1 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions
2 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners
3 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
4 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell
5 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
6 | # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-powershell
7 | # https://github.com/actions/upload-artifact#where-does-the-upload-go
8 | name: ActionsTest-MacOS-Build
9 | on:
10 | pull_request:
11 | paths-ignore:
12 | - '**.md'
13 | - 'docs/**'
14 | branches-ignore:
15 | - 'pipeline'
16 | - 'doctesting'
17 | push:
18 | paths-ignore:
19 | - '**.md'
20 | - 'docs/**'
21 | branches-ignore:
22 | - 'pipeline'
23 | - 'doctesting'
24 | jobs:
25 | test:
26 | name: Run Tests
27 | runs-on: macOS-latest
28 | strategy:
29 | fail-fast: false
30 | steps:
31 | - name: Check out repository
32 | uses: actions/checkout@v3
33 | - name: Display the path
34 | shell: pwsh
35 | run: echo ${env:PATH}
36 | - name: Version Display
37 | shell: pwsh
38 | run: $PSVersionTable
39 | # uncomment below to explore what modules/variables/env variables are available in the build image
40 | # - name: Modules and Variables Display
41 | # shell: pwsh
42 | # run: Get-Module -ListAvailable; (Get-Variable).GetEnumerator() | Sort-Object Name | Out-String; (Get-ChildItem env:*).GetEnumerator() | Sort-Object Name | Out-String
43 | - name: Bootstrap
44 | shell: pwsh
45 | run: ./actions_bootstrap.ps1
46 | - name: Test and Build
47 | shell: pwsh
48 | run: Invoke-Build -File .\src\pwshEmojiExplorer.build.ps1
49 | - name: Upload pester results
50 | uses: actions/upload-artifact@v3
51 | with:
52 | name: pester-results
53 | path: ./src/Artifacts/testOutput
54 | if-no-files-found: warn
55 | - name: Upload zip module archive build
56 | uses: actions/upload-artifact@v3
57 | with:
58 | name: zip-archive
59 | path: ./src/Archive
60 | if-no-files-found: warn
61 |
62 |
--------------------------------------------------------------------------------
/.github/workflows/wf_Windows.yml:
--------------------------------------------------------------------------------
1 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions
2 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners
3 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
4 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell
5 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
6 | # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-powershell
7 | # https://github.com/actions/upload-artifact#where-does-the-upload-go
8 | name: ActionsTest-Windows-Build
9 | on:
10 | pull_request:
11 | paths-ignore:
12 | - '**.md'
13 | - 'docs/**'
14 | branches-ignore:
15 | - 'pipeline'
16 | - 'doctesting'
17 | push:
18 | paths-ignore:
19 | - '**.md'
20 | - 'docs/**'
21 | branches-ignore:
22 | - 'pipeline'
23 | - 'doctesting'
24 | jobs:
25 | test:
26 | name: Run Tests
27 | runs-on: windows-latest
28 | strategy:
29 | fail-fast: false
30 | steps:
31 | - name: Check out repository
32 | uses: actions/checkout@v3
33 | - name: Display the path
34 | shell: powershell
35 | run: echo ${env:PATH}
36 | - name: Version Display
37 | shell: powershell
38 | run: $PSVersionTable
39 | # uncomment below to explore what modules/variables/env variables are available in the build image
40 | # - name: Modules and Variables Display
41 | # shell: powershell
42 | # run: Get-Module -ListAvailable; (Get-Variable).GetEnumerator() | Sort-Object Name | Out-String; (Get-ChildItem env:*).GetEnumerator() | Sort-Object Name | Out-String
43 | - name: NuGet Latest
44 | shell: powershell
45 | run: Install-PackageProvider -Name "NuGet" -Confirm:$false -Force -Verbose
46 | - name: PowerShellGet Latest
47 | shell: powershell
48 | run: Install-Module -Name PowerShellGet -Repository PSGallery -Force
49 | - name: Bootstrap
50 | shell: powershell
51 | run: ./actions_bootstrap.ps1
52 | - name: Test and Build
53 | shell: powershell
54 | run: Invoke-Build -File .\src\pwshEmojiExplorer.build.ps1
55 | - name: Upload pester results
56 | uses: actions/upload-artifact@v3
57 | with:
58 | name: pester-results
59 | path: .\src\Artifacts\testOutput
60 | if-no-files-found: warn
61 | - name: Upload zip module archive build
62 | uses: actions/upload-artifact@v3
63 | with:
64 | name: zip-archive
65 | path: .\src\Archive
66 | if-no-files-found: warn
67 |
68 |
--------------------------------------------------------------------------------
/.github/workflows/wf_Windows_Core.yml:
--------------------------------------------------------------------------------
1 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions
2 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners
3 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
4 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell
5 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
6 | # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-powershell
7 | # https://github.com/actions/upload-artifact#where-does-the-upload-go
8 | name: ActionsTest-Windows-pwsh-Build
9 | on:
10 | pull_request:
11 | paths-ignore:
12 | - '**.md'
13 | - 'docs/**'
14 | branches-ignore:
15 | - 'pipeline'
16 | - 'doctesting'
17 | push:
18 | paths-ignore:
19 | - '**.md'
20 | - 'docs/**'
21 | branches-ignore:
22 | - 'pipeline'
23 | - 'doctesting'
24 | jobs:
25 | test:
26 | name: Run Tests
27 | runs-on: windows-latest
28 | strategy:
29 | fail-fast: false
30 | steps:
31 | - name: Check out repository
32 | uses: actions/checkout@v3
33 | - name: Display the path
34 | shell: pwsh
35 | run: echo ${env:PATH}
36 | - name: Version Display
37 | shell: pwsh
38 | run: $PSVersionTable
39 | # uncomment below to explore what modules/variables/env variables are available in the build image
40 | # - name: Modules and Variables Display
41 | # shell: pwsh
42 | # run: Get-Module -ListAvailable; (Get-Variable).GetEnumerator() | Sort-Object Name | Out-String; (Get-ChildItem env:*).GetEnumerator() | Sort-Object Name | Out-String
43 | - name: Bootstrap
44 | shell: pwsh
45 | run: ./actions_bootstrap.ps1
46 | - name: Test and Build
47 | shell: pwsh
48 | run: Invoke-Build -File .\src\pwshEmojiExplorer.build.ps1
49 | - name: Upload pester results
50 | uses: actions/upload-artifact@v3
51 | with:
52 | name: pester-results
53 | path: .\src\Artifacts\testOutput
54 | if-no-files-found: warn
55 | - name: Upload zip module archive build
56 | uses: actions/upload-artifact@v3
57 | with:
58 | name: zip-archive
59 | path: .\src\Archive
60 | if-no-files-found: warn
61 |
62 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Archive
2 | Artifacts
3 | cov.xml
4 | coverage.xml
5 | *.bkp
6 | # OS generated files #
7 | ######################
8 | .DS_Store
9 | .DS_Store?
10 | ._*
11 | .Spotlight-V100
12 | .Trashes
13 | ehthumbs.db
14 | Thumbs.db
15 |
--------------------------------------------------------------------------------
/.readthedocs.yaml:
--------------------------------------------------------------------------------
1 | # https://docs.readthedocs.io/en/stable/config-file/index.html
2 |
3 | # .readthedocs.yaml
4 | # Read the Docs configuration file
5 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
6 |
7 | # Required
8 | version: 2
9 |
10 | build:
11 | os: ubuntu-22.04
12 | tools:
13 | python: "3.12"
14 |
15 | mkdocs:
16 | configuration: mkdocs.yml
17 |
18 | python:
19 | install:
20 | - requirements: docs/requirements.txt
21 |
22 | # # Build PDF & ePub
23 | formats: all
24 | # - epub
25 | # - pdf
26 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846
3 | // for the documentation about the extensions.json format
4 | "recommendations": [
5 | "ms-vscode.PowerShell",
6 | "ryanluker.vscode-coverage-gutters",
7 | "DavidAnson.vscode-markdownlint",
8 | "aaron-bond.better-comments",
9 | "aws-scripting-guy.cform",
10 | "kddejong.vscode-cfn-lint",
11 | "redhat.vscode-yaml"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "markdownlint.config": {
3 | "default": true,
4 | "MD007": {
5 | "indent": 4
6 | },
7 | "no-hard-tabs": false
8 | },
9 | // When enabled, will trim trailing whitespace when you save a file.
10 | "files.trimTrailingWhitespace": true,
11 | // specifies the location of the explicitly ScriptAnalyzer settings file
12 | "powershell.scriptAnalysis.settingsPath": "PSScriptAnalyzerSettings.psd1",
13 | // specifies the PowerShell coding style used in this project (https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/81)
14 | "powershell.codeFormatting.preset":"Stroustrup",
15 | "[powershell]": {
16 | "files.encoding": "utf8bom",
17 | "files.autoGuessEncoding": true
18 | },
19 | "cSpell.enableFiletypes": [
20 | "powershell"
21 | ],
22 | "cSpell.words": [
23 | "gldata",
24 | "jakemorrison",
25 | "Pscx",
26 | "shortcode"
27 | ]
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/CodeBuild/IntegrationTest/New-IntegrationInfrastructure.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | This stands up any required infrastructure before the Pester integration tests run.
3 | It is invoked in the "pre_build" phase of CodeBuild.
4 | #>
5 |
6 | # $env:AWSAccountId = the AWS Account hosting the MOF Maker stack we're testing
7 | # $env:CODEBUILD_RESOLVED_SOURCE_VERSION = the CodeCommit Commit Id
8 |
9 | #$ErrorActionPreference = 'Stop'
10 | #Import-Module -Name 'AWSPowerShell.NetCore'
11 |
--------------------------------------------------------------------------------
/CodeBuild/IntegrationTest/Remove-IntegrationInfrastructure.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | This removes any required infrastructure after the Pester integration tests run.
3 | It is invoked whether the build succeeeds or fails, and is invoked in the
4 | "post_build" phase of CodeBuild.
5 | #>
6 |
7 | # $env:AWSAccountId = the AWS Account hosting the MOF Maker stack we're testing
8 | # $env:CODEBUILD_RESOLVED_SOURCE_VERSION = the CodeCommit Commit Id
9 |
10 | #$ErrorActionPreference = 'Stop'
11 | #Import-Module -Name 'AWSPowerShell.NetCore'
12 |
--------------------------------------------------------------------------------
/CodeBuild/IntegrationTest/Tests/Integration.Tests.ps1:
--------------------------------------------------------------------------------
1 | # $env:SERVICE_NAME = name of the project
2 | # $env:ARTIFACT_S3_BUCKET = the artifact bucket used by CB
3 | # $env:AWS_ACCOUNTID = the AWS Account hosting the service under test
4 | # $env:GIT_REPO = the git repo name
5 | # $env:S3_PREFIX = the artifact prefix used by CB
6 |
7 |
8 | Describe -Name 'Infrastructure Tests' -Fixture {
9 | BeforeAll {
10 | try {
11 | $cfnExports = Get-CFNExport -ErrorAction Stop
12 | }
13 | catch {
14 | throw
15 | }
16 | $script:ServiceName = $env:SERVICE_NAME
17 | $script:AWSRegion = $env:AWS_REGION
18 | $script:AWSAccountID = $env:AWS_ACCOUNTID
19 | } #before_all
20 |
21 | Context -Name 'psee.yml' -Fixture {
22 |
23 | It -Name 'Should create a PSEEFinalXMLBucketARN' -Test {
24 | $assertion = ($cfnExports | Where-Object { $_.Name -eq "$ServiceName-PSEEFinalXMLBucketARN" }).Value
25 | $expected = 'arn:aws:s3::*'
26 | $assertion | Should -BeLike $expected
27 | } #it
28 |
29 | It -Name 'Should create a PSEECloudFrontLogBucketARN' -Test {
30 | $assertion = ($cfnExports | Where-Object { $_.Name -eq "$ServiceName-PSEECloudFrontLogBucketARN" }).Value
31 | $expected = 'arn:aws:s3::*'
32 | $assertion | Should -BeLike $expected
33 | } #it
34 |
35 | It -Name 'Should create a CloudFront distribution' -Test {
36 | $assertion = ($cfnExports | Where-Object { $_.Name -eq "$ServiceName-PSEECloudFrontDistributionDomain" }).Value
37 | $expected = '*.cloudfront.net'
38 | $assertion | Should -BeLike $expected
39 | } #it
40 |
41 | } #context_psee.yml
42 |
43 | Context -Name 'psee_alarms.yml' -Fixture {
44 |
45 | It -Name 'Should create a pwshEEPubXMLMonitorAlarmARN' -Test {
46 | $assertion = ($cfnExports | Where-Object { $_.Name -eq "$ServiceName-pwshEEUnicodeVersionComparisonAlarmARN" }).Value
47 | $expected = 'arn:aws:cloudwatch:*'
48 | $assertion | Should -BeLike $expected
49 | } #it
50 |
51 | It -Name 'Should create a pwshEEUnicodeVersionMonitorARN' -Test {
52 | $assertion = ($cfnExports | Where-Object { $_.Name -eq "$ServiceName-pwshEEUnicodeVersionMonitorARN" }).Value
53 | $expected = 'arn:aws:lambda:*'
54 | $assertion | Should -BeLike $expected
55 | } #it
56 |
57 | } #context_psee_alarms.yml
58 |
59 | } #describe_infra_tests
60 |
--------------------------------------------------------------------------------
/CodeBuild/IntegrationTest/buildspec.yml:
--------------------------------------------------------------------------------
1 | # https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
2 | # https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-cli-create-build-spec.html
3 | # https://docs.aws.amazon.com/codebuild/latest/userguide/available-runtimes.html
4 | # https://docs.aws.amazon.com/codebuild/latest/userguide/runtime-versions.html
5 |
6 | version: 0.2
7 |
8 | phases:
9 | install:
10 | runtime-versions:
11 | dotnet: 6.0
12 |
13 | commands:
14 | - echo Configure AWS defaults using the configuration script added to the Docker Image.
15 | - pwsh -command './CodeBuild/configure_aws_credential.ps1'
16 | - echo Installing PowerShell Modules from S3
17 | - pwsh -command './CodeBuild/install_modules.ps1'
18 |
19 | pre_build:
20 | commands:
21 | - pwsh -command '$PSVersionTable'
22 | - pwsh -command 'Get-ChildItem env:'
23 | - echo Pre-Build started on `date`
24 | - pwsh -command '& ./CodeBuild/IntegrationTest/New-IntegrationInfrastructure.ps1'
25 |
26 | build:
27 | commands:
28 | - pwsh -command '
29 | Import-Module Pester;
30 | $pesterConfiguration = [PesterConfiguration]::new();
31 | $pesterConfiguration.Run.Exit = $true;
32 | $pesterConfiguration.Run.Path = "./CodeBuild/IntegrationTest/Tests";
33 | $pesterConfiguration.Output.Verbosity = "Detailed";
34 | Invoke-Pester -Configuration $pesterConfiguration'
35 | finally:
36 | - pwsh -command '& ./CodeBuild/IntegrationTest/Remove-IntegrationInfrastructure.ps1'
37 |
--------------------------------------------------------------------------------
/CodeBuild/UnitTestAndBuild/Publish-CFNTemplatesToS3.ps1:
--------------------------------------------------------------------------------
1 | $ErrorActionPreference = 'Stop'
2 | $ProgressPreference = 'SilentlyContinue'
3 |
4 | if ([String]::IsNullOrWhiteSpace($env:ARTIFACT_S3_BUCKET)) {
5 | throw 'The environment variable ARTIFACT_S3_BUCKET must be configured.'
6 | }
7 |
8 | if ([String]::IsNullOrWhiteSpace($env:S3_KEY_PREFIX)) {
9 | throw 'The environment variable S3_KEY_PREFIX must be configured.'
10 | }
11 |
12 | # # Paths are based from the root of the GIT repository
13 | # $paths = @(
14 | # './cloudformation'
15 | # )
16 |
17 | # if ($env:REGIONAL_BUCKET) {
18 | # $artifactBucket = $env:REGIONAL_BUCKET
19 | # }
20 | # else {
21 | # $artifactBucket = $env:ARTIFACT_S3_BUCKET
22 | # }
23 |
24 | # foreach ($path in $paths) {
25 | # Write-Host "Processing CloudFormation Templates in '$path':"
26 | # # All CloudFormation Templates to publish are located in or below the "./CloudFormation" folder
27 | # foreach ($file in (Get-ChildItem -Path $path -Recurse -File -Filter "*.yml")) {
28 |
29 | # '' # Blank line to separate CodeBuild Output
30 |
31 | # # Calculate the S3 Key Prefix, keeping the correct Folder Structure
32 | # if ($file.Name -like '*-ControlPlane.yml') {
33 | # $s3KeyPrefix = '{0}/CloudFormation/{1}' -f $env:S3_KEY_PREFIX, $file.Directory.Name
34 | # }
35 | # elseif ($file.Directory.Name -eq 'ChildTemplates') {
36 | # # Find the parent template path
37 | # $parentPath = Split-Path -Path $file.Directory
38 | # $templatePath = Split-Path -Path $parentPath -Leaf
39 | # $s3KeyPrefix = '{0}/CloudFormation/{1}/{2}' -f $env:S3_KEY_PREFIX, $templatePath, $file.Directory.Name
40 | # }
41 | # elseif ($file.Directory.Name -eq 'Manual') {
42 | # Write-Host 'Manually deployed CFN detected. Skipping.'
43 | # continue
44 | # }
45 | # else {
46 | # throw 'Unexpected directory encountered inside CloudFormation folder'
47 | # }
48 |
49 | # $s3Key = '{0}/{1}' -f $s3KeyPrefix, $file.Name
50 | # [string]$endPoint = "https://s3.$env:AWSRegion" + ".amazonaws.com"
51 |
52 | # Write-Host "ENDPOINT: $endPoint"
53 | # Write-Host "BUCKET: $artifactBucket"
54 | # Write-Host "KEY: $s3Key"
55 | # $writeS3ObjectSplat = @{
56 | # BucketName = $artifactBucket
57 | # Key = $s3Key
58 | # File = $file.FullName
59 | # Region = $env:AWSRegion
60 | # EndpointUrl = $endPoint
61 | # }
62 | # Write-S3Object @writeS3ObjectSplat
63 |
64 | # Remove-Variable -Name @('s3Key', 's3KeyPrefix') -ErrorAction SilentlyContinue
65 | # }
66 | # }
67 | # Update the ControlPlane Parameters JSON files with the target Artifact S3 Bucket.
68 | # All JSON files will be updated, however the deployment CodePipeline is hard coded
69 | # to a specific JSON file so other deployments will not be affected.
70 | foreach ($controlPlaneFolder in (Get-ChildItem -Path './cloudformation' -Recurse -Filter '*control_plane_parameters' -Directory)) {
71 | foreach ($file in (Get-ChildItem -Path $controlPlaneFolder.FullName -Filter '*.json' -Recurse)) {
72 | $fileContent = Get-Content -Path $file.FullName -Raw | ConvertFrom-Json
73 |
74 | $fileContent.Parameters.ArtifactS3Bucket = $env:ARTIFACT_S3_BUCKET
75 |
76 | $fileContent.Parameters.ArtifactS3KeyPrefix = $env:S3_KEY_PREFIX
77 |
78 | $fileContent | ConvertTo-Json -Compress -Depth 6 | Out-File -FilePath $file.FullName -Force
79 | }
80 | }
--------------------------------------------------------------------------------
/CodeBuild/UnitTestAndBuild/Validate-CFNTemplates.Tests.ps1:
--------------------------------------------------------------------------------
1 | $paths = @(
2 | 'cloudformation'
3 | )
4 | $files = Get-ChildItem -Path $paths -Recurse -Filter '*.yml'
5 | $ErrorActionPreference = 'Stop'
6 |
7 | Describe 'CloudFormation Template Validation' {
8 |
9 | Context -Name 'CloudFormation Templates' {
10 | Context -Name '<_.Name>' -Foreach $files {
11 | It 'is valid CFN' {
12 | { Test-CFNTemplate -TemplateBody (Get-Content -Path $_.FullName -Raw) } | Should -Not -Throw
13 | } #it
14 | }
15 | } #context_cfn_templates
16 |
17 | } #describe_cfn_templates
18 |
--------------------------------------------------------------------------------
/CodeBuild/UnitTestAndBuild/Validate-JSONConfigurations.Tests.ps1:
--------------------------------------------------------------------------------
1 | $paths = @(
2 | 'cloudformation'
3 | )
4 | $files = Get-ChildItem -Path $paths -File -Recurse -Filter '*.json'
5 | $ErrorActionPreference = 'Stop'
6 |
7 | Describe -Name 'JSON Configuration File Validation' {
8 |
9 | Context -Name 'JSON Parameter Files' {
10 | Context -Name '<_.Name>' -Foreach $files {
11 | It 'is valid JSON' {
12 | { $null = ConvertFrom-Json -InputObject (Get-Content -Path $_.FullName -Raw) } | Should -Not -Throw
13 | } #it
14 | }
15 | } #context_json_parameter_files
16 |
17 | } #describe_json_configuration_file_validation
18 |
--------------------------------------------------------------------------------
/CodeBuild/UnitTestAndBuild/buildspec.yml:
--------------------------------------------------------------------------------
1 | # https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
2 | # https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-cli-create-build-spec.html
3 | # https://docs.aws.amazon.com/codebuild/latest/userguide/available-runtimes.html
4 | #
5 |
6 | version: 0.2
7 |
8 | phases:
9 | install:
10 | runtime-versions:
11 | dotnet: 6.0
12 | # python: 3.9
13 |
14 | commands:
15 | # Check PowerShell Version
16 | - pwsh -command '$PSVersionTable'
17 |
18 | # Check available variables in the build
19 | # - pwsh -command 'Get-Variable'
20 |
21 | # Check available environment variables in the build
22 | # - pwsh -command 'Get-ChildItem env:'
23 |
24 | # Configure AWS defaults using the configuration script added to the Docker Image.
25 | - pwsh -command './CodeBuild/configure_aws_credential.ps1'
26 |
27 | # Installing PowerShell Modules from PSGallery
28 | - pwsh -command './CodeBuild/install_modules.ps1'
29 |
30 | # Install Python packages
31 | # - pip install pip -U
32 | # - pip install -r ./lambdafunctions/python/requirements.txt
33 |
34 | pre_build:
35 | commands:
36 | # https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
37 | # - pwsh -command '& ./CodeBuild/UnitTestAndBuild/dotnet-install.ps1 -Channel LTS'
38 | # - ./CodeBuild/UnitTestAndBuild/dotnet-install.sh --channel LTS
39 |
40 | # Validate CloudFormation Templates
41 | - pwsh -command '
42 | Import-Module Pester;
43 | $pesterConfiguration = [PesterConfiguration]::new();
44 | $pesterConfiguration.Run.Exit = $true;
45 | $pesterConfiguration.Run.Path = "./CodeBuild/UnitTestAndBuild/Validate-CFNTemplates.Tests.ps1";
46 | $pesterConfiguration.Output.Verbosity = "Detailed";
47 | Invoke-Pester -Configuration $pesterConfiguration'
48 |
49 | # Validate Json files
50 | - pwsh -command '
51 | Import-Module Pester;
52 | $pesterConfiguration = [PesterConfiguration]::new();
53 | $pesterConfiguration.Run.Exit = $true;
54 | $pesterConfiguration.Run.Path = "./CodeBuild/UnitTestAndBuild/Validate-JSONConfigurations.Tests.ps1";
55 | $pesterConfiguration.Output.Verbosity = "Detailed";
56 | Invoke-Pester -Configuration $pesterConfiguration'
57 | build:
58 | commands:
59 | # Run Python unit tests
60 | # - python -m pytest lambdafunctions/python/tests -v
61 |
62 | # Publish cloudformation templates to S3
63 | - pwsh -command '& ./CodeBuild/UnitTestAndBuild/Publish-CFNTemplatesToS3.ps1'
64 |
65 | # Running Invoke-Build against each PowerShell AWS Lambda Function
66 | - pwsh -command 'Get-ChildItem -Path './lambdafunctions/PowerShell' -Filter '*.build.ps1' -File -Recurse | ForEach-Object {Invoke-Build -File $_.FullName}'
67 |
68 | - cd $CODEBUILD_SRC_DIR/cloudformation
69 | - aws cloudformation package --template-file controlplane.yml --s3-bucket $ARTIFACT_S3_BUCKET --output-template-file controlplane-packaged.yml
70 |
71 | post_build:
72 | commands:
73 | - echo THE POSTBUILD
74 |
75 | artifacts:
76 | files:
77 | - cloudformation/**/*
78 | - CodeBuild/**/*
79 |
--------------------------------------------------------------------------------
/CodeBuild/configure_aws_credential.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | This script is used in AWS CodeBuild to configure the default AWS Credentials for use by the AWS CLI and the AWS Powershell module.
4 | .DESCRIPTION
5 | By default, the AWS PowerShell Module does not know about looking up an AWS Container's credentials path, so this works around that issue.
6 | .NOTES
7 | This script enables AWSPowerShell cmdlets in your CodeBuild to interact with and access other AWS resources in your account.
8 | #>
9 | 'Configuring AWS credentials'
10 |
11 | ' - Retrieving temporary credentials from metadata'
12 | $uri = 'http://169.254.170.2{0}' -f $env:AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
13 | $sts = Invoke-RestMethod -UseBasicParsing -Uri $uri
14 |
15 | ' - Setting default AWS Credential'
16 | $credentialsFile = "$env:HOME\.aws\credentials"
17 | $null = New-Item -Path $credentialsFile -Force
18 |
19 | '[default]' | Out-File -FilePath $credentialsFile -Append
20 | 'aws_access_key_id={0}' -f $sts.AccessKeyId | Out-File -FilePath $credentialsFile -Append
21 | 'aws_secret_access_key={0}' -f $sts.SecretAccessKey | Out-File -FilePath $credentialsFile -Append
22 | 'aws_session_token={0}' -f $sts.Token | Out-File -FilePath $credentialsFile -Append
23 |
24 | ' - Setting default AWS Region'
25 | 'region={0}' -f $env:AWS_DEFAULT_REGION | Out-File -FilePath $credentialsFile -Append
26 |
27 | ' - AWS credentials configured'
28 |
--------------------------------------------------------------------------------
/CodeBuild/install_modules.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | This script is used in AWS CodeBuild to install the required PowerShell Modules for the build process.
4 | .DESCRIPTION
5 | The version of PowerShell being run will be identified. This may vary depending on what type of build
6 | container you are running and if your buildspec is installing various versions of PowerShell. You will
7 | need to specify each module and version that is required for installation. You also need to specify
8 | which version of that module should be installed. Additionally, you will need to specify the S3 bucket
9 | location where that module currently resides, so that it can be downloaded and installed into the build
10 | container at runtime. This necessitates that you download and upload your required modules to S3 prior to
11 | the build being executed.
12 | .EXAMPLE
13 | Save-Module -Name Pester -RequiredVersion 4.4.5 -Path C:\RequiredModules
14 | Create an S3 bucket in your AWS account
15 | Zip the contents of the Pester Module up (when done properly the .psd1 of the module should be at the root of the zip)
16 | Name the ZIP file Pester_4.4.4 (adjust version as needed) unless you want to modify the logic below
17 | Upload the Pester Zip file up to S3 bucket you just created
18 | .NOTES
19 | Alternatively, you can source PowerShell modules from the PSGallery although this is quite a bit slower
20 | #>
21 |
22 |
23 | $galleryDownload = $true
24 |
25 | $ErrorActionPreference = 'Stop'
26 | $ProgressPreference = 'SilentlyContinue'
27 | $VerbosePreference = 'SilentlyContinue'
28 |
29 | # List of PowerShell Modules required for the build
30 | # The AWS PowerShell Modules are added below, based on the $PSEdition
31 | $modulesToInstall = [System.Collections.ArrayList]::new()
32 | # https://github.com/pester/Pester
33 | $null = $modulesToInstall.Add(([PSCustomObject]@{
34 | ModuleName = 'Pester'
35 | ModuleVersion = '5.5.0'
36 | BucketName = 'PSGallery'
37 | KeyPrefix = ''
38 | }))
39 | $null = $modulesToInstall.Add(([PSCustomObject]@{
40 | ModuleName = 'InvokeBuild'
41 | ModuleVersion = '5.10.4'
42 | BucketName = 'PSGallery'
43 | KeyPrefix = ''
44 | }))
45 | $null = $modulesToInstall.Add(([PSCustomObject]@{
46 | ModuleName = 'PSScriptAnalyzer'
47 | ModuleVersion = '1.21.0'
48 | BucketName = 'PSGallery'
49 | KeyPrefix = ''
50 | }))
51 | $null = $modulesToInstall.Add(([PSCustomObject]@{
52 | ModuleName = 'PoshGram'
53 | ModuleVersion = '2.3.0'
54 | BucketName = 'PSGallery'
55 | KeyPrefix = ''
56 | }))
57 | $null = $modulesToInstall.Add(([PSCustomObject]@{
58 | ModuleName = 'AWSLambdaPSCore'
59 | ModuleVersion = '3.0.1.0'
60 | BucketName = 'PSGallery'
61 | KeyPrefix = ''
62 | }))
63 | $null = $modulesToInstall.Add(([PSCustomObject]@{
64 | ModuleName = 'AWS.Tools.Common'
65 | ModuleVersion = '4.1.472'
66 | BucketName = 'PSGallery'
67 | KeyPrefix = ''
68 | }))
69 | $null = $modulesToInstall.Add(([PSCustomObject]@{
70 | ModuleName = 'AWS.Tools.CloudFormation'
71 | ModuleVersion = '4.1.472'
72 | BucketName = 'PSGallery'
73 | KeyPrefix = ''
74 | }))
75 | $null = $modulesToInstall.Add(([PSCustomObject]@{
76 | ModuleName = 'AWS.Tools.S3'
77 | ModuleVersion = '4.1.472'
78 | BucketName = 'PSGallery'
79 | KeyPrefix = ''
80 | }))
81 | $null = $modulesToInstall.Add(([PSCustomObject]@{
82 | ModuleName = 'AWS.Tools.SimpleSystemsManagement'
83 | ModuleVersion = '4.1.472'
84 | BucketName = 'PSGallery'
85 | KeyPrefix = ''
86 | }))
87 |
88 |
89 | if ($galleryDownload -eq $false) {
90 |
91 | $tempPath = [System.IO.Path]::GetTempPath()
92 |
93 | if ($PSVersionTable.Platform -eq 'Win32NT') {
94 | $moduleInstallPath = [System.IO.Path]::Combine($env:ProgramFiles, 'WindowsPowerShell', 'Modules')
95 | if ($PSEdition -eq 'Core') {
96 | $moduleInstallPath = [System.IO.Path]::Combine($env:ProgramFiles, 'PowerShell', 'Modules')
97 | # Add the AWSPowerShell.NetCore Module
98 | # $null = $modulesToInstall.Add(([PSCustomObject]@{
99 | # ModuleName = 'AWSPowerShell.NetCore'
100 | # ModuleVersion = '3.3.604.0'
101 | # BucketName = 'PSGallery'
102 | # KeyPrefix = ''
103 | # }))
104 | }
105 | else {
106 | $moduleInstallPath = [System.IO.Path]::Combine($env:ProgramFiles, 'WindowsPowerShell', 'Modules')
107 | # Add the AWSPowerShell Module
108 | # $null = $modulesToInstall.Add(([PSCustomObject]@{
109 | # ModuleName = 'AWSPowerShell'
110 | # ModuleVersion = '3.3.604.0'
111 | # BucketName = 'PSGallery'
112 | # KeyPrefix = ''
113 | # }))
114 | }
115 | }
116 | elseif ($PSVersionTable.Platform -eq 'Unix') {
117 | $moduleInstallPath = [System.IO.Path]::Combine('/', 'usr', 'local', 'share', 'powershell', 'Modules')
118 |
119 | # Add the AWSPowerShell.NetCore Module
120 | # $null = $modulesToInstall.Add(([PSCustomObject]@{
121 | # ModuleName = 'AWSPowerShell.NetCore'
122 | # ModuleVersion = '3.3.604.0'
123 | # BucketName = 'PSGallery'
124 | # KeyPrefix = ''
125 | # }))
126 | }
127 | elseif ($PSEdition -eq 'Desktop') {
128 | $moduleInstallPath = [System.IO.Path]::Combine($env:ProgramFiles, 'WindowsPowerShell', 'Modules')
129 | # Add the AWSPowerShell Module
130 | # $null = $modulesToInstall.Add(([PSCustomObject]@{
131 | # ModuleName = 'AWSPowerShell'
132 | # ModuleVersion = '3.3.604.0'
133 | # BucketName = 'PSGallery'
134 | # KeyPrefix = ''
135 | # }))
136 | }
137 | else {
138 | throw 'Unrecognized OS platform'
139 | }
140 |
141 | 'Installing PowerShell Modules'
142 | foreach ($module in $modulesToInstall) {
143 | ' - {0} {1}' -f $module.ModuleName, $module.ModuleVersion
144 |
145 | # Download file from S3
146 | $key = '{0}_{1}.zip' -f $module.ModuleName, $module.ModuleVersion
147 | $localFile = Join-Path -Path $tempPath -ChildPath $key
148 |
149 | # Download modules from S3 to using the AWS CLI
150 | #note: remove --quiet for more verbose output or if S3 download troubleshooting is needed
151 | $s3Uri = 's3://{0}/{1}{2}' -f $module.BucketName, $module.KeyPrefix, $key
152 | & aws s3 cp $s3Uri $localFile --quiet
153 |
154 | # Ensure the download worked
155 | if (-not(Test-Path -Path $localFile)) {
156 | $message = 'Failed to download {0}' -f $module.ModuleName
157 | " - $message"
158 | throw $message
159 | }
160 |
161 | # Create module path
162 | $modulePath = Join-Path -Path $moduleInstallPath -ChildPath $module.ModuleName
163 | $moduleVersionPath = Join-Path -Path $modulePath -ChildPath $module.ModuleVersion
164 | $null = New-Item -Path $modulePath -ItemType 'Directory' -Force
165 | $null = New-Item -Path $moduleVersionPath -ItemType 'Directory' -Force
166 |
167 | # Expand downloaded file
168 | Expand-Archive -Path $localFile -DestinationPath $moduleVersionPath -Force
169 | }
170 | } #if_GalleryDownload
171 | else {
172 | Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null
173 | 'Installing PowerShell Modules'
174 | Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
175 | # $NuGetProvider = Get-PackageProvider -Name "NuGet" -ErrorAction SilentlyContinue
176 | # if ( -not $NugetProvider ) {
177 | # Install-PackageProvider -Name "NuGet" -Confirm:$false -Force -Verbose
178 | # }
179 | foreach ($module in $modulesToInstall) {
180 | $installSplat = @{
181 | Name = $module.ModuleName
182 | RequiredVersion = $module.ModuleVersion
183 | Repository = 'PSGallery'
184 | SkipPublisherCheck = $true
185 | Force = $true
186 | ErrorAction = 'Stop'
187 | }
188 | try {
189 | Install-Module @installSplat
190 | Import-Module -Name $module.ModuleName -ErrorAction Stop
191 | ' - Successfully installed {0}' -f $module.ModuleName
192 | }
193 | catch {
194 | $message = 'Failed to install {0}' -f $module.ModuleName
195 | " - $message"
196 | throw
197 | }
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Jake
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # pwshEmojiExplorer
2 |
3 | [](https://github.com/PowerShell/PowerShell) [![PowerShell Gallery][psgallery-img]][psgallery-site]  [![License][license-badge]](LICENSE) [](https://pwshemojiexplorer.readthedocs.io/en/latest/?badge=latest)
4 |
5 | [psgallery-img]: https://img.shields.io/powershellgallery/dt/pwshEmojiExplorer?label=Powershell%20Gallery&logo=powershell
6 | [psgallery-site]: https://www.powershellgallery.com/packages/pwshEmojiExplorer
7 | [psgallery-v1]: https://www.powershellgallery.com/packages/pwshEmojiExplorer/0.8.1
8 | [license-badge]: https://img.shields.io/github/license/techthoughts2/pwshEmojiExplorer
9 |
10 |
11 |
12 |
13 |
14 | Branch | Windows - PowerShell | Windows - pwsh | Linux | MacOS
15 | --- | --- | --- | --- | --- |
16 | main | [](https://github.com/techthoughts2/pwshEmojiExplorer/actions/workflows/wf_Windows.yml) | [](https://github.com/techthoughts2/pwshEmojiExplorer/actions/workflows/wf_Windows_Core.yml) | [](https://github.com/techthoughts2/pwshEmojiExplorer/actions/workflows/wf_Linux.yml) | [](https://github.com/techthoughts2/pwshEmojiExplorer/actions/workflows/wf_MacOS.yml)
17 | Enhancements | [](https://github.com/techthoughts2/pwshEmojiExplorer/actions/workflows/wf_Windows.yml) | [](https://github.com/techthoughts2/pwshEmojiExplorer/actions/workflows/wf_Windows_Core.yml) | [](https://github.com/techthoughts2/pwshEmojiExplorer/actions/workflows/wf_Linux.yml) | [](https://github.com/techthoughts2/pwshEmojiExplorer/actions/workflows/wf_MacOS.yml)
18 |
19 | ## Synopsis
20 |
21 | pwshEmojiExplorer is a PowerShell module designed to enable users to search, discover, and retrieve emojis directly through the command line. Leveraging the extensive Unicode emoji library, the module offers a streamlined approach to exploring and integrating a vast range of emojis into various coding projects.
22 |
23 | ## Description
24 |
25 | This PowerShell module simplifies the process of finding and using emojis by enabling direct command-line searches. It's not just about bringing emojis into PowerShell scripts; it's about providing a solution for handling emojis in various coding projects. Whether you need the HTMLEntityFormat for a web project, a Unicode representation for a text file, or the hex code for a development task, pwshEmojiExplorer provides this information quickly and efficiently. It's a tool for developers, scripters, and digital creators who seek to incorporate emojis into their work more effectively, enhancing the ease of access and use of emojis in diverse digital contexts.
26 |
27 | ## Features
28 |
29 | - **Extensive Emoji Search**: Find emojis by name, category, code point, and more.
30 | - **Emoji Information Retrieval**: Get detailed information about each emoji, including different representations and formats.
31 | - **Text Enhancement**: Automatically enhance texts by adding or replacing words with emojis. Experimental, but perfect for adding a bit of fun to your scripts.
32 | - **Unicode Compliance**: Utilizes the Public data set from the Unicode Data Files, ensuring that you are working with officially recognized emoji standards and variations.
33 | - **Auto-updating**: Actively scans for updates in the Unicode data set and automatically upgrades to the latest published standard. This feature ensures you are aligned with the newest emoji releases and changes in the Unicode standard.
34 |
35 | ## Getting Started
36 |
37 | ### Documentation
38 |
39 | Documentation for pwshEmojiExplorer is available at: [https://pwshEmojiExplorer.readthedocs.io](https://pwshEmojiExplorer.readthedocs.io)
40 |
41 | ### Installation
42 |
43 | ```powershell
44 | Install-Module -Name 'pwshEmojiExplorer' -Repository PSGallery -Scope CurrentUser
45 | ```
46 |
47 | ### Quick Start
48 |
49 | ```powershell
50 | #-------------------------------------------------------------------------------------
51 | # Import the pwshEmojiExplorer module
52 | Import-Module -Name 'pwshEmojiExplorer'
53 | #-------------------------------------------------------------------------------------
54 | # Get detailed information about a specific emoji by its character
55 | Get-Emoji -Emoji '😀'
56 | #-------------------------------------------------------------------------------------
57 | # Retrieve a list of all emojis within the 'Food & Drink' group
58 | Get-Emoji -Group 'Food & Drink'
59 | #-------------------------------------------------------------------------------------
60 | # Retrieve a list of all emojis within the 'food-vegetable' sub-group
61 | Get-Emoji -SubGroup 'food-vegetable'
62 | #-------------------------------------------------------------------------------------
63 | # Find an emoji based on its shortcode 🥰
64 | Get-Emoji -ShortCode ':smiling_face_with_hearts:'
65 | #-------------------------------------------------------------------------------------
66 | # Get information about an emoji using its hex code, like '1F600' for 😀
67 | Get-Emoji -HexCodePoint '1F600'
68 | #-------------------------------------------------------------------------------------
69 | # Retrieve an emoji by specifying its decimal code point, e.g., 128512 for 😀
70 | Get-Emoji -Decimal 128512
71 | #-------------------------------------------------------------------------------------
72 | # Perform a general search for emojis
73 | Get-Emoji -SearchTerm 'fork'
74 | #-------------------------------------------------------------------------------------
75 | # Retrieve the complete list of available emojis
76 | Get-AllEmoji
77 | #-------------------------------------------------------------------------------------
78 | # Enhance a given text by automatically adding relevant emojis
79 | $sampleText = "I am going to the airport tomorrow to fly on a plane to Spain. Before I take off I'm going to eat some food. I've heard they have good restaurants at the terminal. Hopefully they have something spicy. You know how much I like hot food! I'm so excited to see you! Can't wait to see you! Love you!"
80 | Add-EmojiToText -Text $sampleText
81 | #-------------------------------------------------------------------------------------
82 | ```
83 |
84 | ## Notes
85 |
86 | This PowerShell project was created with [Catesta](https://github.com/techthoughts2/Catesta).
87 |
88 | ## Contributing
89 |
90 | If you'd like to contribute to pwshEmojiExplorer, please see the [contribution guidelines](.github/CONTRIBUTING.md).
91 |
92 | ## License
93 |
94 | This project is [licensed under the MIT License](LICENSE).
95 |
--------------------------------------------------------------------------------
/actions_bootstrap.ps1:
--------------------------------------------------------------------------------
1 | # Bootstrap dependencies
2 |
3 | # https://docs.microsoft.com/powershell/module/packagemanagement/get-packageprovider
4 | Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null
5 |
6 | # https://docs.microsoft.com/powershell/module/powershellget/set-psrepository
7 | Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
8 |
9 | # List of PowerShell Modules required for the build
10 | $modulesToInstall = [System.Collections.ArrayList]::new()
11 | # https://github.com/pester/Pester
12 | $null = $modulesToInstall.Add(([PSCustomObject]@{
13 | ModuleName = 'Pester'
14 | ModuleVersion = '5.6.1'
15 | }))
16 | # https://github.com/nightroman/Invoke-Build
17 | $null = $modulesToInstall.Add(([PSCustomObject]@{
18 | ModuleName = 'InvokeBuild'
19 | ModuleVersion = '5.12.1'
20 | }))
21 | # https://github.com/PowerShell/PSScriptAnalyzer
22 | $null = $modulesToInstall.Add(([PSCustomObject]@{
23 | ModuleName = 'PSScriptAnalyzer'
24 | ModuleVersion = '1.23.0'
25 | }))
26 | $null = $modulesToInstall.Add(([PSCustomObject]@{
27 | ModuleName = 'Convert'
28 | ModuleVersion = '1.5.0'
29 | }))
30 | # https://github.com/PowerShell/platyPS
31 | # older version used due to: https://github.com/PowerShell/platyPS/issues/457
32 | $null = $modulesToInstall.Add(([PSCustomObject]@{
33 | ModuleName = 'platyPS'
34 | ModuleVersion = '0.12.0'
35 | }))
36 |
37 |
38 |
39 | 'Installing PowerShell Modules'
40 | foreach ($module in $modulesToInstall) {
41 | $installSplat = @{
42 | Name = $module.ModuleName
43 | RequiredVersion = $module.ModuleVersion
44 | Repository = 'PSGallery'
45 | SkipPublisherCheck = $true
46 | Force = $true
47 | ErrorAction = 'Stop'
48 | }
49 | try {
50 | Install-Module @installSplat
51 | Import-Module -Name $module.ModuleName -ErrorAction Stop
52 | ' - Successfully installed {0}' -f $module.ModuleName
53 | }
54 | catch {
55 | $message = 'Failed to install {0}' -f $module.ModuleName
56 | " - $message"
57 | throw
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/cloudformation/control_plane_parameters/parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "Parameters": {
3 | "ServiceName": "pwshEmojiExplorer",
4 | "LMFunctionS3KeypwshEEUnicodeVersionMonitor": "< This value is replace by the UnitTestAndBuild CodeBuild step in the Lambda's build file >",
5 | "LMFunctionHandlerpwshEEUnicodeVersionMonitor": "< This value is replace by the UnitTestAndBuild CodeBuild step in the Lambda's build file >",
6 | "ArtifactS3Bucket": "will be replaced during CodeBuild process",
7 | "ArtifactS3KeyPrefix": "will be replaced during CodeBuild process"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/cloudformation/controlplane.yml:
--------------------------------------------------------------------------------
1 | # Master Control Plane cloudformation Template - Used to deploy the service to child AWS Accounts.
2 | # This control plane does the actual DEPLOYING, but it does so by referencing the child templates via AWS::cloudformation::Stack
3 | # Hi - you want a new parameter - great!
4 | # 1 - Update the parameter JSONS (ControlPlane-Parameters\*.json)
5 | # 2 - Update two locations in ControlPlane
6 | # 3 - Update two locations in ChildTemplates
7 |
8 | ---
9 | AWSTemplateFormatVersion: "2010-09-09"
10 |
11 | Description: "pwshEmojiExplorer: Control Plane"
12 |
13 | Parameters:
14 |
15 | ServiceName:
16 | Type: String
17 | Description: The name of the service being deployed.
18 |
19 | LMFunctionS3KeypwshEEUnicodeVersionMonitor:
20 | Type: String
21 | Description: S3 Key for the PubXMLMonitor Lambda function(s) zip file
22 |
23 | LMFunctionHandlerpwshEEUnicodeVersionMonitor:
24 | Type: String
25 | Description: PubXMLMonitor Lambda HANDLER provided by New-AWSPowerShellLambdaPackage during build
26 |
27 | ArtifactS3Bucket:
28 | Type: String
29 | Description: S3 Bucket for CodePipeline Artifacts
30 |
31 | ArtifactS3KeyPrefix:
32 | Type: String
33 | Description: S3 Key Prefix for CodePipeline Artifacts
34 |
35 | Resources:
36 | # Logical ID should be the same as the (child) nested template name - not required, but makes it easy to line things up and read
37 |
38 | # Deploys the serverless logic solution for pwshEmojiExplorer data gathering
39 | PSEE:
40 | Type: AWS::CloudFormation::Stack
41 | Properties:
42 | TemplateURL: ./childtemplates/psee.yml
43 | TimeoutInMinutes: 25 #make sure it can actually complete in this time period
44 | Parameters: #much match the parameters of nested template
45 | ServiceName: !Ref ServiceName
46 | ResourceType: prod
47 | Tags:
48 | - Key: ServiceName
49 | Value: !Ref ServiceName
50 | - Key: StackName
51 | Value: !Ref AWS::StackName
52 |
53 | PSEEAlarm:
54 | Type: AWS::CloudFormation::Stack
55 | DependsOn: PSEE
56 | Properties:
57 | TemplateURL: ./childtemplates/psee_alarms.yml
58 | TimeoutInMinutes: 15 #make sure it can actually complete in this time period
59 | Parameters: #much match the parameters of nested template
60 | ServiceName: !Ref ServiceName
61 | LambdaS3BucketName: !Ref ArtifactS3Bucket
62 | LMFunctionS3KeypwshEEUnicodeVersionMonitor: !Ref LMFunctionS3KeypwshEEUnicodeVersionMonitor
63 | LMFunctionHandlerpwshEEUnicodeVersionMonitor: !Ref LMFunctionHandlerpwshEEUnicodeVersionMonitor
64 | ResourceType: prod
65 | Tags:
66 | - Key: ServiceName
67 | Value: !Ref ServiceName
68 | - Key: StackName
69 | Value: !Ref AWS::StackName
70 |
--------------------------------------------------------------------------------
/docs/Add-EmojiToText.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: pwshEmojiExplorer-help.xml
3 | Module Name: pwshEmojiExplorer
4 | online version: https://pwshEmojiExplorer.readthedocs.io/en/latest/Add-EmojiToText/
5 | schema: 2.0.0
6 | ---
7 |
8 | # Add-EmojiToText
9 |
10 | ## SYNOPSIS
11 | Enhances text by adding emojis based on key words.
12 |
13 | ## SYNTAX
14 |
15 | ```
16 | Add-EmojiToText [-Text] [-Replace] []
17 | ```
18 |
19 | ## DESCRIPTION
20 | The Add-EmojiToText function is designed to enrich your text with emojis by identifying key words and appending relevant emojis.
21 | It scans the input text for words that can be associated with emojis and inserts an emoji next to each identified word.
22 | This function employs a "best effort" approach to match words with emojis, providing a fun and light-hearted way to spruce up messages or texts.
23 | Note that the function's ability to find and match emojis is based on simple logic, and it may not always find a perfect match for every word.
24 |
25 | ## EXAMPLES
26 |
27 | ### EXAMPLE 1
28 | ```
29 | $sampleText = "Spending the day debugging some code and optimizing algorithms. Later, planning a virtual meeting with my team to discuss cloud computing and data security. Can't forget to update my blog on the latest AI trends. In the evening, it's time to unwind with a sci-fi movie and maybe some online gaming. Proud to be a part of the ever-evolving digital era!"
30 | $enhancedText = Add-EmojiToText -Text $sampleText
31 | Write-Output $enhancedText
32 | ```
33 |
34 | This example demonstrates how Add-EmojiToText can be used to add a playful touch to a given text by inserting emojis.
35 | Emojis related to words like 'cloud', 'AI', 'movie', and 'time' are added next to the corresponding words in the text.
36 |
37 | ### EXAMPLE 2
38 | ```
39 | $sampleText = "I am going to the airport tomorrow to fly on a plane to Spain. Before I take off I'm going to eat some food. I've heard they have good restaurants at the terminal. Hopefully they have something spicy. You know how much I like hot food! I'm so excited to see you! Can't wait to see you! Love you!"
40 | Add-EmojiToText -Text $sampleText
41 | ```
42 |
43 | This example demonstrates how Add-EmojiToText can be used to add a playful touch to a given text by inserting emojis.
44 | Emojis related to words like 'airport', 'plane', 'Spain', and 'food' are added next to the corresponding words in the text.
45 |
46 | ### EXAMPLE 3
47 | ```
48 | $sampleText = "Morning coffee, followed by a workout and a quick check of the news. Work involves writing code, attending meetings, and brainstorming. Lunchtime is for catching up on social media. The evening is for relaxation, maybe with some music, a good book, or a movie. Ending the night by setting the alarm and dreaming about the beach."
49 | $enhancedText = Add-EmojiToText -Text $sampleText -Replace
50 | Write-Output $enhancedText
51 | ```
52 |
53 | This example demonstrates how Add-EmojiToText can be used to transform a text into a fun, emoji-centric version by replacing key words with their corresponding emojis.
54 | The -Replace switch is used to substitute these everyday activities and concepts with relevant emojis, creating an engaging and visually expressive rendition of the text.
55 | This playful transformation is perfect for adding a bit of whimsy to messages or social media posts.
56 |
57 | ## PARAMETERS
58 |
59 | ### -Text
60 | Specifies the text to be processed by the function.
61 |
62 | ```yaml
63 | Type: String
64 | Parameter Sets: (All)
65 | Aliases:
66 |
67 | Required: True
68 | Position: 1
69 | Default value: None
70 | Accept pipeline input: False
71 | Accept wildcard characters: False
72 | ```
73 |
74 | ### -Replace
75 | Specifies whether the function should replace the word with the emoji or add the emoji after the word.
76 | The default value is $false, which means that the emoji is added after the word.
77 | If the value is set to $true, the word is replaced with the emoji.
78 |
79 | ```yaml
80 | Type: SwitchParameter
81 | Parameter Sets: (All)
82 | Aliases:
83 |
84 | Required: False
85 | Position: Named
86 | Default value: False
87 | Accept pipeline input: False
88 | Accept wildcard characters: False
89 | ```
90 |
91 | ### CommonParameters
92 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
93 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
94 |
95 | ## INPUTS
96 |
97 | ## OUTPUTS
98 |
99 | ### System.String
100 | ## NOTES
101 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
102 | This function is experimental and intended for casual use to add a fun element to text processing.
103 |
104 | This function uses the Public data set from the Unicode Data Files and adheres to the Unicode Terms of Use:
105 | https://www.unicode.org/copyright.html
106 | https://www.unicode.org/license.txt
107 |
108 | ## RELATED LINKS
109 |
110 | [https://pwshEmojiExplorer.readthedocs.io/en/latest/Add-EmojiToText/](https://pwshEmojiExplorer.readthedocs.io/en/latest/Add-EmojiToText/)
111 |
112 | [https://www.unicode.org/license.txt](https://www.unicode.org/license.txt)
113 |
--------------------------------------------------------------------------------
/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.2.0/),
6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 |
8 | ## [0.9.0]
9 |
10 | - Module Changes
11 | - Updated to use Unicode Version: 16.0 (was previously Unicode Version: 15.1)
12 | - Added more debug outputs across all functions
13 | - Build Updates
14 | - Improved integration tests
15 | - Updated tests to follow Pester 5 rules
16 | - Updated Bootstrap file to latest version of module dependencies
17 | - Updated readthedocs dependencies versions
18 |
19 | ## [0.8.4]
20 |
21 | - Module Changes
22 | - Addressed bug where `Expand-XMLDataSet` can fail if user has `Expand-Archive` from `Pscx` module, not from `Microsoft.PowerShell.Archive`
23 | - Build Updates
24 | - Added `MarkdownRepair.ps1` and added Markdown repair logic to InvokeBuild script. This is to account for an issue in PowerShell `7.4.0`+ where a new parameter was introduced that platyPS can not handle during help creation. Ref: [platyPS issue]([text](https://github.com/PowerShell/platyPS/issues/595)).
25 |
26 | ## [0.8.2]
27 |
28 | - Module Changes
29 | - Added ReleaseNotes link to `psd1` manifest
30 | - Updated `Convert-EmojiToHexCodePoint` to use `System.Collections.Generic.List` instead of `System.Collections.ArrayList`
31 | - Build Updates
32 | - Adjusted metric dashboard arrangement and sizing
33 | - Misc
34 | - Updated `settings.json` for tab requirements to support Readthedocs
35 | - Updated `extensions.json` with recommended extensions for working with this repo
36 |
37 | ## [0.8.0]
38 |
39 | - Initial release.
40 |
--------------------------------------------------------------------------------
/docs/Get-AllEmoji.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: pwshEmojiExplorer-help.xml
3 | Module Name: pwshEmojiExplorer
4 | online version: https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-AllEmoji/
5 | schema: 2.0.0
6 | ---
7 |
8 | # Get-AllEmoji
9 |
10 | ## SYNOPSIS
11 | Retrieves all emojis.
12 |
13 | ## SYNTAX
14 |
15 | ```
16 | Get-AllEmoji [-IncludeAll] []
17 | ```
18 |
19 | ## DESCRIPTION
20 | The Get-AllEmoji function retrieves a comprehensive list of emojis.
21 | By default, the function returns only 'fully-qualified' emojis, which are the most common and widely supported versions.
22 | If you need to include 'minimally-qualified' and 'unqualified' emojis, which might not be as widely supported or are variations of the standard emojis, use the IncludeAll switch.
23 |
24 | ## EXAMPLES
25 |
26 | ### EXAMPLE 1
27 | ```
28 | Get-AllEmoji
29 | ```
30 |
31 | Retrieves all 'fully-qualified' emojis.
32 |
33 | ### EXAMPLE 2
34 | ```
35 | Get-AllEmoji -IncludeAll
36 | ```
37 |
38 | Retrieves all emojis, including both 'fully-qualified' and 'minimally-qualified'/'unqualified' emojis.
39 |
40 | ## PARAMETERS
41 |
42 | ### -IncludeAll
43 | Includes all emojis in the output, regardless of their qualification status.
44 | By default, only 'fully-qualified' emojis are returned.
45 |
46 | ```yaml
47 | Type: SwitchParameter
48 | Parameter Sets: (All)
49 | Aliases:
50 |
51 | Required: False
52 | Position: Named
53 | Default value: False
54 | Accept pipeline input: False
55 | Accept wildcard characters: False
56 | ```
57 |
58 | ### CommonParameters
59 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
60 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
61 |
62 | ## INPUTS
63 |
64 | ## OUTPUTS
65 |
66 | ### PSEmoji
67 | ## NOTES
68 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
69 | Qualification levels:
70 | - Fully-qualified - a complete, standard emoji
71 | - Minimally-qualified - a basic form of an emoji, often lacking detail
72 | - Unqualified - a raw, unrefined form of an emoji
73 |
74 | This function uses the Public data set from the Unicode Data Files and adheres to the Unicode Terms of Use:
75 | https://www.unicode.org/copyright.html
76 | https://www.unicode.org/license.txt
77 |
78 | ## RELATED LINKS
79 |
80 | [https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-AllEmoji/](https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-AllEmoji/)
81 |
82 | [https://www.unicode.org/license.txt](https://www.unicode.org/license.txt)
83 |
--------------------------------------------------------------------------------
/docs/Get-Emoji.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: pwshEmojiExplorer-help.xml
3 | Module Name: pwshEmojiExplorer
4 | online version: https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-Emoji/
5 | schema: 2.0.0
6 | ---
7 |
8 | # Get-Emoji
9 |
10 | ## SYNOPSIS
11 | Retrieves a specific emoji or a list of emojis based on various search criteria.
12 |
13 | ## SYNTAX
14 |
15 | ### Name
16 | ```
17 | Get-Emoji [-Emoji ] [-IncludeAll] []
18 | ```
19 |
20 | ### Group
21 | ```
22 | Get-Emoji [-Group ] [-IncludeAll] []
23 | ```
24 |
25 | ### SubGroup
26 | ```
27 | Get-Emoji [-SubGroup ] [-IncludeAll] []
28 | ```
29 |
30 | ### ShortCode
31 | ```
32 | Get-Emoji [-ShortCode ] [-IncludeAll] []
33 | ```
34 |
35 | ### Hex
36 | ```
37 | Get-Emoji [-HexCodePoint ] [-IncludeAll] []
38 | ```
39 |
40 | ### Decimal
41 | ```
42 | Get-Emoji [-Decimal ] [-IncludeAll] []
43 | ```
44 |
45 | ### Search
46 | ```
47 | Get-Emoji [-SearchTerm ] [-IncludeAll] []
48 | ```
49 |
50 | ## DESCRIPTION
51 | The Get-Emoji function allows users to retrieve emojis by specifying one or more search criteria such as Emoji, Group, SubGroup, ShortCode, HexCodePoint, Decimal, or a general SearchTerm.
52 | The function supports both exact and relaxed search terms.
53 | Exact search terms provide quick and efficient results, while relaxed search terms perform a more comprehensive search across relevant fields.
54 |
55 | ## EXAMPLES
56 |
57 | ### EXAMPLE 1
58 | ```
59 | Get-Emoji -Emoji '😀'
60 | ```
61 |
62 | Retrieves the emoji specified by the direct emoji character.
63 |
64 | ### EXAMPLE 2
65 | ```
66 | Get-Emoji -Group 'Food & Drink'
67 | ```
68 |
69 | Retrieves all emojis under the exact 'Food & Drink' group.
70 |
71 | ### EXAMPLE 3
72 | ```
73 | Get-Emoji -Group 'food'
74 | ```
75 |
76 | Performs a relaxed search and retrieves all emojis in groups containing the word 'food'.
77 |
78 | ### EXAMPLE 4
79 | ```
80 | Get-Emoji -SubGroup 'food-vegetable'
81 | ```
82 |
83 | Retrieves all emojis under the exact 'food-vegetable' subgroup.
84 |
85 | ### EXAMPLE 5
86 | ```
87 | Get-Emoji -SubGroup 'vegetable'
88 | ```
89 |
90 | Performs a relaxed search and retrieves all emojis in subgroups containing the word 'vegetable'.
91 |
92 | ### EXAMPLE 6
93 | ```
94 | Get-Emoji -ShortCode ':smiling_face_with_hearts:'
95 | ```
96 |
97 | Retrieves the emoji with the exact shortcode ':smiling_face_with_hearts:'.
98 |
99 | ### EXAMPLE 7
100 | ```
101 | Get-Emoji -ShortCode 'smiling'
102 | ```
103 |
104 | Performs a relaxed search and retrieves all emojis with shortcode containing 'smiling'.
105 |
106 | ### EXAMPLE 8
107 | ```
108 | Get-Emoji -HexCodePoint '1F600'
109 | ```
110 |
111 | Retrieves the emoji with the hexadecimal code point '1F600'.
112 |
113 | ### EXAMPLE 9
114 | ```
115 | Get-Emoji -Decimal 128512
116 | ```
117 |
118 | Retrieves the emoji with the exact decimal code '128512'.
119 |
120 | ### EXAMPLE 10
121 | ```
122 | Get-Emoji -Decimal '127812', '8205', '129003'
123 | ```
124 |
125 | Retrieves emojis that match all the specified decimal codes.
126 |
127 | ### EXAMPLE 11
128 | ```
129 | Get-Emoji -SearchTerm 'fork'
130 | ```
131 |
132 | Performs a general search and retrieves all emojis where 'fork' is found in the group, subgroup, or description.
133 |
134 | ### EXAMPLE 12
135 | ```
136 | Get-Emoji -SearchTerm 'plane' -IncludeAll
137 | ```
138 |
139 | Performs a general search and retrieves all emojis where 'plane' is found in the group, subgroup, or description.
140 | Includes all emojis in the output, regardless of their qualification status.
141 |
142 | ### EXAMPLE 13
143 | ```
144 |
145 | ```
146 |
147 | ### EXAMPLE 14
148 | ```
149 | Get-Emoji -SearchTerm 'fork' | Where-Object {$_.Group -eq 'Food & Drink'}
150 | ```
151 |
152 | This example shows how to retrieve all emojis with 'fork' in their group, subgroup, or description, and then filters the results to include only those in the 'Food & Drink' group.
153 |
154 | ## PARAMETERS
155 |
156 | ### -Emoji
157 | Specifies the emoji character to retrieve.
158 | Use an exact emoji character for a direct match.
159 |
160 | ```yaml
161 | Type: String
162 | Parameter Sets: Name
163 | Aliases:
164 |
165 | Required: False
166 | Position: Named
167 | Default value: None
168 | Accept pipeline input: False
169 | Accept wildcard characters: False
170 | ```
171 |
172 | ### -Group
173 | Specifies the group of emojis to retrieve.
174 |
175 | ```yaml
176 | Type: String
177 | Parameter Sets: Group
178 | Aliases:
179 |
180 | Required: False
181 | Position: Named
182 | Default value: None
183 | Accept pipeline input: False
184 | Accept wildcard characters: False
185 | ```
186 |
187 | ### -SubGroup
188 | Specifies the subgroup of emojis to retrieve.
189 |
190 | ```yaml
191 | Type: String
192 | Parameter Sets: SubGroup
193 | Aliases:
194 |
195 | Required: False
196 | Position: Named
197 | Default value: None
198 | Accept pipeline input: False
199 | Accept wildcard characters: False
200 | ```
201 |
202 | ### -ShortCode
203 | Specifies the shortcode of the emoji to retrieve.
204 |
205 | ```yaml
206 | Type: String
207 | Parameter Sets: ShortCode
208 | Aliases:
209 |
210 | Required: False
211 | Position: Named
212 | Default value: None
213 | Accept pipeline input: False
214 | Accept wildcard characters: False
215 | ```
216 |
217 | ### -HexCodePoint
218 | Specifies the hexadecimal code point of the emoji to retrieve.
219 |
220 | ```yaml
221 | Type: String
222 | Parameter Sets: Hex
223 | Aliases:
224 |
225 | Required: False
226 | Position: Named
227 | Default value: None
228 | Accept pipeline input: False
229 | Accept wildcard characters: False
230 | ```
231 |
232 | ### -Decimal
233 | Specifies the decimal code of the emoji to retrieve.
234 |
235 | ```yaml
236 | Type: String[]
237 | Parameter Sets: Decimal
238 | Aliases:
239 |
240 | Required: False
241 | Position: Named
242 | Default value: None
243 | Accept pipeline input: False
244 | Accept wildcard characters: False
245 | ```
246 |
247 | ### -SearchTerm
248 | Specifies a general search term to find emojis.
249 | Searches across group, subgroup, and description fields using a relaxed search approach.
250 |
251 | ```yaml
252 | Type: String
253 | Parameter Sets: Search
254 | Aliases:
255 |
256 | Required: False
257 | Position: Named
258 | Default value: None
259 | Accept pipeline input: False
260 | Accept wildcard characters: False
261 | ```
262 |
263 | ### -IncludeAll
264 | Includes all emojis in the output, regardless of their qualification status.
265 | By default, only 'fully-qualified' emojis are returned.
266 |
267 | ```yaml
268 | Type: SwitchParameter
269 | Parameter Sets: (All)
270 | Aliases:
271 |
272 | Required: False
273 | Position: Named
274 | Default value: False
275 | Accept pipeline input: False
276 | Accept wildcard characters: False
277 | ```
278 |
279 | ### CommonParameters
280 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
281 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
282 |
283 | ## INPUTS
284 |
285 | ## OUTPUTS
286 |
287 | ### PSEmoji
288 | ## NOTES
289 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
290 | Qualification levels:
291 | - Fully-qualified - a complete, standard emoji
292 | - Minimally-qualified - a basic form of an emoji, often lacking detail
293 | - Unqualified - a raw, unrefined form of an emoji
294 |
295 | This function uses the Public data set from the Unicode Data Files and adheres to the Unicode Terms of Use:
296 | https://www.unicode.org/copyright.html
297 | https://www.unicode.org/license.txt
298 |
299 | ## RELATED LINKS
300 |
301 | [https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-Emoji/](https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-Emoji/)
302 |
303 | [https://www.unicode.org/license.txt](https://www.unicode.org/license.txt)
304 |
--------------------------------------------------------------------------------
/docs/assets/pwshEmojiExplorer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techthoughts2/pwshEmojiExplorer/af62a33b35489eb87f3843145ebdf539dab71002/docs/assets/pwshEmojiExplorer.png
--------------------------------------------------------------------------------
/docs/assets/pwshEmojiExplorer_datapull.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techthoughts2/pwshEmojiExplorer/af62a33b35489eb87f3843145ebdf539dab71002/docs/assets/pwshEmojiExplorer_datapull.png
--------------------------------------------------------------------------------
/docs/assets/pwshEmojiExplorer_favicon_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techthoughts2/pwshEmojiExplorer/af62a33b35489eb87f3843145ebdf539dab71002/docs/assets/pwshEmojiExplorer_favicon_32x32.png
--------------------------------------------------------------------------------
/docs/assets/pwshEmojiExplorer_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/techthoughts2/pwshEmojiExplorer/af62a33b35489eb87f3843145ebdf539dab71002/docs/assets/pwshEmojiExplorer_icon.png
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | # pwshEmojiExplorer
2 |
3 | [](https://github.com/PowerShell/PowerShell) [![PowerShell Gallery][psgallery-img]][psgallery-site]  [![License][license-badge]](LICENSE) [](https://pwshemojiexplorer.readthedocs.io/en/latest/?badge=latest)
4 |
5 | [psgallery-img]: https://img.shields.io/powershellgallery/dt/pwshEmojiExplorer?label=Powershell%20Gallery&logo=powershell
6 | [psgallery-site]: https://www.powershellgallery.com/packages/pwshEmojiExplorer
7 | [psgallery-v1]: https://www.powershellgallery.com/packages/pwshEmojiExplorer/0.8.1
8 | [license-badge]: https://img.shields.io/github/license/techthoughts2/pwshEmojiExplorer
9 |
10 | ## What is pwshEmojiExplorer? 🤔
11 |
12 | pwshEmojiExplorer is a PowerShell module designed to enable users to search, discover, and retrieve emojis directly through the command line. Leveraging the extensive Unicode emoji library, the module offers a streamlined approach to exploring and integrating a vast range of emojis into various coding projects.
13 |
14 |
15 |
16 |
17 |
18 | ## Why pwshEmojiExplorer? ❔
19 |
20 | This PowerShell module simplifies the process of finding and using emojis by enabling direct command-line searches. It's not just about bringing emojis into PowerShell scripts; it's about providing a solution for handling emojis in various coding projects. Whether you need the HTMLEntityFormat for a web project, a Unicode representation for a text file, or the hex code for a development task, pwshEmojiExplorer provides this information quickly and efficiently. It's a tool for developers, scripters, and digital creators who seek to incorporate emojis into their work more effectively, enhancing the ease of access and use of emojis in diverse digital contexts.
21 |
22 | ## Getting Started 💻
23 |
24 | ### Installation
25 |
26 | ```powershell
27 | Install-Module -Name 'pwshEmojiExplorer' -Repository PSGallery -Scope CurrentUser
28 | ```
29 |
30 | ### Quick Start
31 |
32 | ```powershell
33 | #-------------------------------------------------------------------------------------
34 | # Import the pwshEmojiExplorer module
35 | Import-Module -Name 'pwshEmojiExplorer'
36 | #-------------------------------------------------------------------------------------
37 | # Get detailed information about a specific emoji by its character
38 | Get-Emoji -Emoji '😀'
39 | #-------------------------------------------------------------------------------------
40 | # Retrieve a list of all emojis within the 'Food & Drink' group
41 | Get-Emoji -Group 'Food & Drink'
42 | #-------------------------------------------------------------------------------------
43 | # Retrieve a list of all emojis within the 'food-vegetable' sub-group
44 | Get-Emoji -SubGroup 'food-vegetable'
45 | #-------------------------------------------------------------------------------------
46 | # Find an emoji based on its shortcode 🥰
47 | Get-Emoji -ShortCode ':smiling_face_with_hearts:'
48 | #-------------------------------------------------------------------------------------
49 | # Get information about an emoji using its hex code, like '1F600' for 😀
50 | Get-Emoji -HexCodePoint '1F600'
51 | #-------------------------------------------------------------------------------------
52 | # Retrieve an emoji by specifying its decimal code point, e.g., 128512 for 😀
53 | Get-Emoji -Decimal 128512
54 | #-------------------------------------------------------------------------------------
55 | # Perform a general search for emojis
56 | Get-Emoji -SearchTerm 'fork'
57 | #-------------------------------------------------------------------------------------
58 | # Retrieve the complete list of available emojis
59 | Get-AllEmoji
60 | #-------------------------------------------------------------------------------------
61 | # Enhance a given text by automatically adding relevant emojis
62 | $sampleText = "I am going to the airport tomorrow to fly on a plane to Spain. Before I take off I'm going to eat some food. I've heard they have good restaurants at the terminal. Hopefully they have something spicy. You know how much I like hot food! I'm so excited to see you! Can't wait to see you! Love you!"
63 | Add-EmojiToText -Text $sampleText
64 | #-------------------------------------------------------------------------------------
65 | ```
66 |
67 | ## How pwshEmojiExplorer Works
68 |
69 | pwshEmojiExplorer uses a cloud-based, event driven workflow to generate a dynamic data set of emoji information based on Public data set from the Unicode Data Files. You can find more detail on the [Emoji Data Set creation component](pwshEmojiExplorer_data_workflow.md) page.
70 |
71 | ## Features
72 |
73 | - **Extensive Emoji Search**: Find emojis by name, category, code point, and more.
74 | - **Emoji Information Retrieval**: Get detailed information about each emoji, including different representations and formats.
75 | - **Text Enhancement**: Automatically enhance texts by adding or replacing words with emojis. Experimental, but perfect for adding a bit of fun to your scripts.
76 | - **Unicode Compliance**: Utilizes the Public data set from the Unicode Data Files, ensuring that you are working with officially recognized emoji standards and variations.
77 | - **Auto-updating**: Actively scans for updates in the Unicode data set and automatically upgrades to the latest published standard. This feature ensures you are aligned with the newest emoji releases and changes in the Unicode standard.
78 |
--------------------------------------------------------------------------------
/docs/pwshEmojiExplorer-Basics.md:
--------------------------------------------------------------------------------
1 | # pwshEmojiExplorer - Basics
2 |
3 | ## Getting Started with pwshEmojiExplorer
4 |
5 | To use pwshEmojiExplorer, you first need to install it from the PowerShell Gallery using the following command:
6 |
7 | ```powershell
8 | Install-Module -Name 'pwshEmojiExplorer' -Repository PSGallery -Scope CurrentUser
9 | ```
10 |
11 | ## Finding Emojis
12 |
13 | pwshEmojiExplorer makes it easy to search and find emojis based on various criteria such as name, group, and more. Here are some common ways to use it:
14 |
15 | ### By Emoji Character
16 |
17 | Find detailed information about a specific emoji by its character.
18 |
19 | ```powershell
20 | Get-Emoji -Emoji '😀'
21 |
22 | Group : Smileys & Emotion
23 | Subgroup : face-smiling
24 | HexCodePoint : 1F600
25 | Name : 😀
26 | Description : grinning face
27 | ShortCode : :grinning_face:
28 | HexCodePointArray : {1F600}
29 | UnicodeStandard : {U+1F600}
30 | pwshEscapedFormat : `u{1F600}
31 | Decimal : {128512}
32 | ```
33 |
34 | ### By Group
35 |
36 | Retrieve all emojis belonging to a specific group like 'Food & Drink'.
37 |
38 | ```powershell
39 | Get-Emoji -Group 'Food & Drink'
40 | ```
41 |
42 | ### By Subgroup
43 |
44 | Focus your emoji search on a specific subgroup.
45 |
46 | ```powershell
47 | Get-Emoji -SubGroup 'food-vegetable'
48 | ```
49 |
50 | ### By Shortcode
51 |
52 | Look for emojis using their shortcode.
53 |
54 | ```powershell
55 | Get-Emoji -ShortCode ':smiling_face_with_hearts:'
56 |
57 | Group : Smileys & Emotion
58 | Subgroup : face-affection
59 | HexCodePoint : 1F970
60 | Name : 🥰
61 | Description : smiling face with hearts
62 | ShortCode : :smiling_face_with_hearts:
63 | HexCodePointArray : {1F970}
64 | UnicodeStandard : {U+1F970}
65 | pwshEscapedFormat : `u{1F970}
66 | Decimal : {129392}
67 | ```
68 |
69 | ### By Hex Code Point
70 |
71 | Use hex code points to find emojis.
72 |
73 | ```powershell
74 | Get-Emoji -HexCodePoint '1F363'
75 |
76 | Group : Food & Drink
77 | Subgroup : food-asian
78 | HexCodePoint : 1F363
79 | Name : 🍣
80 | Description : sushi
81 | ShortCode : :sushi:
82 | HexCodePointArray : {1F363}
83 | UnicodeStandard : {U+1F363}
84 | pwshEscapedFormat : `u{1F363}
85 | Decimal : {127843}
86 | ```
87 |
88 | ### By Decimal
89 |
90 | Decimal code points can also be used for searches.
91 |
92 | ```powershell
93 | Get-Emoji -Decimal 128523
94 |
95 | Group : Smileys & Emotion
96 | Subgroup : face-tongue
97 | HexCodePoint : 1F60B
98 | Name : 😋
99 | Description : face savoring food
100 | ShortCode : :face_savoring_food:
101 | HexCodePointArray : {1F60B}
102 | UnicodeStandard : {U+1F60B}
103 | pwshEscapedFormat : `u{1F60B}
104 | Decimal : {128523}
105 | ```
106 |
107 | ### General Search
108 |
109 | Perform a broader search using a term.
110 |
111 | ```powershell
112 | Get-Emoji -SearchTerm 'fork' | Format-Table
113 |
114 | Name Group Subgroup ShortCode
115 | ---- ----- -------- ---------
116 | 🍽️ Food & Drink dishware :fork_and_knife_with_plate:
117 | 🍴 Food & Drink dishware :fork_and_knife:
118 | ```
119 |
120 | ## Add Emojis to Text
121 |
122 | Enhance your text by automatically adding emojis with the Add-EmojiToText function. This can add a playful or visually engaging element to your messages:
123 | This function scans the text for keywords and appends relevant emojis next to them.
124 |
125 | ```powershell
126 | $sampleText = "I am going to the airport tomorrow to fly on a plane to Spain. Before I take off I'm going to eat some food. I've heard they have good restaurants at the terminal. Hopefully they have something spicy. You know how much I like hot food! I'm so excited to see you! Can't wait to see you! Love you!"
127 | $enhancedText = Add-EmojiToText -Text $sampleText
128 | Write-Output $enhancedText
129 |
130 | I am going to the airport tomorrow to fly 🦋 on a plane ✈️ to Spain. 🇪🇸 Before I take 🥡 off I'm going to eat 😅 some food. 😋 I've 😔 heard 🇭🇲 they have good restaurants at the terminal. Hopefully they have something spicy. You know how much I like hot 🥵 food! 😋 I'm so excited to see 🙈 you! 🤟 Can't wait to see 🙈 you! 🤟 Love 💌 you! 🤟
131 | ```
132 |
133 | ## Getting All Emojis
134 |
135 | To retrieve a comprehensive list of all available emojis, use the Get-AllEmoji function. By default, it returns only 'fully-qualified' emojis:
136 |
137 | ```powershell
138 | Get-AllEmoji
139 | ```
140 |
141 | To include all types of emojis (including 'minimally-qualified' and 'unqualified'), use the `-IncludeAll` switch:
142 |
143 | ```powershell
144 | Get-AllEmoji -IncludeAll
145 | ```
146 |
--------------------------------------------------------------------------------
/docs/pwshEmojiExplorer-FAQ.md:
--------------------------------------------------------------------------------
1 | # pwshEmojiExplorer - FAQ
2 |
3 | ## FAQs
4 |
5 | ### Why would I use this vs just internet searching for an emoji?
6 |
7 | `pwshEmojiExplorer` offers a quicker, more integrated approach for finding and using emojis in your projects. Unlike web searches, it provides immediate, command-line access to a comprehensive set of emoji data, including details like Unicode standards and HTML entity formats, useful for developers and content creators. It streamlines your workflow by allowing programmatic access to emojis and their metadata directly within your PowerShell environment, saving you the time and hassle of manual searching and copying from the web.
8 |
9 | ### How current is the emoji data?
10 |
11 | The emoji data in `pwshEmojiExplorer` is kept up-to-date through a weekly automated scan of the Unicode site for any new emoji version updates. Upon detecting a version update, an automated process is triggered to update the emoji data set on the same day, ensuring that the module always contains the latest emojis and information. For detailed insights into this process, refer to the [Emoji Data Set creation component](pwshEmojiExplorer_data_workflow.md) documentation.
12 |
13 | ### I'm using Windows PowerShell and noticed that some emojis don't display correctly. Why is this happening?
14 |
15 | Windows PowerShell, unlike higher versions of PowerShell, has limited support for Unicode, particularly for characters outside the Basic Multilingual Plane (BMP). This limitation primarily affects emojis composed of surrogate pairs - essentially emojis that are represented by two (or more) Unicode code units.
16 |
17 | In Windows PowerShell, the console technology is based on UCS-2 encoding, which is a precursor to UTF-16. UCS-2 does not fully support characters that require surrogate pairs, leading to incorrect rendering of certain emojis. These are typically the more complex emojis or those added in later Unicode versions.
18 |
19 | While pwshEmojiExplorer functions correctly in Windows PowerShell and can retrieve emoji data, the display of some emojis might not be accurate. This issue does not affect the functionality of the module but is a display limitation in the console.
20 |
21 | For users seeking full emoji support, including accurate rendering of all emojis, consider upgrading to PowerShell (version 6 or newer), which has comprehensive Unicode support and handles all emojis correctly.
22 |
--------------------------------------------------------------------------------
/docs/pwshEmojiExplorer-Metrics.md:
--------------------------------------------------------------------------------
1 | # pwshEmojiExplorer Metrics
2 |
3 | ## Metric Dashboards
4 |
5 | Up-to-date visualizations representing the version of the emoji data set and the frequency of download requests.
6 |
7 |
11 |
--------------------------------------------------------------------------------
/docs/pwshEmojiExplorer.md:
--------------------------------------------------------------------------------
1 | ---
2 | Module Name: pwshEmojiExplorer
3 | Module Guid: 6e4813c7-6f30-42e8-adc4-b3d9b46bce9a
4 | Download Help Link: NA
5 | Help Version: 0.9.0
6 | Locale: en-US
7 | ---
8 |
9 | # pwshEmojiExplorer Module
10 | ## Description
11 | Enables detailed emoji search, discovery, and retrieval. Offers detailed insights on emojis, with multiple search options aligned with the Unicode standard. Provides comprehensive emoji data, including diverse representations and formats, to enhance your scripts and digital communication.
12 |
13 | ## pwshEmojiExplorer Cmdlets
14 | ### [Add-EmojiToText](Add-EmojiToText.md)
15 | Enhances text by adding emojis based on key words.
16 |
17 | ### [Get-AllEmoji](Get-AllEmoji.md)
18 | Retrieves all emojis.
19 |
20 | ### [Get-Emoji](Get-Emoji.md)
21 | Retrieves a specific emoji or a list of emojis based on various search criteria.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/pwshEmojiExplorer_data_workflow.md:
--------------------------------------------------------------------------------
1 | # pwshEmojiExplorer - Emoji Data Set creation component
2 |
3 | ## Synopsis
4 |
5 | pwshEmojiExplorer uses a cloud-based, event driven workflow to generate a dynamic data set of emojis based on Public data set from the Unicode Data Files.
6 |
7 | This workflow continuously checks for emoji version updates for Unicode and automatically updates the emoji data set used by pwshEmojiExplorer.
8 |
9 | You can check out [pwshEmojiExplorer Metrics](pwshEmojiExplorer-Metrics.md) for metric insights into this process.
10 |
11 | ## Unicode Data Files Terms of Use
12 |
13 | pwshEmojiExplorer uses the Public data set from the Unicode Data Files and adheres to the Unicode Terms of Use:
14 |
15 | - [Unicode® Copyright and Terms of Use](https://www.unicode.org/copyright.html)
16 | - [UNICODE LICENSE V3](https://www.unicode.org/license.txt)
17 |
18 | ## Design Diagram
19 |
20 | 
21 |
--------------------------------------------------------------------------------
/docs/requirements.txt:
--------------------------------------------------------------------------------
1 | # https://github.com/readthedocs-examples/example-mkdocs-basic/blob/main/docs/requirements.txt
2 | # requirements.txt
3 | jinja2==3.1.4 #https://pypi.org/project/Jinja2/
4 | mkdocs>=1.6.0 #https://github.com/mkdocs/mkdocs
5 | mkdocs-material==9.5.25 #https://github.com/squidfunk/mkdocs-material
6 | pygments>=2.18.0 #https://pypi.org/project/Pygments/
7 | # mdx_truly_sane_lists
8 |
--------------------------------------------------------------------------------
/lambdafunctions/PowerShell/pwshEEUnicodeVersionMonitor/pwshEEUnicodeVersionMonitor.build.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | An Invoke-Build Build file for an AWS PowerShell Lambda Function
4 |
5 | .DESCRIPTION
6 | This build file is configured for AWS CodeBuild builds, but will work locally as well.
7 |
8 | Build steps can include:
9 | - InstallDependencies
10 | - Clean
11 | - Analyze
12 | - Test
13 | - Build
14 | - Archive
15 |
16 | The default build will not call the 'InstallDependencies' task, but can be used if you want PSDepend
17 | to install pre-requisite modules. "Invoke-Build -Task InstallDependencies"
18 |
19 | This build will pull in configurations from the ".Settings.ps1" file as well, where users can
20 | more easily customize the build process if required.
21 |
22 | .EXAMPLE
23 | Invoke-Build
24 |
25 | This will perform the default build tasks: Clean, Analyze, Test, Build, Archive
26 |
27 | .EXAMPLE
28 | Invoke-Build -Task Analyze,Test
29 |
30 | This will perform only the Analyze and Test tasks.
31 | #>
32 |
33 | # Include: Settings
34 | $ScriptName = (Split-Path -Path $BuildFile -Leaf).Split('.')[0]
35 | . "./$ScriptName.settings.ps1"
36 |
37 | # Default Build
38 | task . Clean, ImportModules, Analyze, Build, Publish
39 |
40 | # Pre-build variables to configure
41 | Enter-Build {
42 | $script:LambdaName = (Split-Path -Path $BuildFile -Leaf).Split('.')[0]
43 |
44 | # Identify other required paths
45 | $script:LambdaSourcePath = $BuildRoot
46 | $script:LambdaScriptPath = Join-Path -Path $script:LambdaSourcePath -ChildPath "$ScriptName.ps1"
47 | $script:ArtifactsPath = Join-Path -Path $BuildRoot -ChildPath 'Artifacts'
48 | $script:ArtifactPackage = Join-Path -Path $script:ArtifactsPath -ChildPath "$ScriptName.zip"
49 | $script:PowerShellLambdaPath = Split-Path -Path $script:LambdaSourcePath
50 | $script:StagingPath = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath 'LambdaStaging'
51 |
52 | if ([String]::IsNullOrWhiteSpace($env:CODEBUILD_SRC_DIR)) {
53 | $script:LambdaFunctionsPath = Split-Path -Path $script:PowerShellLambdaPath
54 | $script:CodeBuildRoot = Split-Path -Path $script:LambdaFunctionsPath
55 | }
56 | else {
57 | $script:CodeBuildRoot = $env:CODEBUILD_SRC_DIR
58 | }
59 | $script:ModulesRoot = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath 'Modules'
60 | $script:CFNParameterFilePath = Join-Path -Path $script:CodeBuildRoot -ChildPath 'cloudformation'
61 |
62 | if (-not(Test-Path -Path $script:CFNParameterFilePath)) {
63 | throw ('Unable to find the cloudformation Path: {0}' -f $script:CFNParameterFilePath)
64 | }
65 | }
66 |
67 | # Synopsis: Imports PowerShell Modules
68 | task ImportModules {
69 | Write-Host 'Importing PowerShell Modules'
70 |
71 | $manifests = Get-ChildItem -Path $script:ModulesRoot -Recurse -Filter "*.psd1"
72 | foreach ($manifest in $manifests) {
73 | if (Get-Module -Name $manifest.BaseName) {
74 | Remove-Module -Name $manifest.BaseName
75 | }
76 |
77 | Write-Host ' -' $manifest.BaseName
78 | Import-Module $manifest.FullName -Force -Verbose:$false
79 | }
80 | }
81 |
82 | # Synopsis: Clean Artifacts Directory
83 | task Clean {
84 | foreach ($path in $script:ArtifactsPath, $script:StagingPath) {
85 | if (Test-Path -Path $path) {
86 | $null = Remove-Item -Path $path -Recurse -Force
87 | }
88 |
89 | $null = New-Item -ItemType Directory -Path $path -Force
90 | }
91 | }
92 |
93 | # Synopsis: Invokes Script Analyzer against the Module source path
94 | task Analyze {
95 | $scriptAnalyzerParams = @{
96 | Path = $script:LambdaScriptPath
97 | Severity = @('Error', 'Warning')
98 | Recurse = $true
99 | ExcludeRule = @('PSAvoidUsingWriteHost', 'PSUseShouldProcessForStateChangingFunctions')
100 | Verbose = $false
101 | }
102 |
103 | $scriptAnalyzerResults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
104 |
105 | if ($scriptAnalyzerResults) {
106 | $scriptAnalyzerResults | Format-Table
107 | throw 'One or more PSScriptAnalyzer errors/warnings where found.'
108 | }
109 | }
110 |
111 | # Synopsis: Builds the Module to the Artifacts folder
112 | task Build {
113 | Write-Verbose -Message 'Compiling the AWS Lambda Package'
114 | $script:LambdaPackage = New-AWSPowerShellLambdaPackage -ScriptPath $script:LambdaScriptPath -StagingDirectory $script:StagingPath -OutputPackage $script:ArtifactPackage -Verbose
115 | Write-Host 'AWS Lambda Function Handler:' $script:LambdaPackage.LambdaHandler
116 | Write-Host 'PowerShell Function Handler Environment Variable Name:' $script:LambdaPackage.PowerShellFunctionHandlerEnvVar
117 | }
118 |
119 | task Publish {
120 | if ([String]::IsNullOrWhiteSpace($env:CODEBUILD_SRC_DIR) -and [String]::IsNullOrWhiteSpace($env:CODEBUILD_RESOLVED_SOURCE_VERSION)) {
121 | Write-Warning -Message 'Not publishing the artifact because the code is not running inside a CodeBuild Project'
122 | }
123 | else {
124 | 'Publishing Lambda Function to S3'
125 |
126 | $s3Key = '{0}/{1}/lambdafunctions/PowerShell/{2}.zip' -f $env:S3_KEY_PREFIX, $env:CODEBUILD_RESOLVED_SOURCE_VERSION, $ScriptName
127 | ' - S3Key:/{0}/{1}' -f $env:ARTIFACT_S3_BUCKET, $s3Key
128 |
129 | Write-S3Object -BucketName $env:ARTIFACT_S3_BUCKET -Key $s3Key -File $script:ArtifactPackage
130 |
131 | # Update json parameter files
132 | $cfnLambdaS3KeyParameterName = 'LMFunctionS3Key{0}' -f $ScriptName
133 | Write-Verbose -Message "JSON Parameter Name for cloudformation S3 Key: $cfnLambdaS3KeyParameterName" -Verbose
134 |
135 | $cfnLambdaHandlerParameterName = 'LMFunctionHandler{0}' -f $ScriptName
136 | Write-Verbose -Message "JSON Parameter Name for Lambda Function Handler: $cfnLambdaHandlerParameterName" -Verbose
137 |
138 | $jsonFiles = Get-ChildItem -Path $script:CFNParameterFilePath -Recurse -Filter "*.json"
139 | foreach ($jsonFile in $jsonFiles) {
140 | 'Processing {0}' -f $jsonFile.Name
141 | $jsonData = Get-Content -Path $jsonFile.FullName -Raw | ConvertFrom-Json
142 |
143 | # Update cfnLambdaS3KeyParameterName in json parameters
144 | try {
145 | $jsonData.Parameters.$cfnLambdaS3KeyParameterName = $s3Key
146 | ' - Updated the json parameter "{0}" with "{1}".' -f $cfnLambdaS3KeyParameterName, $s3Key
147 | }
148 | catch {
149 | ' - Unable to find the json parameter "{0}". No modifications being made.' -f $cfnLambdaS3KeyParameterName
150 | }
151 |
152 | # Update cfnLambdaHandlerParameterName in json parameters
153 | try {
154 | $jsonData.Parameters.$cfnLambdaHandlerParameterName = $script:LambdaPackage.LambdaHandler
155 | ' - Updated the json parameter "{0}" with "{1}".' -f $cfnLambdaHandlerParameterName, $script:LambdaPackage.LambdaHandler
156 | }
157 | catch {
158 | ' - Unable to find the json parameter "{0}". No modifications being made.' -f $cfnLambdaHandlerParameterName
159 | }
160 |
161 | # Export the json back to disk
162 | $jsonData | ConvertTo-Json | Out-File -FilePath $jsonFile.FullName -Force -Encoding utf8
163 | }
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/lambdafunctions/PowerShell/pwshEEUnicodeVersionMonitor/pwshEEUnicodeVersionMonitor.settings.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Use this for custom modifications to the build process if needed.
4 | #>
5 |
6 | ###############################################################################
7 | # Before/After Hooks for the Core Task: Clean
8 | ###############################################################################
9 |
10 | # Synopsis: Executes before the Clean task.
11 | #task BeforeClean -Before Clean {}
12 |
13 | # Synopsis: Executes after the Clean task.
14 | #task AfterClean -After Clean {}
15 |
16 | ###############################################################################
17 | # Before/After Hooks for the Core Task: Analyze
18 | ###############################################################################
19 |
20 | # Synopsis: Executes before the Analyze task.
21 | #task BeforeAnalyze -Before Analyze {}
22 |
23 | # Synopsis: Executes after the Analyze task.
24 | #task AfterAnalyze -After Analyze {}
25 |
26 | ###############################################################################
27 | # Before/After Hooks for the Core Task: Archive
28 | ###############################################################################
29 |
30 | # Synopsis: Executes before the Archive task.
31 | #task BeforeArchive -Before Archive {}
32 |
33 | # Synopsis: Executes after the Archive task.
34 | #task AfterArchive -After Archive {}
35 |
36 | ###############################################################################
37 | # Before/After Hooks for the Core Task: Build
38 | ###############################################################################
39 |
40 | # Synopsis: Executes before the Build task.
41 | #task BeforeBuild -Before Build {}
42 |
43 | # Synopsis: Executes after the Build task.
44 | #task AfterBuild -After Build {}
45 |
46 | ###############################################################################
47 | # Before/After Hooks for the Core Task: Test
48 | ###############################################################################
49 |
50 | # Synopsis: Executes before the Test Task.
51 | #task BeforeTest -Before Test {}
52 |
53 | # Synopsis: Executes after the Test Task.
54 | #task AfterTest -After Test {}
55 |
--------------------------------------------------------------------------------
/mkdocs.yml:
--------------------------------------------------------------------------------
1 | # https://www.mkdocs.org/user-guide/configuration/
2 | # https://www.mkdocs.org/user-guide/writing-your-docs/
3 | # https://www.mkdocs.org/user-guide/writing-your-docs/#writing-with-markdown
4 | # https://mkdocs.readthedocs.io/en/0.15.2/user-guide/writing-your-docs/
5 | # https://mkdocs.readthedocs.io/en/0.15.2/user-guide/styling-your-docs/
6 | # https://example-mkdocs-basic.readthedocs.io/en/latest/
7 | # https://github.com/mkdocs/mkdocs/blob/master/mkdocs.yml
8 | # https://squidfunk.github.io/mkdocs-material/creating-your-site/
9 | # mkdocs.yml
10 |
11 | site_name: pwshEmojiExplorer
12 | # site_url:
13 | repo_url: https://github.com/techthoughts2/pwshEmojiExplorer
14 | # repo_name:
15 | # edit_uri: edit/main/docs/
16 | # edit_uri_template:
17 | site_description: Explore the latest Unicode emojis directly in PowerShell with pwshEmojiExplorer. Search, retrieve, and integrate emojis into scripts and projects using this PowerShell module command-line toolkit. # meta tag to the generated HTML header
18 | site_author: Jake Morrison # meta tag to the generated HTML header
19 | copyright: "pwshEmojiExplorer is licensed under the MIT license"
20 | # remote_branch:
21 | # remote_name:
22 | # docs_dir: docs
23 | # site_dir:
24 | # extra_css:
25 | # extra_javascript:
26 | # markdown_extensions:
27 | # Python Markdown
28 | # - admonition
29 | # - toc:
30 | # permalink: true
31 | # code highlighting
32 | # - pymdownx.highlight:
33 | # use_pygments: true
34 | # - pymdownx.highlight:
35 | # anchor_linenums: true
36 | # - pymdownx.inlinehilite
37 | # - pymdownx.snippets
38 | # - pymdownx.superfences
39 |
40 | # extra_templates:
41 | # extra:
42 | theme:
43 | name: material
44 | language: en
45 | # custom_dir: overrides
46 | features:
47 | # - navigation.tabs
48 | # - navigation.tabs.sticky
49 | # - navigation.path
50 | favicon: assets/pwshEmojiExplorer_favicon_32x32.png
51 | # icon:
52 | # repo:
53 | # font:
54 | # text: Work Sans
55 | logo: assets/pwshEmojiExplorer_icon.png
56 | # palette:
57 | # primary: teal
58 | # palette:
59 | # # Palette toggle for light mode
60 | # - media: "(prefers-color-scheme: light)"
61 | # scheme: default
62 | # primary: light blue
63 | # accent: pink
64 | # toggle:
65 | # icon: material/brightness-7
66 | # name: Switch to dark mode
67 |
68 | # # Palette toggle for dark mode
69 | # - media: "(prefers-color-scheme: dark)"
70 | # scheme: slate
71 | # primary: indigo
72 | # accent: pink
73 | # toggle:
74 | # icon: material/brightness-4
75 | # name: Switch to light mode
76 | nav:
77 | - Home: index.md
78 | - Usage:
79 | - pwshEmojiExplorer Basics: pwshEmojiExplorer-Basics.md
80 | - Functions:
81 | - Add-EmojiToText: Add-EmojiToText.md
82 | - Get-AllEmoji: Get-AllEmoji.md
83 | - Get-Emoji: Get-Emoji.md
84 | - Metrics: pwshEmojiExplorer-Metrics.md
85 | - FAQ: pwshEmojiExplorer-FAQ.md
86 | - Data Set Creation: pwshEmojiExplorer_data_workflow.md
87 | - Change Log: CHANGELOG.md
88 |
--------------------------------------------------------------------------------
/src/MarkdownRepair.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Repair PlatyPS generated markdown files.
4 | .NOTES
5 | This file is temporarily required to handle platyPS help generation.
6 | https://github.com/PowerShell/platyPS/issues/595
7 | This is a result of a breaking change introduced in PowerShell 7.4.0:
8 | https://learn.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-74?view=powershell-7.4
9 | Breaking Changes: Added the ProgressAction parameter to the Common Parameters
10 | modified from source: https://github.com/PowerShell/platyPS/issues/595#issuecomment-1820971702
11 | #>
12 |
13 | function Remove-CommonParameterFromMarkdown {
14 | <#
15 | .SYNOPSIS
16 | Remove a PlatyPS generated parameter block.
17 | .DESCRIPTION
18 | Removes parameter block for the provided parameter name from the markdown file provided.
19 | #>
20 | param(
21 | [Parameter(Mandatory)]
22 | [string[]]
23 | $Path,
24 |
25 | [Parameter(Mandatory = $false)]
26 | [string[]]
27 | $ParameterName = @('ProgressAction')
28 | )
29 | $ErrorActionPreference = 'Stop'
30 | foreach ($p in $Path) {
31 | $content = (Get-Content -Path $p -Raw).TrimEnd()
32 | $updateFile = $false
33 | foreach ($param in $ParameterName) {
34 | if (-not ($Param.StartsWith('-'))) {
35 | $param = "-$($param)"
36 | }
37 | # Remove the parameter block
38 | $pattern = "(?m)^### $param\r?\n[\S\s]*?(?=#{2,3}?)"
39 | $newContent = $content -replace $pattern, ''
40 | # Remove the parameter from the syntax block
41 | $pattern = " \[$param\s?.*?]"
42 | $newContent = $newContent -replace $pattern, ''
43 | if ($null -ne (Compare-Object -ReferenceObject $content -DifferenceObject $newContent)) {
44 | Write-Verbose "Added $param to $p"
45 | # Update file content
46 | $content = $newContent
47 | $updateFile = $true
48 | }
49 | }
50 | # Save file if content has changed
51 | if ($updateFile) {
52 | $newContent | Out-File -Encoding utf8 -FilePath $p
53 | Write-Verbose "Updated file: $p"
54 | }
55 | }
56 | return
57 | }
58 |
59 | function Add-MissingCommonParameterToMarkdown {
60 | param(
61 | [Parameter(Mandatory)]
62 | [string[]]
63 | $Path,
64 |
65 | [Parameter(Mandatory = $false)]
66 | [string[]]
67 | $ParameterName = @('ProgressAction')
68 | )
69 | $ErrorActionPreference = 'Stop'
70 | foreach ($p in $Path) {
71 | $content = (Get-Content -Path $p -Raw).TrimEnd()
72 | $updateFile = $false
73 | foreach ($NewParameter in $ParameterName) {
74 | if (-not ($NewParameter.StartsWith('-'))) {
75 | $NewParameter = "-$($NewParameter)"
76 | }
77 | $pattern = '(?m)^This cmdlet supports the common parameters:(.+?)\.'
78 | $replacement = {
79 | $Params = $_.Groups[1].Captures[0].ToString() -split ' '
80 | $CommonParameters = @()
81 | foreach ($CommonParameter in $Params) {
82 | if ($CommonParameter.StartsWith('-')) {
83 | if ($CommonParameter.EndsWith(',')) {
84 | $CleanParam = $CommonParameter.Substring(0, $CommonParameter.Length - 1)
85 | }
86 | elseif ($p.EndsWith('.')) {
87 | $CleanParam = $CommonParameter.Substring(0, $CommonParameter.Length - 1)
88 | }
89 | else {
90 | $CleanParam = $CommonParameter
91 | }
92 | $CommonParameters += $CleanParam
93 | }
94 | }
95 | if ($NewParameter -notin $CommonParameters) {
96 | $CommonParameters += $NewParameter
97 | }
98 | $CommonParameters[-1] = "and $($CommonParameters[-1]). "
99 | return "This cmdlet supports the common parameters: " + (($CommonParameters | Sort-Object) -join ', ')
100 | }
101 | $newContent = $content -replace $pattern, $replacement
102 | if ($null -ne (Compare-Object -ReferenceObject $content -DifferenceObject $newContent)) {
103 | Write-Verbose "Added $NewParameter to $p"
104 | $updateFile = $true
105 | $content = $newContent
106 | }
107 | }
108 | # Save file if content has changed
109 | if ($updateFile) {
110 | $newContent | Out-File -Encoding utf8 -FilePath $p
111 | Write-Verbose "Updated file: $p"
112 | }
113 | }
114 | return
115 | }
116 |
117 | function Repair-PlatyPSMarkdown {
118 | param(
119 | [Parameter(Mandatory)]
120 | [string[]]
121 | $Path,
122 |
123 | [Parameter()]
124 | [string[]]
125 | $ParameterName = @('ProgressAction')
126 | )
127 | $ErrorActionPreference = 'Stop'
128 | $Parameters = @{
129 | Path = $Path
130 | ParameterName = $ParameterName
131 | }
132 | $null = Remove-CommonParameterFromMarkdown @Parameters
133 | $null = Add-MissingCommonParameterToMarkdown @Parameters
134 | return
135 | }
136 |
--------------------------------------------------------------------------------
/src/PSScriptAnalyzerSettings.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | #________________________________________
3 | #IncludeDefaultRules
4 | IncludeDefaultRules = $true
5 | #________________________________________
6 | #Severity
7 | #Specify Severity when you want to limit generated diagnostic records to a specific subset: [ Error | Warning | Information ]
8 | Severity = @('Error', 'Warning')
9 | #________________________________________
10 | #CustomRulePath
11 | #Specify CustomRulePath when you have a large set of custom rules you'd like to reference
12 | #CustomRulePath = "Module\InjectionHunter\1.0.0\InjectionHunter.psd1"
13 | #________________________________________
14 | #IncludeRules
15 | #Specify IncludeRules when you only want to run specific subset of rules instead of the default rule set.
16 | #IncludeRules = @('PSShouldProcess',
17 | # 'PSUseApprovedVerbs')
18 | #________________________________________
19 | #ExcludeRules
20 | #Specify ExcludeRules when you want to exclude a certain rule from the the default set of rules.
21 | #ExcludeRules = @(
22 | # 'PSUseDeclaredVarsMoreThanAssignments'
23 | #)
24 | #________________________________________
25 | #Rules
26 | #Here you can specify customizations for particular rules. Several examples are included below:
27 | #Rules = @{
28 | # PSUseCompatibleCmdlets = @{
29 | # compatibility = @('core-6.1.0-windows', 'desktop-4.0-windows')
30 | # }
31 | # PSUseCompatibleSyntax = @{
32 | # Enable = $true
33 | # TargetVersions = @(
34 | # '3.0',
35 | # '5.1',
36 | # '6.2'
37 | # )
38 | # }
39 | # PSUseCompatibleCommands = @{
40 | # Enable = $true
41 | # TargetProfiles = @(
42 | # 'win-8_x64_10.0.14393.0_6.1.3_x64_4.0.30319.42000_core', # PS 6.1 on WinServer-2019
43 | # 'win-8_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework', # PS 5.1 on WinServer-2019
44 | # 'win-8_x64_6.2.9200.0_3.0_x64_4.0.30319.42000_framework' # PS 3 on WinServer-2012
45 | # )
46 | # }
47 | # PSUseCompatibleTypes = @{
48 | # Enable = $true
49 | # TargetProfiles = @(
50 | # 'ubuntu_x64_18.04_6.1.3_x64_4.0.30319.42000_core',
51 | # 'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework'
52 | # )
53 | # # You can specify types to not check like this, which will also ignore methods and members on it:
54 | # IgnoreTypes = @(
55 | # 'System.IO.Compression.ZipFile'
56 | # )
57 | # }
58 | #}
59 | #________________________________________
60 | }
61 |
--------------------------------------------------------------------------------
/src/Tests/Unit/ExportedFunctions.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..\', '..\', $ModuleName, "$ModuleName.psd1")
5 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
6 | Import-Module $PathToManifest -Force
7 | $manifestContent = Test-ModuleManifest -Path $PathToManifest
8 | $moduleExported = Get-Command -Module $ModuleName | Select-Object -ExpandProperty Name
9 | $manifestExported = ($manifestContent.ExportedFunctions).Keys
10 | }
11 | BeforeDiscovery {
12 | Set-Location -Path $PSScriptRoot
13 | $ModuleName = 'pwshEmojiExplorer'
14 | $PathToManifest = [System.IO.Path]::Combine('..\', '..\', $ModuleName, "$ModuleName.psd1")
15 | $manifestContent = Test-ModuleManifest -Path $PathToManifest
16 | $moduleExported = Get-Command -Module $ModuleName | Select-Object -ExpandProperty Name
17 | $manifestExported = ($manifestContent.ExportedFunctions).Keys
18 | }
19 |
20 | Describe $ModuleName {
21 |
22 | Context 'Exported Commands' -Fixture {
23 |
24 | Context 'Number of commands' -Fixture {
25 | It -Name 'Exports the same number of public functions as what is listed in the Module Manifest' -Test {
26 | $manifestExported.Count | Should -BeExactly $moduleExported.Count
27 | }
28 | }
29 |
30 | Context 'Explicitly exported commands' -ForEach $moduleExported {
31 | foreach ($command in $moduleExported) {
32 | BeforeAll {
33 | $command = $_
34 | }
35 | It -Name "Includes the $command in the Module Manifest ExportedFunctions" -Test {
36 | $manifestExported -contains $command | Should -BeTrue
37 | }
38 | }
39 | }
40 | }
41 |
42 | Context 'Command Help' -ForEach $moduleExported {
43 | foreach ($command in $moduleExported) {
44 | BeforeAll {
45 | $help = Get-Help -Name $_ -Full
46 | }
47 | Context $command -Fixture {
48 | $help = Get-Help -Name $command -Full
49 |
50 | It -Name 'Includes a Synopsis' -Test {
51 | $help.Synopsis | Should -Not -BeNullOrEmpty
52 | }
53 |
54 | It -Name 'Includes a Description' -Test {
55 | $help.description.Text | Should -Not -BeNullOrEmpty
56 | }
57 |
58 | It -Name 'Includes an Example' -Test {
59 | $help.examples.example | Should -Not -BeNullOrEmpty
60 | }
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Private/Confirm-DataLocation.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Confirm-DataLocation' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 | } #before_all
17 |
18 | BeforeEach {
19 | Mock -CommandName Test-Path -MockWith {
20 | $true
21 | } #endMock
22 | Mock -CommandName New-Item -MockWith { } #endMock
23 | } #before_each
24 |
25 | Context 'Error' {
26 |
27 | It 'should return false if an error is encountered with Test-Path' {
28 | Mock -CommandName Test-Path -MockWith {
29 | throw 'FakeError'
30 | } #endMock
31 | Confirm-DataLocation | Should -BeExactly $false
32 | } #it
33 |
34 | It 'should return false if an error is encountered with New-Item' {
35 | Mock -CommandName Test-Path -MockWith {
36 | $false
37 | } #endMock
38 | Mock -CommandName New-Item -MockWith {
39 | throw 'FakeError'
40 | } #endMock
41 | Confirm-DataLocation | Should -BeExactly $false
42 | } #it
43 |
44 | } #context_Error
45 |
46 | Context 'Success' {
47 |
48 | It 'should return true if the output dir already exists' {
49 | Confirm-DataLocation | Should -BeExactly $true
50 | } #it
51 |
52 | It 'should return true if the output dir does not exists and is created' {
53 | Mock -CommandName Test-Path -MockWith {
54 | $false
55 | } #endMock
56 | Confirm-DataLocation | Should -BeExactly $true
57 | } #it
58 |
59 | } #context_Success
60 |
61 | } #describe_Confirm-DataLocation
62 |
63 | } #inModule
64 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Private/Confirm-MetadataUpdate.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Confirm-MetadataUpdate' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 | $metadataJSON = @'
17 | {
18 | "version": "15.1"
19 | }
20 | '@
21 | $metadataJSON2 = @'
22 | {
23 | "version": "15.2"
24 | }
25 | '@
26 | function Remove-Item {
27 | }
28 | } #before_all
29 |
30 | BeforeEach {
31 | Mock -CommandName Test-Path -MockWith {
32 | $true
33 | } #endMock
34 | Mock -CommandName Get-Content -MockWith {
35 | $metadataJSON
36 | } #endMock
37 | Mock -CommandName Remove-Item -MockWith {}
38 | Mock -CommandName Get-RemoteFile -MockWith {
39 | $true
40 | } #endMock
41 | } #before_each
42 |
43 | Context 'Error' {
44 |
45 | It 'should return false if an error is encountered with Test-Path' {
46 | Mock -CommandName Test-Path -MockWith {
47 | throw 'FakeError'
48 | } #endMock
49 | Confirm-MetadataUpdate | Should -BeExactly $false
50 | } #it
51 |
52 | It 'should return false if an error is encountered with Get-Content' {
53 | Mock -CommandName Get-Content -MockWith {
54 | throw 'FakeError'
55 | } #endMock
56 | Confirm-MetadataUpdate | Should -BeExactly $false
57 | } #it
58 |
59 | It 'should return false if the metadata file is not downloaded' {
60 | Mock -CommandName Get-RemoteFile -MockWith {
61 | $false
62 | } #endMock
63 | Confirm-MetadataUpdate | Should -BeExactly $false
64 | } #it
65 |
66 | It 'should return false if an error is encountered with second Get-Content' {
67 | $script:mockCalled = 0
68 | $mockInvoke = {
69 | $script:mockCalled++
70 | if ($script:mockCalled -eq 1) {
71 | return $metadataJSON
72 | }
73 | elseif ($script:mockCalled -eq 2) {
74 | throw 'FakeError'
75 | }
76 | }
77 | Mock -CommandName Get-Content -MockWith $mockInvoke
78 | Confirm-MetadataUpdate | Should -BeExactly $false
79 | } #it
80 |
81 | } #context_Error
82 |
83 | Context 'Success' {
84 |
85 | It 'should return false if the metadata file is not found' {
86 | Mock -CommandName Test-Path -MockWith {
87 | $false
88 | } #endMock
89 | Confirm-MetadataUpdate | Should -BeExactly $false
90 | } #it
91 |
92 | It 'should return true if the local and remote metadata files are the same' {
93 | Confirm-MetadataUpdate | Should -BeExactly $true
94 | } #it
95 |
96 | It 'should return false if the local and remote metadata files are different' {
97 | $script:mockCalled = 0
98 | $mockInvoke = {
99 | $script:mockCalled++
100 | if ($script:mockCalled -eq 1) {
101 | return $metadataJSON
102 | }
103 | elseif ($script:mockCalled -eq 2) {
104 | return $metadataJSON2
105 | }
106 | }
107 | Mock -CommandName Get-Content -MockWith $mockInvoke
108 | Confirm-MetadataUpdate | Should -BeExactly $false
109 | } #it
110 |
111 | } #context_Success
112 |
113 | } #describe_Confirm-MetadataUpdate
114 |
115 | } #inModule
116 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Private/Confirm-XMLDataSet.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Confirm-XMLDataSet' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 | } #before_all
17 |
18 | BeforeEach {
19 | Mock -CommandName Test-Path -MockWith {
20 | $true
21 | } #endMock
22 | Mock -CommandName Get-Item -MockWith {
23 | [PSCustomObject]@{
24 | Name = 'AzModI.xml'
25 | CreationTime = [datetime]'01/06/20 21:17:21'
26 | CreationTimeUtc = [datetime]'01/07/20 05:17:21'
27 | LastAccessTime = [datetime]'01/06/20 21:17:22'
28 | LastWriteTime = [datetime]'01/06/20 21:17:21'
29 | }
30 | } #endMock
31 | Mock -CommandName Get-Date -MockWith {
32 | [datetime]'01/06/20 21:17:22'
33 | } #endMock
34 | Mock -CommandName Confirm-MetadataUpdate -MockWith {
35 | $true
36 | } #endMock
37 | } #before_each
38 |
39 | Context 'Error' {
40 |
41 | It 'should return false if an error is encountered with Test-Path' {
42 | Mock -CommandName Test-Path -MockWith {
43 | throw 'FakeError'
44 | } #endMock
45 | Confirm-XMLDataSet | Should -BeExactly $false
46 | } #it
47 |
48 | It 'should return false if an error is encountered with Get-Item' {
49 | Mock -CommandName Get-Item -MockWith {
50 | throw 'FakeError'
51 | } #endMock
52 | Confirm-XMLDataSet | Should -BeExactly $false
53 | } #it
54 |
55 | It 'should return null false if no file information is returned from Get-Item' {
56 | Mock -CommandName Get-Item -MockWith { } #endMock
57 | Confirm-XMLDataSet | Should -BeExactly $false
58 | } #it
59 |
60 | } #context_Error
61 |
62 | Context 'Success' {
63 |
64 | It 'should return false if the data file is not found' {
65 | Mock -CommandName Test-Path -MockWith {
66 | $false
67 | } #endMock
68 | Confirm-XMLDataSet | Should -BeExactly $false
69 | } #it
70 |
71 | It 'should return true if the file is found and is less than 9 days old' {
72 | Confirm-XMLDataSet | Should -BeExactly $true
73 | } #it
74 |
75 | It 'should return true if the data file is older than 9 days but the metadata file is current' {
76 | Mock -CommandName Get-Date -MockWith {
77 | [datetime]'1/16/20 21:17:22'
78 | } #endMock
79 | Confirm-XMLDataSet | Should -BeExactly $true
80 | } #it
81 |
82 | It 'should return false if the data file is older than 9 days and the metadata file is also out of date' {
83 | Mock -CommandName Get-Date -MockWith {
84 | [datetime]'1/16/20 21:17:22'
85 | } #endMock
86 | Mock -CommandName Confirm-MetadataUpdate -MockWith {
87 | $false
88 | } #endMock
89 | Confirm-XMLDataSet | Should -BeExactly $false
90 | } #it
91 |
92 | It 'should check the metadata file if the data file is greater than 9 days old' {
93 | Mock -CommandName Get-Date -MockWith {
94 | [datetime]'1/16/20 21:17:22'
95 | } #endMock
96 | Confirm-XMLDataSet
97 | Should -Invoke -CommandName Confirm-MetadataUpdate -Exactly 1
98 | } #it
99 |
100 | } #context_Success
101 |
102 | } #describe_Confirm-XMLDataSet
103 |
104 | } #inModule
105 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Private/Convert-EmojiToHexCodePoint.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Convert-EmojiToHexCodePoint' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 | } #before_all
17 |
18 | BeforeEach {
19 |
20 | } #before_each
21 |
22 | # Context 'Error' {
23 |
24 | # } #context_Error
25 |
26 | Context 'Success' {
27 |
28 | It 'should return the expected object type' {
29 | # https://github.com/pester/Pester/issues/1315
30 | Convert-EmojiToHexCodePoint -Emoji '😀' | Should -BeOfType [System.String]
31 | } #it
32 |
33 | It 'should return the expected values' {
34 | $emoji = Convert-EmojiToHexCodePoint -Emoji '😀'
35 | $emoji | Should -BeExactly '1F600'
36 | } #it
37 |
38 | } #context_Success
39 |
40 | } #describe_Convert-EmojiToHexCodePoint
41 |
42 | } #inModule
43 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Private/ConvertTo-PSEmoji.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'ConvertTo-PSEmoji' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 |
17 | . $PSScriptRoot\..\..\asset\emojiTestData.ps1
18 | } #before_all
19 |
20 | BeforeEach {
21 |
22 | } #before_each
23 |
24 | Context 'Error' {
25 |
26 | It 'should not throw an error if the custom object is malformed' {
27 | { ConvertTo-PSEmoji -CustomObject $badCustomObject } | Should -Not -Throw
28 | } #it
29 |
30 | It 'shoulld have null values if the custom object is malformed' {
31 | $emoji = ConvertTo-PSEmoji -CustomObject $badCustomObject
32 | $emoji.Group | Should -BeNullOrEmpty
33 | $emoji.Subgroup | Should -BeNullOrEmpty
34 | $emoji.HexCodePoint | Should -BeNullOrEmpty
35 | $emoji.Status | Should -BeNullOrEmpty
36 | $emoji.Name | Should -BeNullOrEmpty
37 | $emoji.Version | Should -BeNullOrEmpty
38 | $emoji.Description | Should -BeNullOrEmpty
39 | $emoji.ShortCode | Should -BeNullOrEmpty
40 | $emoji.HexCodePointArray | Should -BeNullOrEmpty
41 | $emoji.UnicodeStandard | Should -BeNullOrEmpty
42 | $emoji.HTMLEntityFormat | Should -BeNullOrEmpty
43 | $emoji.pwshEscapedFormat | Should -BeNullOrEmpty
44 | $emoji.Decimal | Should -BeNullOrEmpty
45 | } #it
46 |
47 | It 'should throw an error if the custom object is not the expected type' {
48 | { ConvertTo-PSEmoji -CustomObject $badDataTypeCustomObject } | Should -Throw
49 | } #it
50 |
51 | } #context_Error
52 |
53 | Context 'Success' {
54 |
55 | It 'should return the expected object type' {
56 | # https://github.com/pester/Pester/issues/1315
57 | (ConvertTo-PSEmoji -CustomObject $customObject).GetType().Name | Should -Be 'PSEmoji'
58 | } #it
59 |
60 | It 'should return the expected values' {
61 | $emoji = ConvertTo-PSEmoji -CustomObject $customObject
62 | $emoji.Group | Should -BeExactly 'Smileys & Emotion'
63 | $emoji.Subgroup | Should -BeExactly 'face-smiling'
64 | $emoji.HexCodePoint | Should -BeExactly '1F600'
65 | $emoji.Status | Should -BeExactly 'fully-qualified'
66 | $emoji.Name | Should -BeExactly '😀'
67 | $emoji.Version | Should -BeExactly 'E1.0'
68 | $emoji.Description | Should -BeExactly 'grinning face'
69 | $emoji.ShortCode | Should -BeExactly ':grinning_face:'
70 | $emoji.HexCodePointArray | Should -BeExactly @('1F600')
71 | $emoji.UnicodeStandard | Should -BeExactly 'Unicode 6.0'
72 | $emoji.HTMLEntityFormat | Should -BeExactly '😀'
73 | $emoji.pwshEscapedFormat | Should -BeExactly '`u{1F600}'
74 | $emoji.Decimal | Should -BeExactly @('128512')
75 | } #it
76 |
77 | } #context_Success
78 |
79 | } #describe_ConvertTo-PSEmoji
80 |
81 | } #inModule
82 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Private/Expand-XMLDataSet.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Expand-XMLDataSet' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 | } #before_all
17 |
18 | BeforeEach {
19 | Mock -CommandName Test-Path -MockWith {
20 | $false
21 | } #endMock
22 | Mock -CommandName Remove-Item -MockWith {
23 |
24 | } #endMock
25 | Mock -CommandName Expand-Archive -MockWith {
26 | [PSCustomObject]@{
27 | Name = 'AzModI.xml'
28 | Exists = 'True'
29 | CreationTime = [datetime]'01 / 06 / 20 23:02:16'
30 | }
31 | } #endMock
32 | } #before_each
33 |
34 | Context 'Error' {
35 |
36 | It 'should return false if an error is encountered with Test-Path' {
37 | Mock -CommandName Test-Path -MockWith {
38 | throw 'FakeError'
39 | } #endMock
40 | Expand-XMLDataSet | Should -BeExactly $false
41 | } #it
42 |
43 | It 'should return false if an error is encountered with Remove-Item' {
44 | Mock -CommandName Test-Path -MockWith {
45 | $true
46 | } #endMock
47 | Mock -CommandName Remove-Item -MockWith {
48 | throw 'FakeError'
49 | } #endMock
50 | Expand-XMLDataSet | Should -BeExactly $false
51 | } #it
52 |
53 | It 'should return false if an error is encountered with Expand-Archive' {
54 | Mock -CommandName Expand-Archive -MockWith {
55 | throw 'FakeError'
56 | } #endMock
57 | Expand-XMLDataSet | Should -BeExactly $false
58 | } #it
59 |
60 | } #context_Error
61 |
62 | Context 'Success' {
63 |
64 | It 'should return true if the data file is expanded' {
65 | Expand-XMLDataSet | Should -BeExactly $true
66 | } #it
67 |
68 | } #context_Success
69 |
70 | } #describe_Expand-XMLDataSet
71 |
72 | } #inModule
73 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Private/Get-RemoteFile.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Get-RemoteFile' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 | $fileName = 'test.zip'
17 | } #before_all
18 |
19 | BeforeEach {
20 | Mock -CommandName Invoke-WebRequest -MockWith {
21 | [PSCustomObject]@{
22 | StatusCode = '200'
23 | StatusDescription = 'OK'
24 | Content = '{80, 75, 3, 4}'
25 | }
26 | } #endMock
27 | } #before_each
28 |
29 | Context 'Error' {
30 |
31 | It 'should return false if an error is encountered downloading the file' {
32 | Mock -CommandName Invoke-WebRequest -MockWith {
33 | throw 'FakeError'
34 | } #endMock
35 | Get-RemoteFile -File $fileName | Should -BeExactly $false
36 | } #it
37 |
38 | } #context_FunctionName
39 |
40 | Context 'Success' {
41 |
42 | It 'should return true if the file is downloaded' {
43 | Get-RemoteFile -File $fileName | Should -BeExactly $true
44 | } #it
45 |
46 | It 'should call Invoke-WebRequest with the correct parameters' {
47 | $outPath = [System.IO.Path]::Combine($script:dataPath, $fileName)
48 | Get-RemoteFile -File $fileName
49 | Should -Invoke -CommandName Invoke-WebRequest -Times 1 -Exactly -Scope It -ParameterFilter {
50 | $OutFile -eq $outPath -and $Uri -eq "https://$script:dlURI/$fileName"
51 | }
52 | } #it
53 |
54 | It 'should call Invoke-WebRequest with the correct parameters if OutFileName is specified' {
55 | $fileNameOverride = 'test2.zip'
56 | $outPath = [System.IO.Path]::Combine($script:dataPath, $fileNameOverride)
57 | Get-RemoteFile -File $fileName -OutFileName $fileNameOverride
58 | Should -Invoke -CommandName Invoke-WebRequest -Times 1 -Exactly -Scope It -ParameterFilter {
59 | $OutFile -eq $outPath -and $Uri -eq "https://$script:dlURI/$fileName"
60 | }
61 | } #it
62 |
63 | } #context_Success
64 |
65 | } #describe_Get-RemoteFile
66 |
67 | } #inModule
68 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Private/Invoke-XMLDataCheck.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Invoke-XMLDataCheck' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 | function Confirm-DataLocation {
17 | }
18 | function Confirm-XMLDataSet {
19 | }
20 | function Expand-XMLDataSet {
21 | }
22 | function Get-RemoteFile {
23 | }
24 | function Remove-Item {
25 | }
26 | } #before_all
27 |
28 | Context 'ShouldProcess' {
29 | BeforeEach {
30 | Mock -CommandName Invoke-XMLDataCheck -MockWith { } #endMock
31 | } #before_each
32 | It 'Should process by default' {
33 | Invoke-XMLDataCheck
34 | Should -Invoke Invoke-XMLDataCheck -Scope It -Exactly -Times 1
35 | } #it
36 | It 'Should not process on explicit request for confirmation (-Confirm)' {
37 | { Invoke-XMLDataCheck -Confirm }
38 | Should -Invoke Invoke-XMLDataCheck -Scope It -Exactly -Times 0
39 | } #it
40 | It 'Should not process on implicit request for confirmation (ConfirmPreference)' {
41 | {
42 | $ConfirmPreference = 'Low'
43 | Invoke-XMLDataCheck
44 | }
45 | Should -Invoke Invoke-XMLDataCheck -Scope It -Exactly -Times 0
46 | } #it
47 | It 'Should not process on explicit request for validation (-WhatIf)' {
48 | { Invoke-XMLDataCheck -WhatIf }
49 | Should -Invoke Invoke-XMLDataCheck -Scope It -Exactly -Times 0
50 | } #it
51 | It 'Should not process on implicit request for validation (WhatIfPreference)' {
52 | {
53 | $WhatIfPreference = $true
54 | Invoke-XMLDataCheck
55 | }
56 | Should -Invoke Invoke-XMLDataCheck -Scope It -Exactly -Times 0
57 | } #it
58 | It 'Should process on force' {
59 | $ConfirmPreference = 'Medium'
60 | Invoke-XMLDataCheck -Force
61 | Should -Invoke Invoke-XMLDataCheck -Scope It -Exactly -Times 1
62 | } #it
63 | } #context_ShouldProcess
64 |
65 | BeforeEach {
66 | Mock -CommandName Confirm-DataLocation -MockWith {
67 | $true
68 | } #endMock
69 | Mock -CommandName Confirm-XMLDataSet -MockWith {
70 | $true
71 | } #endMock
72 | Mock -CommandName Expand-XMLDataSet -MockWith {
73 | $true
74 | } #endMock
75 | Mock -CommandName Get-RemoteFile -MockWith {
76 | $true
77 | } #endMock
78 | Mock -CommandName Test-Path -MockWith {
79 | $true
80 | } #endMock
81 | Mock -CommandName Remove-Item -MockWith {}
82 | } #before_each
83 |
84 | Context 'Success' {
85 |
86 | It 'should return true if the data file is confirmed' {
87 | Invoke-XMLDataCheck -Force | Should -BeExactly $true
88 | } #it
89 |
90 | It 'should return false if the data output dir cannot be confirmed' {
91 | Mock -CommandName Confirm-DataLocation -MockWith {
92 | $false
93 | } #endMock
94 | Invoke-XMLDataCheck -Force | Should -BeExactly $false
95 | } #it
96 |
97 | It 'should return false if the data file is not confirmed and the file can not be downloaded' {
98 | Mock -CommandName Confirm-XMLDataSet -MockWith {
99 | $false
100 | } #endMock
101 | Mock -CommandName Get-RemoteFile -MockWith {
102 | $false
103 | } #endMock
104 | Invoke-XMLDataCheck -Force | Should -BeExactly $false
105 | } #it
106 |
107 | It 'should return false if the data file is not confirmed and the file is downloaded, but can not be expanded' {
108 | Mock -CommandName Confirm-XMLDataSet -MockWith {
109 | $false
110 | } #endMock
111 | Mock -CommandName Expand-XMLDataSet -MockWith {
112 | $false
113 | } #endMock
114 | Invoke-XMLDataCheck -Force | Should -BeExactly $false
115 | } #it
116 |
117 | It 'should return true if the data file is not confirmed and the file is downloaded and expanded' {
118 | Mock -CommandName Confirm-XMLDataSet -MockWith {
119 | $false
120 | } #endMock
121 | Invoke-XMLDataCheck -Force | Should -BeExactly $true
122 | } #it
123 |
124 | It 'should download 2 files if the data file is not confirmed' {
125 | Mock -CommandName Confirm-XMLDataSet -MockWith {
126 | $false
127 | } #endMock
128 | Invoke-XMLDataCheck -Force
129 | Should -Invoke Get-RemoteFile -Scope It -Exactly -Times 2
130 | } #it
131 |
132 | It 'should not attempt to remove the metadata file if it does not exist' {
133 | Mock -CommandName Confirm-XMLDataSet -MockWith {
134 | $false
135 | } #endMock
136 | Mock -CommandName Test-Path -MockWith {
137 | $false
138 | } #endMock
139 | Invoke-XMLDataCheck -Force
140 | Should -Invoke Remove-Item -Scope It -Exactly -Times 0
141 | } #it
142 |
143 | } #context_Success
144 |
145 | } #describe_Invoke-XMLDataCheck
146 |
147 | } #inModule
148 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Public/Add-EmojiToText.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Add-EmojiToText Public Function Tests' -Tag Unit {
13 | BeforeAll {
14 | $WarningPreference = 'SilentlyContinue'
15 | $ErrorActionPreference = 'SilentlyContinue'
16 | . $PSScriptRoot\..\..\asset\emojiTestData.ps1
17 | $script:glData = $emojiTestData
18 | } #beforeAll
19 | # Context 'Error' {
20 |
21 | # } #context_Error
22 | Context 'Success' {
23 |
24 | BeforeEach {
25 | Mock -CommandName 'Get-Emoji' -MockWith {
26 | [PSCustomObject]@{
27 | Group = 'Travel & Places'
28 | Subgroup = 'place-map'
29 | HexCodePoint = '1F5FA FE0F'
30 | Status = 'fully-qualified'
31 | Name = '🗺️'
32 | }
33 | } #endMock
34 | } #beforeEach
35 |
36 | It 'Adds an emoji to the text' {
37 | $result = Add-EmojiToText -Text "World!"
38 | $result | Should -Be "World! 🗺️"
39 | } #it
40 |
41 | It 'Returns the original text when no emoji is provided' {
42 | Mock -CommandName 'Get-Emoji' -MockWith { }
43 | $result = Add-EmojiToText -Text "Hello, world!"
44 | $result | Should -Be "Hello, world!"
45 | } #it
46 |
47 | It 'should replace the word with the emoji when the -Replace switch is used' {
48 | $result = Add-EmojiToText -Text "World" -Replace
49 | $result | Should -Be "🗺️"
50 | } #it
51 |
52 | It 'should not try to add emojis for stop words' {
53 | Mock -CommandName 'Get-Emoji' -MockWith { }
54 | Add-EmojiToText -Text "and"
55 | Should -Invoke -CommandName 'Get-Emoji' -Exactly -Times 0 -Scope 'It'
56 | } #it
57 |
58 | } #context_Success
59 |
60 | } #describe_Add-EmojiToText
61 |
62 | } #inModule
63 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Public/Get-AllEmoji.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Get-AllEmoji Public Function Tests' -Tag Unit {
13 |
14 | BeforeAll {
15 | $WarningPreference = 'SilentlyContinue'
16 | $ErrorActionPreference = 'SilentlyContinue'
17 | . $PSScriptRoot\..\..\asset\emojiTestData.ps1
18 | $script:glData = $emojiTestData
19 | } #beforeAll
20 |
21 | Context 'Error' {
22 |
23 | It 'should return null when the data set is not available' {
24 | Mock -CommandName 'Import-XMLDataSet' -MockWith {
25 | return $false
26 | } #endMock
27 | Get-AllEmoji | Should -BeNullOrEmpty
28 | } #it
29 |
30 | It 'should return null if the data set contains objects with incorrect data types' {
31 | Mock -CommandName 'Import-XMLDataSet' -MockWith {
32 | return $true
33 | } #endMock
34 | Mock -CommandName 'ConvertTo-PSEmoji' -MockWith {
35 | throw 'fake error'
36 | } #endMock
37 | Get-AllEmoji | Should -BeNullOrEmpty
38 | } #it
39 |
40 | } #context_Error
41 |
42 | Context 'Success' {
43 |
44 | BeforeEach {
45 | Mock -CommandName 'Import-XMLDataSet' -MockWith {
46 | return $true
47 | } #endMock
48 | Mock -CommandName 'ConvertTo-PSEmoji' -MockWith {
49 | $testEmoji
50 | } #endMock
51 | } #beforeEach
52 |
53 | It 'should import the xml data set' {
54 | Get-AllEmoji
55 | Should -Invoke -CommandName 'Import-XMLDataSet' -Exactly -Times 1 -Scope 'It'
56 | } #it
57 |
58 | It 'should return the expected object type' {
59 | # https://github.com/pester/Pester/issues/1315
60 | $emojis = Get-AllEmoji
61 | ($emojis[0]).GetType().Name | Should -Be 'PSEmoji'
62 | } #it
63 |
64 | It 'should convert the expected number of objects' {
65 | Get-AllEmoji
66 | Should -Invoke -CommandName 'ConvertTo-PSEmoji' -Exactly -Times 11 -Scope 'It'
67 | } #it
68 |
69 | It 'should return the expected number of objects' {
70 | (Get-AllEmoji).Count | Should -Be 11
71 | } #it
72 |
73 | It 'should return the expected number of objects if only unqualified objects are in the dataset' {
74 | Mock -CommandName 'ConvertTo-PSEmoji' -MockWith {
75 | $testEmoji2
76 | } #endMock
77 | (Get-AllEmoji).Count | Should -Be 0
78 | } #it
79 |
80 | It 'should return the expected number of objects when IncludeAll is specified' {
81 | Mock -CommandName 'ConvertTo-PSEmoji' -MockWith {
82 | $testEmoji2
83 | } #endMock
84 | (Get-AllEmoji -IncludeAll).Count | Should -Be 11
85 | } #it
86 |
87 | } #context_Success
88 |
89 | } #describe_Get-AllEmoji
90 |
91 | } #inModule
92 |
--------------------------------------------------------------------------------
/src/Tests/Unit/Public/Get-Emoji.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeDiscovery {
2 | Set-Location -Path $PSScriptRoot
3 | $ModuleName = 'pwshEmojiExplorer'
4 | $PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1")
5 | #if the module is already in memory, remove it
6 | Get-Module $ModuleName -ErrorAction SilentlyContinue | Remove-Module -Force
7 | Import-Module $PathToManifest -Force
8 | }
9 |
10 | InModuleScope 'pwshEmojiExplorer' {
11 |
12 | Describe 'Get-Emoji Public Function Tests' -Tag Unit {
13 |
14 | BeforeAll {
15 | $WarningPreference = 'SilentlyContinue'
16 | $ErrorActionPreference = 'SilentlyContinue'
17 | . $PSScriptRoot\..\..\asset\emojiTestData.ps1
18 | $script:glData = $emojiTestData
19 | } #beforeAll
20 |
21 | Context 'Error' {
22 |
23 | It 'should return null when the data set is not available' {
24 | Mock -CommandName 'Import-XMLDataSet' -MockWith {
25 | return $false
26 | } #endMock
27 | Get-Emoji -Emoji '😀' | Should -BeNullOrEmpty
28 | } #it
29 |
30 | It 'should return null if the data set contains objects with incorrect data types' {
31 | Mock -CommandName 'Import-XMLDataSet' -MockWith {
32 | return $true
33 | } #endMock
34 | Mock -CommandName 'ConvertTo-PSEmoji' -MockWith {
35 | throw 'fake error'
36 | } #endMock
37 | Get-Emoji -Decimal 128512 | Should -BeNullOrEmpty
38 | } #it
39 |
40 | } #context_Error
41 |
42 | Context 'Success' {
43 |
44 | BeforeEach {
45 | Mock -CommandName 'Import-XMLDataSet' -MockWith {
46 | return $true
47 | } #endMock
48 | Mock -CommandName 'ConvertTo-PSEmoji' -MockWith {
49 | $testEmoji
50 | } #endMock
51 | } #beforeEach
52 |
53 | It 'should import the xml data set' {
54 | Get-Emoji -Group 'Food & Drink'
55 | Should -Invoke -CommandName 'Import-XMLDataSet' -Exactly -Times 1 -Scope 'It'
56 | } #it
57 |
58 | It 'should return the expected object type' {
59 | # https://github.com/pester/Pester/issues/1315
60 | $emojis = Get-Emoji -SubGroup 'food-vegetable'
61 | ($emojis[0]).GetType().Name | Should -Be 'PSEmoji'
62 | } #it
63 |
64 | It 'should convert the expected number of objects for HexCodePoint' {
65 | Get-Emoji -HexCodePoint '1F600'
66 | Should -Invoke -CommandName 'ConvertTo-PSEmoji' -Exactly -Times 1 -Scope 'It'
67 | } #it
68 |
69 | Context 'Results Counts - exact' {
70 |
71 | It 'should return the expected number of objects for Emoji' {
72 | (Get-Emoji -Emoji '😀').Count | Should -Be 1
73 | } #it
74 |
75 | It 'should return the expected number of objects for Group' {
76 | (Get-Emoji -Group 'Food & Drink').Count | Should -Be 8
77 | } #it
78 |
79 | It 'should return the expected number of objects for SubGroup' {
80 | (Get-Emoji -SubGroup 'food-vegetable').Count | Should -Be 3
81 | } #it
82 |
83 | It 'should return the expected number of objects for ShortCode' {
84 | (Get-Emoji -ShortCode ':smiling_face_with_hearts:').Count | Should -Be 1
85 | } #it
86 |
87 | It 'should return the expected number of objects for HexCodePoint' {
88 | (Get-Emoji -HexCodePoint '1F600').Count | Should -Be 1
89 | } #it
90 |
91 | It 'should return the expected number of objects for Decimal' {
92 | (Get-Emoji -Decimal 128512).Count | Should -Be 1
93 | } #it
94 |
95 | It 'should return the expected number of objects for Decimal with multiple decimal values' {
96 | (Get-Emoji -Decimal '127812', '8205', '129003').Count | Should -Be 1
97 | } #it
98 |
99 | It 'should return no objects if no decimal values are found' {
100 | (Get-Emoji -Decimal '123456').Count | Should -Be 0
101 | } #it
102 |
103 | It 'should return the expected number of objects for SearchTerm' {
104 | (Get-Emoji -SearchTerm 'fork').Count | Should -Be 2
105 | } #it
106 |
107 | It 'should return the expected number of objects for SearchTerm with IncludeAll' {
108 | (Get-Emoji -SearchTerm 'fork' -IncludeAll).Count | Should -Be 3
109 | } #it
110 |
111 | } #context_exact_ResultCounts
112 |
113 | Context 'Results Counts - relaxed' {
114 |
115 | It 'should return the expected number of objects for wildcard Group' {
116 | (Get-Emoji -Group '*food*').Count | Should -Be 8
117 | } #it
118 |
119 | It 'should return the expected number of objects for general Group' {
120 | (Get-Emoji -Group 'food').Count | Should -Be 8
121 | } #it
122 |
123 | It 'should return the expected number of objects for wildcard SubGroup' {
124 | (Get-Emoji -SubGroup '*vegetable*').Count | Should -Be 3
125 | } #it
126 |
127 | It 'should return the expected number of objects for general SubGroup' {
128 | (Get-Emoji -SubGroup 'vegetable').Count | Should -Be 3
129 | } #it
130 |
131 | It 'should return the expected number of objects for wildcard ShortCode' {
132 | (Get-Emoji -ShortCode '*smiling*').Count | Should -Be 1
133 | } #it
134 |
135 | It 'should return the expected number of objects for general ShortCode' {
136 | (Get-Emoji -ShortCode 'smiling').Count | Should -Be 1
137 | } #it
138 |
139 | It 'should return the expected number of objects for general HexCodePoint' {
140 | (Get-Emoji -HexCodePoint '1F7E9').Count | Should -Be 1
141 | } #it
142 |
143 | } #context_range_ResultCounts
144 |
145 | } #context_Success
146 |
147 | } #describe_Get-Emoji
148 |
149 | } #inModule
150 |
--------------------------------------------------------------------------------
/src/Tests/Unit/pwshEmojiExplorer-Module.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | #-------------------------------------------------------------------------
3 | Set-Location -Path $PSScriptRoot
4 | #-------------------------------------------------------------------------
5 | $ModuleName = 'pwshEmojiExplorer'
6 | $PathToManifest = [System.IO.Path]::Combine('..', '..', $ModuleName, "$ModuleName.psd1")
7 | $PathToModule = [System.IO.Path]::Combine('..', '..', $ModuleName, "$ModuleName.psm1")
8 | #-------------------------------------------------------------------------
9 | }
10 | Describe 'Module Tests' -Tag Unit {
11 | Context "Module Tests" {
12 | $script:manifestEval = $null
13 | It 'Passes Test-ModuleManifest' {
14 | { $script:manifestEval = Test-ModuleManifest -Path $PathToManifest } | Should -Not -Throw
15 | $? | Should -BeTrue
16 | } #manifestTest
17 | It 'root module pwshEmojiExplorer.psm1 should exist' {
18 | $PathToModule | Should -Exist
19 | $? | Should -BeTrue
20 | } #psm1Exists
21 | It 'manifest should contain pwshEmojiExplorer.psm1' {
22 | $PathToManifest |
23 | Should -FileContentMatchExactly "pwshEmojiExplorer.psm1"
24 | } #validPSM1
25 | It 'should have a matching module name in the manifest' {
26 | $script:manifestEval.Name | Should -BeExactly $ModuleName
27 | } #name
28 | It 'should have a valid description in the manifest' {
29 | $script:manifestEval.Description | Should -Not -BeNullOrEmpty
30 | } #description
31 | It 'should have a valid author in the manifest' {
32 | $script:manifestEval.Author | Should -Not -BeNullOrEmpty
33 | } #author
34 | It 'should have a valid version in the manifest' {
35 | $script:manifestEval.Version -as [Version] | Should -Not -BeNullOrEmpty
36 | } #version
37 | It 'should have a valid guid in the manifest' {
38 | { [guid]::Parse($script:manifestEval.Guid) } | Should -Not -Throw
39 | } #guid
40 | It 'should not have any spaces in the tags' {
41 | foreach ($tag in $script:manifestEval.Tags) {
42 | $tag | Should -Not -Match '\s'
43 | }
44 | } #tagSpaces
45 | It 'should have a valid project Uri' {
46 | $script:manifestEval.ProjectUri | Should -Not -BeNullOrEmpty
47 | } #uri
48 | } #context_ModuleTests
49 | } #describe_ModuleTests
50 |
--------------------------------------------------------------------------------
/src/Tests/asset/emojiTestData.ps1:
--------------------------------------------------------------------------------
1 | $emojiTestData = @(
2 | [PSCustomObject]@{
3 | Group = 'Smileys & Emotion'
4 | Subgroup = 'face-smiling'
5 | HexCodePoint = '1F600'
6 | Status = 'fully-qualified'
7 | Name = '😀'
8 | Version = 'E1.0'
9 | Description = 'grinning face'
10 | ShortCode = ':grinning_face:'
11 | HexCodePointArray = @('1F600')
12 | UnicodeStandard = @('U+1F600')
13 | HTMLEntityFormat = @('😀')
14 | pwshEscapedFormat = '`u1F600'
15 | Decimal = @('128512')
16 | }
17 | [PSCustomObject]@{
18 | Group = 'Smileys & Emotion'
19 | Subgroup = 'face-affection'
20 | HexCodePoint = '1F970'
21 | Status = 'fully-qualified'
22 | Name = '🥰'
23 | Version = 'E11.0'
24 | Description = 'smiling face with hearts'
25 | ShortCode = ':smiling_face_with_hearts:'
26 | HexCodePointArray = @('1F970')
27 | UnicodeStandard = @('U+1F970')
28 | HTMLEntityFormat = @('🥰')
29 | pwshEscapedFormat = '`u1F970'
30 | Decimal = @('129392')
31 | }
32 | [PSCustomObject]@{
33 | Group = 'Food & Drink'
34 | Subgroup = 'food-asian'
35 | HexCodePoint = '1F363'
36 | Status = 'fully-qualified'
37 | Name = '🍣'
38 | Version = 'E0.6'
39 | Description = 'sushi'
40 | ShortCode = ':sushi:'
41 | HexCodePointArray = @('1F363')
42 | UnicodeStandard = @('U+1F363')
43 | HTMLEntityFormat = @('🍣')
44 | pwshEscapedFormat = '`u1F363'
45 | Decimal = @('127843')
46 | }
47 | [PSCustomObject]@{
48 | Group = 'Food & Drink'
49 | Subgroup = 'food-vegetable'
50 | HexCodePoint = '1F344 200D 1F7EB'
51 | Status = 'fully-qualified'
52 | Name = '🍄🟫'
53 | Version = 'E15.1'
54 | Description = 'brown mushroom'
55 | ShortCode = ':brown_mushroom:'
56 | HexCodePointArray = @('1F344', '200D', '1F7EB')
57 | UnicodeStandard = @('U+1F344', 'U+200D', 'U+1F7EB')
58 | HTMLEntityFormat = @('🍄', '', '🟫')
59 | pwshEscapedFormat = '`u1F344`u200D`u1F7EB'
60 | Decimal = @('127812', '8205', '129003')
61 | }
62 | [PSCustomObject]@{
63 | Group = 'Food & Drink'
64 | Subgroup = 'food-fruit'
65 | HexCodePoint = '1F34B'
66 | Status = 'fully-qualified'
67 | Name = '🍋'
68 | Version = 'E1.0'
69 | Description = 'lemon'
70 | ShortCode = ':lemon:'
71 | HexCodePointArray = @('1F34B')
72 | UnicodeStandard = @('U+1F34B')
73 | HTMLEntityFormat = @('🍋')
74 | pwshEscapedFormat = '`u1F34B'
75 | Decimal = @('127819')
76 | }
77 | [PSCustomObject]@{
78 | Group = 'Food & Drink'
79 | Subgroup = 'food-fruit'
80 | HexCodePoint = '1F34B 200D 1F7E9'
81 | Status = 'fully-qualified'
82 | Name = '🍋🟩'
83 | Version = 'E15.1'
84 | Description = 'lime'
85 | ShortCode = ':lime:'
86 | HexCodePointArray = @('1F34B', '200D', '1F7E9')
87 | UnicodeStandard = @('U+1F34B', 'U+200D', 'U+1F7E9')
88 | HTMLEntityFormat = @('🍋', '', '🟩')
89 | pwshEscapedFormat = '`u1F34B`u200D`u1F7E9'
90 | Decimal = @('127819', '8205', '129001')
91 | }
92 | [PSCustomObject]@{
93 | Group = 'Food & Drink'
94 | Subgroup = 'food-vegetable'
95 | HexCodePoint = '1F336 FE0F'
96 | Status = 'fully-qualified'
97 | Name = '🌶️'
98 | Version = 'E0.7'
99 | Description = 'hot pepper'
100 | ShortCode = ':hot_pepper:'
101 | HexCodePointArray = @('1F336', 'FE0F')
102 | UnicodeStandard = @('U+1F336', 'U+FE0F')
103 | HTMLEntityFormat = @('🌶', '️')
104 | pwshEscapedFormat = '`u1F336`uFE0F'
105 | Decimal = @('127798', '65039')
106 | }
107 | [PSCustomObject]@{
108 | Group = 'Food & Drink'
109 | Subgroup = 'food-vegetable'
110 | HexCodePoint = '1FAD1'
111 | Status = 'fully-qualified'
112 | Name = '🫑'
113 | Version = 'E13.0'
114 | Description = 'bell pepper'
115 | ShortCode = ':bell_pepper:'
116 | HexCodePointArray = @('1FAD1')
117 | UnicodeStandard = @('U+1FAD1')
118 | HTMLEntityFormat = @('🫑')
119 | pwshEscapedFormat = '`u1FAD1'
120 | Decimal = @('129745')
121 | }
122 | [PSCustomObject]@{
123 | Group = 'Food & Drink'
124 | Subgroup = 'dishware'
125 | HexCodePoint = '1F37D FE0F'
126 | Status = 'fully-qualified'
127 | Name = '🍽️'
128 | Version = 'E0.7'
129 | Description = 'fork and knife with plate'
130 | ShortCode = ':fork_and_knife_with_plate:'
131 | HexCodePointArray = @('1F37D', 'FE0F')
132 | UnicodeStandard = @('U+1F37D', 'U+FE0F')
133 | HTMLEntityFormat = @('🍽', '️')
134 | pwshEscapedFormat = '`u1F37D`uFE0F'
135 | Decimal = @('127869', '65039')
136 | }
137 | [PSCustomObject]@{
138 | Group = 'Food & Drink'
139 | Subgroup = 'dishware'
140 | HexCodePoint = '1F374'
141 | Status = 'fully-qualified'
142 | Name = '🍴'
143 | Version = 'E0.6'
144 | Description = 'fork and knife'
145 | ShortCode = ':fork_and_knife:'
146 | HexCodePointArray = @('1F374')
147 | UnicodeStandard = @('U+1F374')
148 | HTMLEntityFormat = @('🍴')
149 | pwshEscapedFormat = '`u1F374'
150 | Decimal = @('127860')
151 | }
152 | [PSCustomObject]@{
153 | Group = 'Food & Drink'
154 | Subgroup = 'dishware'
155 | HexCodePoint = '1F37D'
156 | Status = 'unqualified'
157 | Name = '🍽'
158 | Version = 'E0.7'
159 | Description = 'fork and knife with plate'
160 | ShortCode = ':fork_and_knife_with_plate:'
161 | HexCodePointArray = @('1F37D')
162 | UnicodeStandard = @('U+1F37D')
163 | HTMLEntityFormat = @('🍽')
164 | pwshEscapedFormat = '`u{1F37D'
165 | Decimal = @('127869')
166 | }
167 | )
168 |
169 | $testEmoji = [PSEmoji]::new(
170 | 'Smileys & Emotion',
171 | 'face-smiling',
172 | '1F600',
173 | 'fully-qualified',
174 | '😀',
175 | 'E1.0',
176 | 'grinning face',
177 | ':grinning_face:',
178 | @('1F600'),
179 | @('U+1F600'),
180 | @('😀'),
181 | '`u1F600',
182 | @('128512')
183 | )
184 | $testEmoji2 = [PSEmoji]::new(
185 | 'Food & Drink',
186 | 'dishware',
187 | '1F37D',
188 | 'unqualified',
189 | '🍽',
190 | 'E0.7',
191 | 'fork and knife with plate',
192 | ':fork_and_knife_with_plate:',
193 | @('1F37D'),
194 | @('U+1F37D'),
195 | @('🍽'),
196 | '`u{1F37D',
197 | @('127869')
198 | )
199 |
200 | $testEmojis = @(
201 | $testEmoji,
202 | $testEmoji2
203 | )
204 |
205 |
206 | $customObject = [PSCustomObject]@{
207 | Group = 'Smileys & Emotion'
208 | Subgroup = 'face-smiling'
209 | HexCodePoint = '1F600'
210 | Status = 'fully-qualified'
211 | Name = '😀'
212 | Version = 'E1.0'
213 | Description = 'grinning face'
214 | ShortCode = ':grinning_face:'
215 | HexCodePointArray = @('1F600')
216 | UnicodeStandard = 'Unicode 6.0'
217 | HTMLEntityFormat = '😀'
218 | pwshEscapedFormat = '`u{1F600}'
219 | Decimal = @('128512')
220 | }
221 | $badCustomObject = [PSCustomObject]@{
222 | BadValue = 'Malformed'
223 | VeryBadValue = '{Malformed}'
224 | }
225 | $badDataTypeCustomObject = [PSCustomObject]@{
226 | Group = 'Food & Drink'
227 | Subgroup = 'dishware'
228 | HexCodePoint = '1F37D'
229 | Status = 'unqualified'
230 | Name = '🍽'
231 | Version = 'E0.7'
232 | Description = 'fork and knife with plate'
233 | ShortCode = ':fork_and_knife_with_plate:'
234 | HexCodePointArray = '{1F37D}'
235 | UnicodeStandard = '{U+1F37D}'
236 | HTMLEntityFormat = '{🍽}'
237 | pwshEscapedFormat = '`u{1F37D}'
238 | Decimal = '{127869}'
239 | }
240 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer.Settings.ps1:
--------------------------------------------------------------------------------
1 | # specify the minimum required major PowerShell version that the build script should validate
2 | [version]$script:requiredPSVersion = '5.1.0'
3 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Imports.ps1:
--------------------------------------------------------------------------------
1 | # This is a locally sourced Imports file for local development.
2 | # It can be imported by the psm1 in local development to add script level variables.
3 | # It will merged in the build process. This is for local development only.
4 |
5 | # region script variables
6 | # $script:resourcePath = "$PSScriptRoot\Resources"
7 |
8 | $script:unicodeVersion = '16.0'
9 |
10 | function Get-DataLocation {
11 | $folderName = 'pwshEmojiExplorer'
12 | if ($PROFILE) {
13 | $script:dataPath = (Join-Path (Split-Path -Parent $PROFILE) $folderName)
14 | }
15 | else {
16 | $script:dataPath = "~\${$folderName}"
17 | }
18 | }
19 |
20 | $domain = 'cloudfront.net'
21 | $target = 'd1nm4o1hreod3r'
22 | Get-DataLocation
23 | $script:dataFileZip = 'pwshemojis.zip'
24 | $script:metadataFile = 'version.json'
25 | $script:dataFile = 'pwshEmoji.xml'
26 | $script:dlURI = '{0}.{1}' -f $target, $domain
27 | $script:glData = $null
28 |
29 |
30 | class PSEmoji {
31 | [string]$Group
32 | [string]$Subgroup
33 | [string]$HexCodePoint
34 | [string]$Status
35 | [string]$Name
36 | [string]$Version
37 | [string]$Description
38 | [string]$ShortCode
39 | [string[]]$HexCodePointArray
40 | [string[]]$UnicodeStandard
41 | [string[]]$HTMLEntityFormat
42 | [string]$pwshEscapedFormat
43 | [int[]]$Decimal
44 |
45 | PSEmoji([string]$Group, [string]$Subgroup, [string]$HexCodePoint, [string]$Status, [string]$Name, [string]$Version, [string]$Description, [string]$ShortCode, [string[]]$HexCodePointArray, [string[]]$UnicodeStandard, [string[]]$HTMLEntityFormat, [string]$pwshEscapedFormat, [int[]]$Decimal) {
46 | $this.Group = $Group
47 | $this.Subgroup = $Subgroup
48 | $this.HexCodePoint = $HexCodePoint
49 | $this.Status = $Status
50 | $this.Name = $Name
51 | $this.Version = $Version
52 | $this.Description = $Description
53 | $this.ShortCode = $ShortCode
54 | $this.HexCodePointArray = $HexCodePointArray
55 | $this.UnicodeStandard = $UnicodeStandard
56 | $this.HTMLEntityFormat = $HTMLEntityFormat
57 | $this.pwshEscapedFormat = $pwshEscapedFormat
58 | $this.Decimal = $Decimal
59 | }
60 |
61 | # You can add any additional methods here
62 | }
63 |
64 | $script:stopWords = @(
65 | 'a'
66 | 'about'
67 | 'above'
68 | 'actually'
69 | 'after'
70 | 'again'
71 | 'against'
72 | 'all'
73 | 'almost'
74 | 'also'
75 | 'although'
76 | 'always'
77 | 'am'
78 | 'an'
79 | 'and'
80 | 'any'
81 | 'are'
82 | 'as'
83 | 'at'
84 | 'be'
85 | 'became'
86 | 'because'
87 | 'become'
88 | 'been'
89 | 'before'
90 | 'being'
91 | 'below'
92 | 'between'
93 | 'both'
94 | 'but'
95 | 'by'
96 | 'can'
97 | 'cannot'
98 | 'could'
99 | 'did'
100 | 'do'
101 | 'does'
102 | 'doing'
103 | 'down'
104 | 'during'
105 | 'each'
106 | 'either'
107 | 'else'
108 | 'few'
109 | 'for'
110 | 'from'
111 | 'further'
112 | 'had'
113 | 'has'
114 | 'have'
115 | 'having'
116 | 'he'
117 | 'hence'
118 | 'her'
119 | 'here'
120 | 'hers'
121 | 'herself'
122 | 'him'
123 | 'himself'
124 | 'his'
125 | 'how'
126 | 'i'
127 | 'if'
128 | 'i''m'
129 | 'in'
130 | 'into'
131 | 'is'
132 | 'it'
133 | 'its'
134 | 'itself'
135 | 'just'
136 | 'may'
137 | 'maybe'
138 | 'me'
139 | 'might'
140 | 'mine'
141 | 'more'
142 | 'most'
143 | 'must'
144 | 'my'
145 | 'myself'
146 | 'neither'
147 | 'no'
148 | 'nor'
149 | 'not'
150 | 'of'
151 | 'off'
152 | 'oh'
153 | 'ok'
154 | 'on'
155 | 'once'
156 | 'only'
157 | 'or'
158 | 'other'
159 | 'ought'
160 | 'our'
161 | 'ours'
162 | 'ourselves'
163 | 'out'
164 | 'over'
165 | 'own'
166 | 'same'
167 | 'she'
168 | 'so'
169 | 'some'
170 | 'such'
171 | 'than'
172 | 'that'
173 | 'the'
174 | 'their'
175 | 'theirs'
176 | 'them'
177 | 'themselves'
178 | 'then'
179 | 'there'
180 | 'these'
181 | 'they'
182 | 'this'
183 | 'those'
184 | 'through'
185 | 'to'
186 | 'too'
187 | 'under'
188 | 'very'
189 | 'wait'
190 | 'was'
191 | 'we'
192 | 'were'
193 | 'what'
194 | 'whenever'
195 | 'whereas'
196 | 'wherever'
197 | 'whether'
198 | 'who'
199 | 'whoever'
200 | 'whom'
201 | 'whose'
202 | 'why'
203 | 'will'
204 | 'with'
205 | 'within'
206 | 'without'
207 | 'would'
208 | 'yes'
209 | 'yet'
210 | 'you'
211 | 'your'
212 | 'yours'
213 | 'yourself'
214 | 'yourselves'
215 | )
216 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/Confirm-DataLocation.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Confirm data output location. Creates output dir if not present.
4 | .DESCRIPTION
5 | Evaluates presence of data output location for xml dataset. If the directory is not found, it will be created.
6 | .EXAMPLE
7 | Confirm-DataLocation
8 |
9 | Confirms presence of data output location. Creates if not found.
10 | .OUTPUTS
11 | System.Boolean
12 | .NOTES
13 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
14 | .COMPONENT
15 | pwshEmojiExplorer
16 | #>
17 | function Confirm-DataLocation {
18 | [CmdletBinding()]
19 | param (
20 | )
21 | $result = $true #assume the best
22 | Write-Verbose -Message 'Verifying data set output location...'
23 | Write-Debug -Message ('Data path: {0}' -f $script:dataPath)
24 | try {
25 | $pathEval = Test-Path -Path $script:dataPath -ErrorAction Stop
26 | }
27 | catch {
28 | $result = $false
29 | Write-Error $_
30 | return $result
31 | }
32 |
33 | Write-Debug -Message ('Path evaluation: {0}' -f $pathEval)
34 |
35 | if (-not ($pathEval)) {
36 | Write-Verbose -Message 'Creating output directory...'
37 | try {
38 | $newItemSplat = @{
39 | ItemType = 'Directory'
40 | Path = $script:dataPath
41 | ErrorAction = 'Stop'
42 | }
43 | $null = New-Item @newItemSplat
44 | Write-Verbose -Message 'Created.'
45 | }
46 | catch {
47 | $result = $false
48 | Write-Error $_
49 | return $result
50 | }
51 | } #if_TestPath
52 | else {
53 | Write-Verbose 'Data path confirmed.'
54 | } #else_TestPath
55 |
56 | return $result
57 | } #Confirm-DataLocation
58 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/Confirm-MetadataUpdate.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Compares the local metadata file to the remote metadata file.
4 | .DESCRIPTION
5 | Evaluates the local metadata file and compares it to the remote metadata file. If the files are the same, returns true. If the files are different, returns false.
6 | .EXAMPLE
7 | Confirm-MetadataUpdate
8 |
9 | Compares the local metadata file to the remote metadata file.
10 | .OUTPUTS
11 | System.Boolean
12 | .NOTES
13 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
14 | .COMPONENT
15 | pwshEmojiExplorer
16 | #>
17 | function Confirm-MetadataUpdate {
18 | [CmdletBinding()]
19 | param (
20 | )
21 | $result = $true #assume the best
22 |
23 | Write-Verbose -Message 'Checking for metadata file...'
24 | $localMetaDataFilePath = [System.IO.Path]::Combine($script:dataPath, $script:metadataFile)
25 | Write-Debug -Message ('Metadata file path: {0}' -f $localMetaDataFilePath)
26 | try {
27 | $pathEval = Test-Path -Path $localMetaDataFilePath -ErrorAction Stop
28 | }
29 | catch {
30 | $result = $false
31 | Write-Error $_
32 | return $result
33 | }
34 |
35 | if (-not ($pathEval)) {
36 | $result = $false
37 | Write-Debug -Message 'Metadata file not found.'
38 | } #if_pathEval
39 | else {
40 | Write-Verbose 'Metadata file found. Performing metadata comparison...'
41 | try {
42 | $localMetadata = Get-Content $localMetaDataFilePath -ErrorAction 'Stop' | ConvertFrom-Json
43 | }
44 | catch {
45 | $result = $false
46 | Write-Error $_
47 | return $result
48 | }
49 |
50 | $tempMetadataFile = '{0}_temp' -f $script:metadataFile
51 | $tempMetadataFilePath = [System.IO.Path]::Combine($script:dataPath, $tempMetadataFile)
52 | Write-Debug -Message ('Temp metadata file path: {0}' -f $tempMetadataFilePath)
53 | # if the temp metadata file exists, delete it
54 | if (Test-Path -Path $tempMetadataFile) {
55 | Write-Debug -Message 'Removing temp metadata file...'
56 | Remove-Item -Path $tempMetadataFilePath -Force
57 | }
58 |
59 | # download metadata file for comparison
60 | $fileFetchStatus = Get-RemoteFile -File $script:metadataFile -OutFile $tempMetadataFile
61 | if ($fileFetchStatus -eq $false) {
62 | Write-Error 'Unable to download metadata file.'
63 | $result = $false
64 | return $result
65 | }
66 |
67 | Write-Debug -Message 'Getting content of temp metadata file...'
68 | try {
69 | $remoteMetadata = Get-Content $tempMetadataFilePath -ErrorAction 'Stop' | ConvertFrom-Json
70 | }
71 | catch {
72 | $result = $false
73 | Write-Error $_
74 | return $result
75 | }
76 |
77 | Write-Debug -Message ('Local metadata version: {0}' -f $localMetadata.version)
78 | Write-Debug -Message ('Remote metadata version: {0}' -f $remoteMetadata.version)
79 |
80 | Write-Verbose -Message ('{0} vs {1}' -f $localMetadata.version, $remoteMetadata.version)
81 | if ($localMetadata.version -eq $remoteMetadata.version) {
82 | Write-Verbose 'Metadata file is current.'
83 | }
84 | else {
85 | Write-Verbose 'Metadata file requires refresh.'
86 | $result = $false
87 | }
88 | }
89 |
90 | return $result
91 | } #Confirm-MetadataUpdate
92 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/Confirm-XMLDataSet.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Confirms the XML dataset file is available and not beyond the expiration time.
4 | .DESCRIPTION
5 | Determines if the XML dataset file is stale or not available.
6 | If the file is not available, false will be returned so it can be downloaded.
7 | If the file is available, but over 9 days old, the metadata file will be checked to see if an update is available.
8 | If an update is available after the metadata file is checked, false will be returned so the data file can be refreshed.
9 | .EXAMPLE
10 | Confirm-XMLDataSet
11 |
12 | Checks for XML dataset and determines if it is 9 days older or more.
13 | .OUTPUTS
14 | System.Boolean
15 | .NOTES
16 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
17 | .COMPONENT
18 | pwshEmojiExplorer
19 | #>
20 | function Confirm-XMLDataSet {
21 | [CmdletBinding()]
22 | param (
23 | )
24 | $result = $true #assume the best
25 | $dataFile = '{0}/{1}' -f $script:dataPath, $script:dataFile
26 |
27 | Write-Verbose -Message 'Confirming valid and current data set...'
28 |
29 | # if the file doesn't exist, we need to download it
30 | Write-Verbose -Message 'Checking for data file...'
31 | Write-Debug -Message ('Data file path: {0}' -f $dataFile)
32 | try {
33 | $pathEval = Test-Path -Path $dataFile -ErrorAction Stop
34 | }
35 | catch {
36 | $result = $false
37 | Write-Error $_
38 | return $result
39 | }
40 |
41 | if (-not ($pathEval)) {
42 | Write-Debug -Message 'Data file not found.'
43 | $result = $false
44 | } #if_pathEval
45 | else {
46 | Write-Verbose 'Data file found. Checking date of file...'
47 | try {
48 | $fileData = Get-Item -Path $dataFile -ErrorAction Stop
49 | }
50 | catch {
51 | $result = $false
52 | Write-Error $_
53 | return $result
54 | }
55 | if ($fileData) {
56 | $creationDate = $fileData.LastWriteTime
57 | $now = Get-Date
58 | if (($now - $creationDate).Days -ge 9) {
59 | # Write-Verbose 'Data file requires refresh.'
60 | Write-Verbose 'Data file is older than 9 days. Checking if an update is available...'
61 | $metadataStatus = Confirm-MetadataUpdate
62 | if ($metadataStatus -eq $false) {
63 | Write-Verbose 'Refreshing data file...'
64 | $result = $false
65 | }
66 | else {
67 | Write-Verbose 'No update available. Data file is current.'
68 | }
69 | }
70 | else {
71 | Write-Verbose 'Data file verified'
72 | }
73 | } #if_fileData
74 | else {
75 | Write-Warning 'Unable to retrieve file information for pwshEmojiExplorer data set.'
76 | $result = $false
77 | return $result
78 | } #else_fileData
79 | } #else_pathEval
80 |
81 | return $result
82 | } #Confirm-XMLDataSet
83 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/Convert-EmojiToHexCodePoint.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Converts an emoji to a string of its hexadecimal code points.
4 | .DESCRIPTION
5 | The Convert-EmojiToHexCodePoint function translates a given emoji character into its corresponding hexadecimal code points. This function is particularly useful for handling emojis that consist of surrogate pairs in Unicode, ensuring accurate conversion of complex emojis into their full hexadecimal representations.
6 | .EXAMPLE
7 | $Emoji = "🐸"
8 | $searchCriteria = Convert-EmojiToHexCodePoint -Emoji $Emoji
9 | $searchCriteria
10 |
11 | Converts the frog emoji into its hexadecimal representation '1F438'.
12 | .PARAMETER Emoji
13 | Specifies the emoji character to be converted.
14 | .OUTPUTS
15 | System.String
16 | .NOTES
17 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
18 | .COMPONENT
19 | pwshEmojiExplorer
20 | #>
21 | function Convert-EmojiToHexCodePoint {
22 | param (
23 | [Parameter(Mandatory = $true)]
24 | [string]$Emoji
25 | )
26 |
27 | Write-Debug -Message 'Converting emoji to hexadecimal code points...'
28 | $charArray = $Emoji.ToCharArray()
29 | $codePoints = New-Object System.Collections.Generic.List[string]
30 |
31 | for ($i = 0; $i -lt $charArray.Length; $i++) {
32 | $codePoint = [Char]::ConvertToUtf32($Emoji, $i)
33 | [void]$codePoints.Add("{0:X}" -f $codePoint)
34 |
35 | # If this character is a high surrogate, skip the next character
36 | if ([Char]::IsHighSurrogate($charArray[$i])) {
37 | $i++
38 | }
39 | }
40 |
41 | return $codePoints -join ' '
42 | } # Convert-EmojiToHexCodePoint
43 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/ConvertTo-PSEmoji.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Converts a custom object to a PSEmoji object.
4 | .DESCRIPTION
5 | The ConvertTo-PSEmoji function takes a custom object as input and converts it to a PSEmoji object.
6 | .EXAMPLE
7 | $customObject = [PSCustomObject]@{
8 | Group = 'Smileys & Emotion'
9 | Subgroup = 'face-smiling'
10 | HexCodePoint = '1F600'
11 | Status = 'fully-qualified'
12 | Name = '😀'
13 | Version = 'E1.0'
14 | Description = 'grinning face'
15 | ShortCode = ':grinning_face:'
16 | HexCodePointArray = @('1F600')
17 | UnicodeStandard = 'Unicode 6.0'
18 | HTMLEntityFormat = '😀'
19 | pwshEscapedFormat = '`u{1F600}'
20 | Decimal = @('128512')
21 | }
22 | $emoji = ConvertTo-PSEmoji -CustomObject $customObject
23 |
24 | This example shows how to convert a custom object to a PSEmoji object.
25 | .EXAMPLE
26 | [PSEmoji]$emoji = ConvertTo-PSEmoji -CustomObject $customObject s
27 |
28 | This example shows how to convert a custom object to a PSEmoji object.
29 | .PARAMETER CustomObject
30 | The custom object to be converted. This object should have properties that match the properties of the PSEmoji class.
31 | .INPUTS
32 | PSCustomObject
33 | .OUTPUTS
34 | PSEmoji
35 | .NOTES
36 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
37 | The properties of the custom object should match the properties of the PSEmoji class.
38 | .COMPONENT
39 | pwshEmojiExplorer
40 | #>
41 | function ConvertTo-PSEmoji {
42 | param (
43 | [Parameter(Mandatory = $true,
44 | HelpMessage = 'Custom object to be converted to a PSEmoji object.')]
45 | [PSCustomObject]$CustomObject
46 | )
47 |
48 | Write-Debug -Message 'Converting custom object to PSEmoji object...'
49 |
50 | $emoji = [PSEmoji]::new(
51 | $CustomObject.Group,
52 | $CustomObject.Subgroup,
53 | $CustomObject.HexCodePoint,
54 | $CustomObject.Status,
55 | $CustomObject.Name,
56 | $CustomObject.Version,
57 | $CustomObject.Description,
58 | $CustomObject.ShortCode,
59 | $CustomObject.HexCodePointArray,
60 | $CustomObject.UnicodeStandard,
61 | $CustomObject.HTMLEntityFormat,
62 | $CustomObject.pwshEscapedFormat,
63 | $CustomObject.Decimal
64 | )
65 |
66 | return $emoji
67 | } #ConvertTo-PSEmoji
68 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/Expand-XMLDataSet.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Unzips the XML data set.
4 | .DESCRIPTION
5 | Evaluates for previous version of XML data set and removes if required. Expands the XML data set for use.
6 | .EXAMPLE
7 | Expand-XMLDataSet
8 |
9 | Unzips and expands the XML data set.
10 | .OUTPUTS
11 | System.Boolean
12 | .NOTES
13 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
14 | .COMPONENT
15 | pwshEmojiExplorer
16 | #>
17 | function Expand-XMLDataSet {
18 | [CmdletBinding()]
19 | param (
20 | )
21 | $result = $true #assume the best
22 | $dataFile = '{0}/{1}' -f $script:dataPath, $script:dataFile
23 |
24 | Write-Verbose -Message 'Testing if data set file already exists...'
25 | Write-Debug -Message ('Data file path: {0}' -f $dataFile)
26 | try {
27 | $pathEval = Test-Path -Path $dataFile -ErrorAction Stop
28 | Write-Verbose -Message "EVAL: $true"
29 | }
30 | catch {
31 | $result = $false
32 | Write-Error $_
33 | return $result
34 | }
35 |
36 | if ($pathEval) {
37 | Write-Verbose -Message 'Removing existing data set file...'
38 | try {
39 | $removeItemSplat = @{
40 | Force = $true
41 | Path = $dataFile
42 | ErrorAction = 'Stop'
43 | }
44 | Remove-Item @removeItemSplat
45 | } #try
46 | catch {
47 | $result = $false
48 | Write-Error $_
49 | return $result
50 | } #catch
51 | } #if_pathEval
52 |
53 | Write-Verbose -Message 'Expanding data set archive...'
54 | try {
55 | $expandArchiveSplat = @{
56 | DestinationPath = $script:dataPath
57 | Force = $true
58 | ErrorAction = 'Stop'
59 | Path = '{0}/{1}' -f $script:dataPath, $script:dataFileZip
60 | }
61 | $null = Microsoft.PowerShell.Archive\Expand-Archive @expandArchiveSplat
62 | Write-Verbose -Message 'Expand completed.'
63 | } #try
64 | catch {
65 | $result = $false
66 | Write-Error $_
67 | } #catch
68 |
69 | return $result
70 | } #Expand-XMLDataSet
71 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/Get-RemoteFile.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Downloads file to device.
4 | .DESCRIPTION
5 | Retrieves file from web and downloads to device.
6 | .EXAMPLE
7 | Get-RemoteFile
8 |
9 | Downloads file to data path.
10 | .PARAMETER File
11 | File to download.
12 | .PARAMETER OutFileName
13 | Specify output file name.
14 | .OUTPUTS
15 | System.Boolean
16 | .NOTES
17 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
18 | Overwrites existing zip file.
19 | .COMPONENT
20 | pwshEmojiExplorer
21 | #>
22 | function Get-RemoteFile {
23 | [CmdletBinding()]
24 | param (
25 | [Parameter(Mandatory = $true,
26 | HelpMessage = 'File to download')]
27 | [string]$File,
28 |
29 | [Parameter(Mandatory = $false,
30 | HelpMessage = 'Specify output file name.')]
31 | [string]$OutFileName
32 | )
33 | $result = $true #assume the best
34 |
35 | if ($OutFileName) {
36 | $OutFile = $OutFileName
37 | }
38 | else {
39 | $OutFile = $File
40 | }
41 |
42 | Write-Verbose -Message 'Downloading file...'
43 | $outFilePath = [System.IO.Path]::Combine($script:dataPath, $OutFile)
44 | Write-Debug -Message ('Out file path: {0}' -f $outFilePath)
45 | try {
46 | $invokeWebRequestSplat = @{
47 | OutFile = $outFilePath
48 | Uri = 'https://{0}/{1}' -f $script:dlURI, $File
49 | ErrorAction = 'Stop'
50 | }
51 | $oldProgressPreference = $progressPreference
52 | $progressPreference = 'SilentlyContinue'
53 | if ($PSEdition -eq 'Desktop') {
54 | $null = Invoke-WebRequest @invokeWebRequestSplat -PassThru -UseBasicParsing
55 | }
56 | else {
57 | $null = Invoke-WebRequest @invokeWebRequestSplat -PassThru
58 | }
59 | } #try
60 | catch {
61 | $result = $false
62 | Write-Error $_
63 | } #catch
64 | finally {
65 | $progressPreference = $oldProgressPreference
66 | } #finally
67 | return $result
68 | } #Get-RemoteFile
69 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/Import-XMLDataSet.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Evaluates if XML data set is in memory and kicks of child processes to obtain XML data set.
4 | .DESCRIPTION
5 | XML data set will be evaluated if already in memory. If not, a series of processes will be kicked off to load the XML data set for use.
6 | .EXAMPLE
7 | Import-XMLDataSet
8 |
9 | Loads the XML data set into memory.
10 | .OUTPUTS
11 | System.Boolean
12 | .NOTES
13 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
14 | Parent process for getting XML data.
15 | .COMPONENT
16 | pwshEmojiExplorer
17 | #>
18 | function Import-XMLDataSet {
19 | [CmdletBinding()]
20 | param (
21 | )
22 | $result = $true #assume the best
23 | Write-Verbose -Message 'Verifying current state of XML data set...'
24 | if ($null -eq $script:glData) {
25 | $dataCheck = Invoke-XMLDataCheck
26 | if ($dataCheck) {
27 | Write-Debug -Message 'XMLDataCheck returned true.'
28 | try {
29 | $getContentSplat = @{
30 | Path = "$script:dataPath\$script:dataFile"
31 | Raw = $true
32 | ErrorAction = 'Stop'
33 | }
34 | $fileData = Get-Content @getContentSplat
35 | $script:glData = $fileData | ConvertFrom-Clixml -ErrorAction Stop
36 | } #try
37 | catch {
38 | $result = $false
39 | Write-Error $_
40 | } #catch
41 | } #if_dataCheck
42 | else {
43 | Write-Debug -Message 'XMLDataCheck returned false.'
44 | $result = $false
45 | } #else_dataCheck
46 | } #if_gldata
47 | return $result
48 | } #Import-XMLDataSet
49 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Private/Invoke-XMLDataCheck.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Invokes all child functions required to process retrieving the XML data set file.
4 | .DESCRIPTION
5 | Runs all required child functions to successfully retrieve and process the XML data set file.
6 | .EXAMPLE
7 | Invoke-XMLDataCheck
8 |
9 | Downloads, expands, and verified the XML data set file.
10 | .OUTPUTS
11 | System.Boolean
12 | .NOTES
13 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
14 | Confirm-XMLDataSet
15 | Get-RemoteFile
16 | Expand-XMLDataSet
17 | .COMPONENT
18 | pwshEmojiExplorer
19 | #>
20 | function Invoke-XMLDataCheck {
21 | [CmdletBinding(ConfirmImpact = 'Low',
22 | SupportsShouldProcess = $true)]
23 | param (
24 | [Parameter(Mandatory = $false,
25 | HelpMessage = 'Skip confirmation')]
26 | [switch]$Force
27 | )
28 | Begin {
29 |
30 | if (-not $PSBoundParameters.ContainsKey('Verbose')) {
31 | $VerbosePreference = $PSCmdlet.SessionState.PSVariable.GetValue('VerbosePreference')
32 | }
33 | if (-not $PSBoundParameters.ContainsKey('Confirm')) {
34 | $ConfirmPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ConfirmPreference')
35 | }
36 | if (-not $PSBoundParameters.ContainsKey('WhatIf')) {
37 | $WhatIfPreference = $PSCmdlet.SessionState.PSVariable.GetValue('WhatIfPreference')
38 | }
39 |
40 | Write-Verbose -Message ('[{0}] Confirm={1} ConfirmPreference={2} WhatIf={3} WhatIfPreference={4}' -f $MyInvocation.MyCommand, $Confirm, $ConfirmPreference, $WhatIf, $WhatIfPreference)
41 |
42 | $results = $true #assume the best
43 | } #begin
44 | Process {
45 | # -Confirm --> $ConfirmPreference = 'Low'
46 | # ShouldProcess intercepts WhatIf* --> no need to pass it on
47 | if ($Force -or $PSCmdlet.ShouldProcess("ShouldProcess?")) {
48 | Write-Verbose -Message ('[{0}] Reached command' -f $MyInvocation.MyCommand)
49 | $ConfirmPreference = 'None'
50 |
51 | $dataOutputDir = Confirm-DataLocation
52 | if ($dataOutputDir -eq $true) {
53 | $confirm = Confirm-XMLDataSet
54 | if (-not $confirm -eq $true) {
55 | $retrieve = Get-RemoteFile -File $script:dataFileZip
56 | # remove metadata file if it exists
57 | $localMetaDataFilePath = [System.IO.Path]::Combine($script:dataPath, $script:metadataFile)
58 | if (Test-Path -Path $localMetaDataFilePath) {
59 | Remove-Item -Path $localMetaDataFilePath -Force
60 | }
61 | $retrieveMetadata = Get-RemoteFile -File $script:metadataFile
62 | if ($retrieve -eq $true -and $retrieveMetadata -eq $true) {
63 | $expand = Expand-XMLDataSet
64 | if (-not $expand -eq $true) {
65 | $results = $false
66 | }
67 | }
68 | else {
69 | $results = $false
70 | }
71 | } #if_Confirm
72 | } #if_data_output
73 | else {
74 | $results = $false
75 | } #else_data_output
76 |
77 | } #if_Should
78 | } #process
79 | End {
80 | return $results
81 | } #end
82 | } #Invoke-XMLDataCheck
83 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Public/Add-EmojiToText.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Enhances text by adding emojis based on key words.
4 | .DESCRIPTION
5 | The Add-EmojiToText function is designed to enrich your text with emojis by identifying key words and appending relevant emojis. It scans the input text for words that can be associated with emojis and inserts an emoji next to each identified word. This function employs a "best effort" approach to match words with emojis, providing a fun and light-hearted way to spruce up messages or texts. Note that the function's ability to find and match emojis is based on simple logic, and it may not always find a perfect match for every word.
6 | .EXAMPLE
7 | $sampleText = "Spending the day debugging some code and optimizing algorithms. Later, planning a virtual meeting with my team to discuss cloud computing and data security. Can't forget to update my blog on the latest AI trends. In the evening, it's time to unwind with a sci-fi movie and maybe some online gaming. Proud to be a part of the ever-evolving digital era!"
8 | $enhancedText = Add-EmojiToText -Text $sampleText
9 | Write-Output $enhancedText
10 |
11 | This example demonstrates how Add-EmojiToText can be used to add a playful touch to a given text by inserting emojis. Emojis related to words like 'cloud', 'AI', 'movie', and 'time' are added next to the corresponding words in the text.
12 | .EXAMPLE
13 | $sampleText = "I am going to the airport tomorrow to fly on a plane to Spain. Before I take off I'm going to eat some food. I've heard they have good restaurants at the terminal. Hopefully they have something spicy. You know how much I like hot food! I'm so excited to see you! Can't wait to see you! Love you!"
14 | Add-EmojiToText -Text $sampleText
15 |
16 | This example demonstrates how Add-EmojiToText can be used to add a playful touch to a given text by inserting emojis. Emojis related to words like 'airport', 'plane', 'Spain', and 'food' are added next to the corresponding words in the text.
17 | .EXAMPLE
18 | $sampleText = "Morning coffee, followed by a workout and a quick check of the news. Work involves writing code, attending meetings, and brainstorming. Lunchtime is for catching up on social media. The evening is for relaxation, maybe with some music, a good book, or a movie. Ending the night by setting the alarm and dreaming about the beach."
19 | $enhancedText = Add-EmojiToText -Text $sampleText -Replace
20 | Write-Output $enhancedText
21 |
22 | This example demonstrates how Add-EmojiToText can be used to transform a text into a fun, emoji-centric version by replacing key words with their corresponding emojis. The -Replace switch is used to substitute these everyday activities and concepts with relevant emojis, creating an engaging and visually expressive rendition of the text. This playful transformation is perfect for adding a bit of whimsy to messages or social media posts.
23 | .PARAMETER Text
24 | Specifies the text to be processed by the function.
25 | .PARAMETER Replace
26 | Specifies whether the function should replace the word with the emoji or add the emoji after the word. The default value is $false, which means that the emoji is added after the word. If the value is set to $true, the word is replaced with the emoji.
27 | .OUTPUTS
28 | System.String
29 | .NOTES
30 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
31 | This function is experimental and intended for casual use to add a fun element to text processing.
32 |
33 | This function uses the Public data set from the Unicode Data Files and adheres to the Unicode Terms of Use:
34 | https://www.unicode.org/copyright.html
35 | https://www.unicode.org/license.txt
36 | .COMPONENT
37 | pwshEmojiExplorer
38 | .LINK
39 | https://pwshEmojiExplorer.readthedocs.io/en/latest/Add-EmojiToText/
40 | .LINK
41 | https://www.unicode.org/license.txt
42 | #>
43 | function Add-EmojiToText {
44 | [CmdletBinding()]
45 | param (
46 | [Parameter(Mandatory = $true,
47 | HelpMessage = 'The text to process')]
48 | [ValidateNotNullOrEmpty()]
49 | [string]$Text,
50 |
51 | [Parameter(Mandatory = $false,
52 | HelpMessage = 'Replace the word with the emoji instead of adding the emoji after the word')]
53 | [switch]$Replace
54 | )
55 |
56 | Write-Verbose -Message 'Processing text...'
57 |
58 | $words = $Text -split ' '
59 |
60 | # Process each word
61 | $processedWords = foreach ($word in $words) {
62 | # ____________________________
63 | # resets
64 | $emoji = $null
65 | $key = $null
66 | $emojiObj = $null
67 | # ____________________________
68 | if ($word -notin $stopWords) {
69 | $key = $word -replace '[^\w\s]', '' # Remove punctuation for matching
70 | $emojiObj = Get-Emoji -SearchTerm $key
71 | if ($emojiObj) {
72 | $emoji = $emojiObj[0].Name
73 | }
74 | if ($emoji) {
75 | Write-Debug -Message ('{0} -> {1}' -f $key, $emoji)
76 | if ($Replace -eq $true) {
77 | $word = "$emoji"
78 | }
79 | else {
80 | $word = "$word $emoji" # Add the emoji after the word
81 | }
82 | $word
83 | }
84 | else {
85 | $word
86 | }
87 | }
88 | else {
89 | $word
90 | }
91 | } #foreach_word
92 |
93 | # Reconstruct the text
94 | $processedText = $processedWords -join ' '
95 |
96 | return $processedText
97 | } #Add-EmojiToText
98 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/Public/Get-AllEmoji.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Retrieves all emojis.
4 | .DESCRIPTION
5 | The Get-AllEmoji function retrieves a comprehensive list of emojis. By default, the function returns only 'fully-qualified' emojis, which are the most common and widely supported versions. If you need to include 'minimally-qualified' and 'unqualified' emojis, which might not be as widely supported or are variations of the standard emojis, use the IncludeAll switch.
6 | .EXAMPLE
7 | Get-AllEmoji
8 |
9 | Retrieves all 'fully-qualified' emojis.
10 | .EXAMPLE
11 | Get-AllEmoji -IncludeAll
12 |
13 | Retrieves all emojis, including both 'fully-qualified' and 'minimally-qualified'/'unqualified' emojis.
14 | .PARAMETER IncludeAll
15 | Includes all emojis in the output, regardless of their qualification status. By default, only 'fully-qualified' emojis are returned.
16 | .OUTPUTS
17 | PSEmoji
18 | .NOTES
19 | Author: Jake Morrison - @jakemorrison - https://www.techthoughts.info/
20 | Qualification levels:
21 | - Fully-qualified — a complete, standard emoji
22 | - Minimally-qualified — a basic form of an emoji, often lacking detail
23 | - Unqualified — a raw, unrefined form of an emoji
24 |
25 | This function uses the Public data set from the Unicode Data Files and adheres to the Unicode Terms of Use:
26 | https://www.unicode.org/copyright.html
27 | https://www.unicode.org/license.txt
28 | .COMPONENT
29 | pwshEmojiExplorer
30 | .LINK
31 | https://pwshEmojiExplorer.readthedocs.io/en/latest/Get-AllEmoji/
32 | .LINK
33 | https://www.unicode.org/license.txt
34 | #>
35 | function Get-AllEmoji {
36 | [CmdletBinding()]
37 | param (
38 | [Parameter(Mandatory = $false,
39 | HelpMessage = 'Includes all emojis in the output')]
40 | [switch]$IncludeAll
41 | )
42 | Write-Verbose -Message 'Verifying XML Data Set Availability...'
43 | if (Import-XMLDataSet) {
44 | Write-Verbose -Message 'Verified.'
45 |
46 | $dataSet = $script:glData
47 |
48 | Write-Verbose -Message 'Retrieving all emojis...'
49 | # declare object array empty list
50 | $emojiList = New-Object System.Collections.Generic.List[PSEmoji]
51 | $dataSet | ForEach-Object {
52 | $emoji = $null
53 | try {
54 | [PSEmoji]$emoji = ConvertTo-PSEmoji -CustomObject $_
55 | }
56 | catch {
57 | Write-Warning -Message ('Unable to convert the custom object {0} to a PSEmoji object.' -f $_.Description)
58 | }
59 |
60 | [void]$emojiList.Add($emoji)
61 | }
62 |
63 | Write-Debug -Message ('{0} emojis retrieved.' -f $emojiList.Count)
64 |
65 | if ($IncludeAll -eq $false) {
66 | $results = $emojiList | Where-Object { $_.Status -eq 'fully-qualified' }
67 | }
68 | else {
69 | $results = $emojiList
70 | }
71 |
72 | Write-Debug -Message ('{0} emojis returned.' -f $results.Count)
73 |
74 | } #if_Import-XMLDataSet
75 | else {
76 | Write-Warning -Message 'pwshEmojiExplorer was unable to source the required data set file.'
77 | Write-Warning -Message 'Ensure you have an active internet connection'
78 | return
79 | } #else_Import-XMLDataSet
80 |
81 | return $results
82 | } #Get-AllEmoji
83 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/pwshEmojiExplorer.Format.ps1xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PSEList
6 |
7 | PSEmoji
8 |
9 |
10 |
11 |
12 |
13 |
14 | Group
15 |
16 |
17 | Subgroup
18 |
19 |
20 | HexCodePoint
21 |
22 |
23 | Name
24 |
25 |
26 | Description
27 |
28 |
29 | ShortCode
30 |
31 |
32 | HexCodePointArray
33 |
34 |
35 | UnicodeStandard
36 |
37 |
38 | pwshEscapedFormat
39 |
40 |
41 | Decimal
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | PSETable
50 |
51 | PSEmoji
52 |
53 |
54 | Group
55 |
56 |
57 |
58 |
59 | 6
60 | center
61 |
62 |
63 | 22
64 | left
65 |
66 |
67 | 22
68 | left
69 |
70 |
71 | left
72 |
73 |
74 |
75 |
76 |
77 |
78 | Name
79 |
80 |
81 | Group
82 |
83 |
84 | Subgroup
85 |
86 |
87 | ShortCode
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/pwshEmojiExplorer.psd1:
--------------------------------------------------------------------------------
1 | #
2 | # Module manifest for module 'pwshEmojiExplorer'
3 | #
4 | # Generated by: Jake
5 | #
6 | # Generated on: 12/27/2023
7 | #
8 |
9 | @{
10 |
11 | # Script module or binary module file associated with this manifest.
12 | RootModule = 'pwshEmojiExplorer.psm1'
13 |
14 | # Version number of this module.
15 | ModuleVersion = '0.9.0'
16 |
17 | # Supported PSEditions
18 | # CompatiblePSEditions = @()
19 |
20 | # ID used to uniquely identify this module
21 | GUID = '6e4813c7-6f30-42e8-adc4-b3d9b46bce9a'
22 |
23 | # Author of this module
24 | Author = 'Jake Morrison'
25 |
26 | # Company or vendor of this module
27 | CompanyName = 'TechThoughts'
28 |
29 | # Copyright statement for this module
30 | Copyright = '(c) Jake Morrison. All rights reserved.'
31 |
32 | # Description of the functionality provided by this module
33 | Description = 'Enables detailed emoji search, discovery, and retrieval. Offers detailed insights on emojis, with multiple search options aligned with the Unicode standard. Provides comprehensive emoji data, including diverse representations and formats, to enhance your scripts and digital communication.'
34 |
35 | # Minimum version of the PowerShell engine required by this module
36 | # PowerShellVersion = ''
37 |
38 | # Name of the PowerShell host required by this module
39 | # PowerShellHostName = ''
40 |
41 | # Minimum version of the PowerShell host required by this module
42 | # PowerShellHostVersion = ''
43 |
44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45 | # DotNetFrameworkVersion = ''
46 |
47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48 | # ClrVersion = ''
49 |
50 | # Processor architecture (None, X86, Amd64) required by this module
51 | # ProcessorArchitecture = ''
52 |
53 | # Modules that must be imported into the global environment prior to importing this module
54 | RequiredModules = @(
55 | @{
56 | ModuleName = 'Convert'
57 | ModuleVersion = '1.5.0'
58 | }
59 | )
60 |
61 | # Assemblies that must be loaded prior to importing this module
62 | # RequiredAssemblies = @()
63 |
64 | # Script files (.ps1) that are run in the caller's environment prior to importing this module.
65 | ScriptsToProcess = @(
66 | 'ArgumentCompleters.ps1'
67 | )
68 |
69 | # Type files (.ps1xml) to be loaded when importing this module
70 | # TypesToProcess = @()
71 |
72 | # Format files (.ps1xml) to be loaded when importing this module
73 | FormatsToProcess = @(
74 | 'pwshEmojiExplorer.Format.ps1xml'
75 | )
76 |
77 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
78 | # NestedModules = @()
79 |
80 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
81 | FunctionsToExport = @(
82 | 'Add-EmojiToText',
83 | 'Get-Emoji',
84 | 'Get-AllEmoji'
85 | )
86 |
87 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
88 | # CmdletsToExport = '*'
89 |
90 | # Variables to export from this module
91 | # VariablesToExport = '*'
92 |
93 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
94 | # AliasesToExport = '*'
95 |
96 | # DSC resources to export from this module
97 | # DscResourcesToExport = @()
98 |
99 | # List of all modules packaged with this module
100 | # ModuleList = @()
101 |
102 | # List of all files packaged with this module
103 | # FileList = @()
104 |
105 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
106 | PrivateData = @{
107 |
108 | PSData = @{
109 |
110 | # Tags applied to this module. These help with module discovery in online galleries.
111 | Tags = @(
112 | 'emoji',
113 | 'emojis',
114 | 'unicode',
115 | 'unicode-emoji',
116 | 'unicode-emojis',
117 | 'chat',
118 | 'text',
119 | 'texting',
120 | 'text-emoji',
121 | 'text-emojis',
122 | 'texting-emoji',
123 | 'texting-emojis',
124 | 'message',
125 | 'messaging',
126 | 'message-emoji',
127 | 'message-emojis',
128 | 'messaging-emoji',
129 | 'messaging-emojis',
130 | 'Activities',
131 | 'Animals',
132 | 'Nature',
133 | 'Component',
134 | 'Flag',
135 | 'Flags',
136 | 'Food',
137 | 'Drink',
138 | 'People',
139 | 'Smileys',
140 | 'Emotion',
141 | 'Symbols',
142 | 'Travel',
143 | 'Places'
144 | )
145 |
146 | # A URL to the license for this module.
147 | LicenseUri = 'https://github.com/techthoughts2/pwshEmojiExplorer/blob/main/LICENSE'
148 |
149 | # A URL to the main website for this project.
150 | ProjectUri = 'https://github.com/techthoughts2/pwshEmojiExplorer'
151 |
152 | # A URL to an icon representing this module.
153 | IconUri = 'https://github.com/techthoughts2/pwshEmojiExplorer/raw/main/docs/assets/pwshEmojiExplorer_icon.png'
154 |
155 | # ReleaseNotes of this module
156 | ReleaseNotes = 'https://github.com/techthoughts2/pwshEmojiExplorer/blob/main/docs/CHANGELOG.md'
157 |
158 | # Prerelease string of this module
159 | # Prerelease = ''
160 |
161 | # Flag to indicate whether the module requires explicit user acceptance for install/update/save
162 | # RequireLicenseAcceptance = $false
163 |
164 | # External dependent modules of this module
165 | # ExternalModuleDependencies = @()
166 |
167 | } # End of PSData hashtable
168 |
169 | } # End of PrivateData hashtable
170 |
171 | # HelpInfo URI of this module
172 | # HelpInfoURI = ''
173 |
174 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
175 | # DefaultCommandPrefix = ''
176 |
177 | }
178 |
179 |
180 |
--------------------------------------------------------------------------------
/src/pwshEmojiExplorer/pwshEmojiExplorer.psm1:
--------------------------------------------------------------------------------
1 | # this psm1 is for local testing and development use only
2 |
3 | # dot source the parent import for local development variables
4 | . $PSScriptRoot\Imports.ps1
5 |
6 | # discover all ps1 file(s) in Public and Private paths
7 |
8 | $itemSplat = @{
9 | Filter = '*.ps1'
10 | Recurse = $true
11 | ErrorAction = 'Stop'
12 | }
13 | try {
14 | $public = @(Get-ChildItem -Path "$PSScriptRoot\Public" @itemSplat)
15 | $private = @(Get-ChildItem -Path "$PSScriptRoot\Private" @itemSplat)
16 | }
17 | catch {
18 | Write-Error $_
19 | throw "Unable to get get file information from Public & Private src."
20 | }
21 |
22 | # dot source all .ps1 file(s) found
23 | foreach ($file in @($public + $private)) {
24 | try {
25 | . $file.FullName
26 | }
27 | catch {
28 | throw "Unable to dot source [$($file.FullName)]"
29 |
30 | }
31 | }
32 |
33 | # export all public functions
34 | Export-ModuleMember -Function $public.Basename
--------------------------------------------------------------------------------