diff --git a/.gitea/workflows/default_nottags.yaml b/.gitea/workflows/default_nottags.yaml new file mode 100644 index 0000000..0bae651 --- /dev/null +++ b/.gitea/workflows/default_nottags.yaml @@ -0,0 +1,66 @@ +name: Default (not tags) + +on: + push: + tags-ignore: + - '**' + +env: + IMAGE: code.foss.global/host.today/ht-docker-node:npmci + NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git + NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}} + NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}} + NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}} + NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}} + +jobs: + security: + runs-on: ubuntu-latest + continue-on-error: true + container: + image: ${{ env.IMAGE }} + + steps: + - uses: actions/checkout@v3 + + - name: Install pnpm and npmci + run: | + pnpm install -g pnpm + pnpm install -g @ship.zone/npmci + + - name: Run npm prepare + run: npmci npm prepare + + - name: Audit production dependencies + run: | + npmci command npm config set registry https://registry.npmjs.org + npmci command pnpm audit --audit-level=high --prod + continue-on-error: true + + - name: Audit development dependencies + run: | + npmci command npm config set registry https://registry.npmjs.org + npmci command pnpm audit --audit-level=high --dev + continue-on-error: true + + test: + if: ${{ always() }} + needs: security + runs-on: ubuntu-latest + container: + image: ${{ env.IMAGE }} + + steps: + - uses: actions/checkout@v3 + + - name: Test stable + run: | + npmci node install stable + npmci npm install + npmci npm test + + - name: Test build + run: | + npmci node install stable + npmci npm install + npmci npm build diff --git a/.gitea/workflows/default_tags.yaml b/.gitea/workflows/default_tags.yaml new file mode 100644 index 0000000..821d33f --- /dev/null +++ b/.gitea/workflows/default_tags.yaml @@ -0,0 +1,124 @@ +name: Default (tags) + +on: + push: + tags: + - '*' + +env: + IMAGE: code.foss.global/host.today/ht-docker-node:npmci + NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git + NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}} + NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}} + NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}} + NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}} + +jobs: + security: + runs-on: ubuntu-latest + continue-on-error: true + container: + image: ${{ env.IMAGE }} + + steps: + - uses: actions/checkout@v3 + + - name: Prepare + run: | + pnpm install -g pnpm + pnpm install -g @ship.zone/npmci + npmci npm prepare + + - name: Audit production dependencies + run: | + npmci command npm config set registry https://registry.npmjs.org + npmci command pnpm audit --audit-level=high --prod + continue-on-error: true + + - name: Audit development dependencies + run: | + npmci command npm config set registry https://registry.npmjs.org + npmci command pnpm audit --audit-level=high --dev + continue-on-error: true + + test: + if: ${{ always() }} + needs: security + runs-on: ubuntu-latest + container: + image: ${{ env.IMAGE }} + + steps: + - uses: actions/checkout@v3 + + - name: Prepare + run: | + pnpm install -g pnpm + pnpm install -g @ship.zone/npmci + npmci npm prepare + + - name: Test stable + run: | + npmci node install stable + npmci npm install + npmci npm test + + - name: Test build + run: | + npmci node install stable + npmci npm install + npmci npm build + + release: + needs: test + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + container: + image: ${{ env.IMAGE }} + + steps: + - uses: actions/checkout@v3 + + - name: Prepare + run: | + pnpm install -g pnpm + pnpm install -g @ship.zone/npmci + npmci npm prepare + + - name: Release + run: | + npmci node install stable + npmci npm publish + + metadata: + needs: test + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + container: + image: ${{ env.IMAGE }} + continue-on-error: true + + steps: + - uses: actions/checkout@v3 + + - name: Prepare + run: | + pnpm install -g pnpm + pnpm install -g @ship.zone/npmci + npmci npm prepare + + - name: Code quality + run: | + npmci command npm install -g typescript + npmci npm install + + - name: Trigger + run: npmci trigger + + - name: Build docs and upload artifacts + run: | + npmci node install stable + npmci npm install + pnpm install -g @git.zone/tsdoc + npmci command tsdoc + continue-on-error: true diff --git a/.gitignore b/.gitignore index ef13c79..0b26089 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ # artifacts coverage/ public/ -pages/ # installs node_modules/ @@ -17,4 +16,4 @@ node_modules/ dist/ dist_*/ -# custom \ No newline at end of file +#------# custom \ No newline at end of file diff --git a/changelog.md b/changelog.md index 0399b7e..aa53c27 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-01-29 - 2.1.0 - feat(CI) +Add Continuous Integration workflows for Gitea with Docker-based setup + +- Added new CI workflows for handling both regular and tagged pushes in Gitea. +- Integrated security audits and setup tasks using Docker images in the CI workflows. +- Ensured that CI includes testing, building, and releasing steps as per tag events. + ## 2025-01-29 - 2.0.39 - fix(package.json) Add pnpm overrides configuration for peek-readable package diff --git a/npmextra.json b/npmextra.json index 380f3e8..0ead8d4 100644 --- a/npmextra.json +++ b/npmextra.json @@ -6,8 +6,8 @@ "gitzone": { "projectType": "npm", "module": { - "githost": "gitlab.com", - "gitscope": "gitzone", + "githost": "code.foss.global", + "gitscope": "git.zone", "gitrepo": "tswatch", "shortDescription": "watch typescript projects during development", "npmPackagename": "@git.zone/tswatch", diff --git a/package.json b/package.json index 28a5648..2108a25 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ }, "scripts": { "test": "(tstest test/ --web)", - "build": "(tsbuild --web --allowimplicitany)" + "build": "(tsbuild --web --allowimplicitany)", + "buildDocs": "tsdoc" }, "devDependencies": { "@git.zone/tsbuild": "^2.2.1", @@ -72,9 +73,15 @@ "node.js", "development server" ], + "repository": { + "type": "git", + "url": "https://code.foss.global/git.zone/tswatch.git" + }, + "bugs": { + "url": "https://code.foss.global/git.zone/tswatch/issues" + }, + "homepage": "https://code.foss.global/git.zone/tswatch#readme", "pnpm": { - "overrides": { - "peek-readable": "5.3.1" - } + "overrides": {} } -} +} \ No newline at end of file diff --git a/readme.md b/readme.md index f94da65..357aee7 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,5 @@ # @git.zone/tswatch + A development tool for watching and re-compiling TypeScript projects automatically upon detecting changes. ## Install @@ -141,9 +142,9 @@ import { TsWatch } from '@git.zone/tswatch'; const setupMultipleWatchers = async () => { const tsWatchInstance = new TsWatch('node'); - + // View active watchers through instance mapping - tsWatchInstance.watcherMap.forEach(watcher => { + tsWatchInstance.watcherMap.forEach((watcher) => { console.log(`Watcher listening on: ${watcher.toString()}`); }); @@ -180,7 +181,7 @@ Explore the various features and tailor the tool to fit your unique project requ ## License and Legal Information -This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 64afcf7..1da0822 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tswatch', - version: '2.0.39', + version: '2.1.0', description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.' } diff --git a/ts/interfaces/interfaces.watchmodes.ts b/ts/interfaces/interfaces.watchmodes.ts index 5444cff..510ed6e 100644 --- a/ts/interfaces/interfaces.watchmodes.ts +++ b/ts/interfaces/interfaces.watchmodes.ts @@ -1,7 +1 @@ -export type TWatchModes = - | 'test' - | 'node' - | 'service' - | 'element' - | 'website' - | 'echo'; +export type TWatchModes = 'test' | 'node' | 'service' | 'element' | 'website' | 'echo'; diff --git a/ts/tswatch.classes.tswatch.ts b/ts/tswatch.classes.tswatch.ts index aa5905d..909b3e6 100644 --- a/ts/tswatch.classes.tswatch.ts +++ b/ts/tswatch.classes.tswatch.ts @@ -31,7 +31,7 @@ export class TsWatch { filePathToWatch: paths.cwd, commandToExecute: 'npm run test2', timeout: null, - }) + }), ); break; case 'node': @@ -40,7 +40,7 @@ export class TsWatch { filePathToWatch: paths.cwd, commandToExecute: 'npm run test', timeout: null, - }) + }), ); break; case 'element': @@ -51,7 +51,7 @@ export class TsWatch { // lets create a standard server logger.log( 'info', - 'bundling TypeScript files to "dist_watch" Note: This is for development only!' + 'bundling TypeScript files to "dist_watch" Note: This is for development only!', ); this.typedserver = new plugins.typedserver.TypedServer({ cors: true, @@ -75,13 +75,13 @@ export class TsWatch { await bundleAndReloadElement(); }, timeout: null, - }) + }), ); // lets get the other ts folders let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd); tsfolders = tsfolders.filter( - (itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web' + (itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web', ); const smartshellInstance = new plugins.smartshell.Smartshell({ executor: 'bash', @@ -97,7 +97,7 @@ export class TsWatch { await bundleAndReloadElement(); }, timeout: null, - }) + }), ); } @@ -113,7 +113,7 @@ export class TsWatch { await bundleAndReloadElement(); }, timeout: null, - }) + }), ); })(); break; @@ -127,7 +127,7 @@ export class TsWatch { }; let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd); tsfolders = tsfolders.filter( - (itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web' + (itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web', ); for (const tsfolder of tsfolders) { this.watcherMap.add( @@ -138,7 +138,7 @@ export class TsWatch { await bundleAndReloadWebsite(); }, timeout: null, - }) + }), ); } this.watcherMap.add( @@ -148,7 +148,7 @@ export class TsWatch { await bundleAndReloadWebsite(); }, timeout: null, - }) + }), ); this.watcherMap.add( new Watcher({ @@ -162,7 +162,17 @@ export class TsWatch { await bundleAndReloadWebsite(); }, timeout: null, - }) + }), + ); + this.watcherMap.add( + new Watcher({ + filePathToWatch: plugins.path.join(paths.cwd, './assets/'), + functionToCall: async () => { + await assetsHandler.processAssets(); + await bundleAndReloadWebsite(); + }, + timeout: null, + }), ); })(); break; @@ -172,7 +182,7 @@ export class TsWatch { filePathToWatch: plugins.path.join(paths.cwd, './ts/'), commandToExecute: 'npm run startTs', timeout: null, - }) + }), ); break; case 'echo': diff --git a/ts/tswatch.classes.watcher.ts b/ts/tswatch.classes.watcher.ts index 033b26a..aacc939 100644 --- a/ts/tswatch.classes.watcher.ts +++ b/ts/tswatch.classes.watcher.ts @@ -56,7 +56,7 @@ export class Watcher { logger.log('ok', `executing ${this.options.commandToExecute} for the first time`); } this.currentExecution = await this.smartshellInstance.execStreaming( - this.options.commandToExecute + this.options.commandToExecute, ); } else { console.log('no executionCommand set'); @@ -64,7 +64,7 @@ export class Watcher { if (this.options.functionToCall) { this.options.functionToCall(); } else { - console.log('no functionToCall set.') + console.log('no functionToCall set.'); } } diff --git a/ts/tswatch.cli.ts b/ts/tswatch.cli.ts index 6eb2009..abfdf9a 100644 --- a/ts/tswatch.cli.ts +++ b/ts/tswatch.cli.ts @@ -7,9 +7,9 @@ import { TsWatch } from './tswatch.classes.tswatch.js'; const tswatchCli = new plugins.smartcli.Smartcli(); // standard behaviour will assume gitzone setup -tswatchCli.standardCommand().subscribe((argvArg => { +tswatchCli.standardCommand().subscribe((argvArg) => { tswatchCli.triggerCommand('npm', {}); -})) +}); tswatchCli.addCommand('element').subscribe(async (argvArg) => { logger.log('info', `running watch task for a gitzone element project`); diff --git a/ts/tswatch.plugins.ts b/ts/tswatch.plugins.ts index 2aeaac2..6860caf 100644 --- a/ts/tswatch.plugins.ts +++ b/ts/tswatch.plugins.ts @@ -4,16 +4,12 @@ export { path }; // @gitzone scope import * as tsbundle from '@git.zone/tsbundle'; -export { - tsbundle -} +export { tsbundle }; // @apiglobal scope import * as typedserver from '@api.global/typedserver'; -export { - typedserver, -} +export { typedserver }; // @pushrocks scope import * as lik from '@push.rocks/lik'; diff --git a/tsconfig.json b/tsconfig.json index dfe5a55..2413b93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,11 @@ "module": "NodeNext", "moduleResolution": "NodeNext", "esModuleInterop": true, - "verbatimModuleSyntax": true + "verbatimModuleSyntax": true, + "baseUrl": ".", + "paths": {} }, "exclude": [ "dist_*/**/*.d.ts" ] -} +} \ No newline at end of file