Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add universal manifest helpers #60

Merged
merged 32 commits into from
Dec 5, 2020
Merged

feat: Add universal manifest helpers #60

merged 32 commits into from
Dec 5, 2020

Conversation

Ash258
Copy link
Owner

@Ash258 Ash258 commented Aug 21, 2020

#27
ScoopInstaller#3587

{
    "version": "1.0",
    "pre_download": [
        "Assert-Administrator",
        "Assert-ScoopConfigValue 'SCOOP_BRANCH' 'NEW'",
        "Assert-WindowsMinimalVersion '7.0'"
    ],
    "url": [
        "https://github.com/sharkdp/bat/releases/download/v0.12.1/bat-v0.12.1-x86_64-pc-windows-msvc.zip",
        "https://raw.githubusercontent.com/lukesampson/scoop-extras/master/scripts/vscode-install-context.reg",
        "https://raw.githubusercontent.com/lukesampson/scoop-extras/master/scripts/vscode-uninstall-context.reg"
    ],
    "hash": [
        "d6136b0133ad7f16029f7b996fc36cfb9af83828420e4a29d9798249fb8b37df",
        "b65d66860d9ccc18bfb05237b03e06db0d6c574be3d4b946c2a5e6865c08cb28",
        "df2a5162e72e2518e2b75b4337c8e7b46c136554872af90fa0de1cf6ebef376f"
    ],
    "pre_install": [
        "    # Nested file with two lines",
        "Test-Persistence 'bin\\nested\\file' -Content 'new', 'line'",
        "    # File4 should be empty",
        "Test-Persistence 'file1', 'file2', 'file3', 'file4' -Content 'new', 'new2', 'new3'",
        "    # Empty pipeline",
        "'file5', 'file6', 'file7', 'file8' | Test-Persistence",
        "    # One file with 2 lines",
        "'file9' | Test-Persistence -Content 'alfa', 'new'",
        "Test-Persistence 'alfa.json' -Execution { Write-Host 'This file will not exists', \"[$currentFile]\" -f magenta }",
        "",
        "    # File will be automatically checked against $dir and if exists it will use it.",
        "Edit-File 'vscode-install-context.reg' '$code', '&Code' 'pathToVSCODE.exe', 'Code &Insiders'",
        "Edit-File \"$dir\\vscode-install-context.reg\" 'pathToVSCODE.exe', 'Code &Insiders' 'SECOND REPLACE USING $dir', 'REPLACED AGAIN'",
        "Edit-File 'file9' '^new$' 'completelyNew' -Regex",
        "Edit-File \"$dir\\file9\" 'letely' 'COSI' -Regex",
        "Edit-File 'file9' '^(alfa)$' '${1}NNNNN' -Regex",
        "    # Replace with empty string",
        "Edit-File 'vscode-uninstall-context.reg' 'Windows Registry'",
        "Edit-File \"$dir\\vscode-uninstall-context.reg\" '^\\[-HKEY_.*\\\\command' -Regex",
        "",
        "Remove-AppDirItem 'LICENS*', 'README.md'",
        "Remove-AppDirItem 'cosi\\alfa\\beta\\delta\\necum'",
        "Test-Persistence 'file10' -Execution { write-host $currentFileDir }"
    ],
    "post_install": [
        "Test-Persistence 'file10' -Execution { write-host $currentFileDir }"
    ]
}
TODO
function Copy-ToPersist {
    <#
    .SYNOPSIS
        Manually "persist" file.
    .DESCRIPTION
        In case of file is in nested directory, the structure will not be preserved in $persist_dir
    .PARAMETER Item
        Specifies the items to be copied from $dir into $persist_dir
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
        [SupportsWildcards()]
        [ValidateNotNullOrEmpty()]
        [Alias('Path', 'Name', 'File')]
        [System.IO.FileInfo[]] $Item
    )

    begin { Confirm-DirectoryExistence -Directory $persist_dir | Out-Null }

    process {
        foreach ($it in $Item) {
            Join-Path $dir $it | Copy-Item -Destination $persist_dir -ErrorAction 'SilentlyContinue' -Force
        }
    }
}

function Copy-FromPersist {
    <#
    .SYNOPSIS
        Manually "persist" file.
    .DESCRIPTION
        In case of file is in nested directory, the structure will not be preserved in $dir
    .PARAMETER Item
        Specifies the items to be copied from $persist_dir into $dir
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
        [SupportsWildcards()]
        [ValidateNotNullOrEmpty()]
        [Alias('Path', 'Name', 'File')]
        [System.IO.FileInfo[]] $Item
    )

    begin { Confirm-DirectoryExistence -Directory $persist_dir | Out-Null }

    process {
        foreach ($it in $Item) {
            Join-Path $persist_dir $it | Copy-Item -Destination $dir -ErrorAction 'SilentlyContinue' -Force
        }
    }
}

@Ash258 Ash258 added this to the 0.55 milestone Aug 21, 2020
@Ash258 Ash258 self-assigned this Aug 21, 2020
@Ash258 Ash258 marked this pull request as draft August 21, 2020 19:03
@Ash258 Ash258 marked this pull request as ready for review December 5, 2020 20:21
@Ash258 Ash258 merged commit f3b767c into NEW Dec 5, 2020
@Ash258 Ash258 deleted the manifestHelpersShovel branch December 5, 2020 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant