Skip to content
Permalink
Browse files
Replaced the Gulp build system by PowerShell scripts
  • Loading branch information
cedx committed May 9, 2020
1 parent b0dc1b7 commit 448f92168445508b23562e48762eed01da238a2b
Showing with 110 additions and 93 deletions.
  1. +0 −1 .gitignore
  2. +0 −5 .gulp.json
  3. +1 −4 doc/installation.md
  4. +4 −5 package.json
  5. +18 −0 tool/build.ps1
  6. +11 −0 tool/clean.ps1
  7. +4 −0 tool/coverage.ps1
  8. +6 −0 tool/doc.ps1
  9. +4 −0 tool/fix.ps1
  10. +0 −78 tool/gulpfile.cjs
  11. +4 −0 tool/lint.ps1
  12. +6 −0 tool/publish.ps1
  13. +4 −0 tool/test.ps1
  14. +10 −0 tool/upgrade.ps1
  15. +11 −0 tool/version.ps1
  16. +27 −0 tool/watch.ps1
@@ -14,4 +14,3 @@
/**/.DS_Store
/npm-debug.log
/package-lock.json
/share/*.private.env.json

This file was deleted.

@@ -4,14 +4,11 @@
Before installing **Web Storage for Angular**, you need to make sure you have [Node.js](https://nodejs.org)
and [npm](https://www.npmjs.com), the Node.js package manager, up and running.

!!! warning
Web Storage for Angular requires Node.js >= **14.1.0**.

You can verify if you're already good to go with the following commands:

```shell
node --version
# v14.1.0
# v14.2.0
npm --version
# 6.14.4
@@ -49,7 +49,7 @@
"zone.js": "^0.10.3"
},
"engines": {
"node": ">=14.1.0"
"node": ">=14.2.0"
},
"files": [
"lib/"
@@ -81,9 +81,8 @@
"url": "https://git.belin.io/cedx/ngx-webstorage.git"
},
"scripts": {
"coverage": "gulp coverage",
"prepack": "gulp",
"start": "gulp watch",
"test": "gulp test"
"coverage": "coveralls var/lcov.info",
"prepack": "pwsh tool/build.ps1",
"test": "ng test"
}
}
@@ -0,0 +1,18 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)

node_modules/.bin/ng.ps1 build
if (-not (Test-Path lib)) { New-Item lib -ItemType Directory | Out-Null }

$regex = "(export|import)\s+(.+)\s+from\s+'((?!.*\.js)\.[^']+)'"
foreach ($item in Get-ChildItem build/esm2015 -File -Filter '*.js') {
$file = Get-Content $item -Raw
($file -replace $regex, '$1 $2 from ''$3.js''') -replace "`r?`n//# sourceMappingURL=.*$", '' | Out-File "lib/$($item.Name)"
}

foreach ($item in Get-ChildItem build -File -Filter '*.d.ts') {
Copy-Item $item "lib/$($item.Name)"
}

Remove-Item build -Recurse
@@ -0,0 +1,11 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)

foreach ($item in @('build', 'doc/api', 'lib', 'www')) {
if (Test-Path $item) { Remove-Item $item -Recurse }
}

foreach ($item in Get-ChildItem var -Exclude .gitkeep) {
Remove-Item $item -Recurse
}
@@ -0,0 +1,4 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)
node_modules/.bin/coveralls.ps1 var/lcov.info
@@ -0,0 +1,6 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)

node_modules/.bin/compodoc.ps1 --config=etc/compodoc.yaml
mkdocs build --config-file=etc/mkdocs.yaml
@@ -0,0 +1,4 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)
node_modules/.bin/eslint.ps1 --config=etc/eslint.yaml --fix src/**/*.ts

This file was deleted.

@@ -0,0 +1,4 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)
node_modules/.bin/eslint.ps1 --config=etc/eslint.yaml src/**/*.ts
@@ -0,0 +1,6 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)

tool/clean.ps1
npm publish --registry=https://registry.npmjs.org
@@ -0,0 +1,4 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)
node_modules/.bin/ng.ps1 test
@@ -0,0 +1,10 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)

git reset --hard
git fetch --all --prune
git pull --rebase

npm install --ignore-scripts --production=false
npm update --dev
@@ -0,0 +1,11 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)

$version = (Get-Content package.json | ConvertFrom-Json).version
$lines = @(
'/** The version number of the package. */',
"export const packageVersion: string = '$version';"
)

Set-Content src/cli/version.g.ts ($lines -join [Environment]::NewLine)
@@ -0,0 +1,27 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)
[Console]::TreatControlCAsInput = $true

$action = {
$changeType = [String] $EventArgs.ChangeType
Write-Host "'$($EventArgs.Name)' was $($changeType.ToLower()): starting a new build..."
$timeSpan = Measure-Command { tool/build.ps1 }
Write-Host "> Finished the build after $($timeSpan.TotalSeconds) seconds."
}

$watcher = New-Object System.IO.FileSystemWatcher (Resolve-Path src).Path
$watcher.EnableRaisingEvents = $true
$watcher.IncludeSubdirectories = $true

foreach ($event in @('Changed', 'Created', 'Deleted', 'Renamed')) {
Register-ObjectEvent $watcher $event -Action $action | Out-Null
}

$console = $Host.UI.RawUI;
while ($true) {
if ($console.KeyAvailable -and ($console.ReadKey('AllowCtrlC,IncludeKeyUp,NoEcho').Character -eq 3)) { break }
Start-Sleep -Milliseconds 200
}

Get-EventSubscriber | Unregister-Event

0 comments on commit 448f921

Please sign in to comment.