diff --git a/.github/os-git-actions/manual-commit/action.yml b/.github/os-git-actions/manual-commit/action.yml index 0aa04e76..895e35c7 100644 --- a/.github/os-git-actions/manual-commit/action.yml +++ b/.github/os-git-actions/manual-commit/action.yml @@ -19,7 +19,7 @@ runs: steps: - name: Add new files (if needed) shell: bash - if: ${{ inputs.newFiles }} + if: ${{ inputs.newFiles == 'true' }} run: | git add . diff --git a/.github/os-git-actions/signed-commit/action.yml b/.github/os-git-actions/signed-commit/action.yml index a997e72b..f200b112 100644 --- a/.github/os-git-actions/signed-commit/action.yml +++ b/.github/os-git-actions/signed-commit/action.yml @@ -26,13 +26,13 @@ runs: using: composite steps: - name: Setup GPG to sign commits - uses: ./.github/setup-gpg/ + uses: ./.github/os-git-actions/setup-gpg/ with: gpgPriv: ${{ inputs.gpgPriv }} gpgPassPhrase: ${{ inputs.gpgPassPhrase }} - name: Perform git commit - uses: ./.github/manual-commit/ + uses: ./.github/os-git-actions/manual-commit/ with: branch: ${{ inputs.branch }} message: ${{ inputs.message }} diff --git a/.github/workflows/AddInnerSourcingLabel.yml b/.github/workflows/AddInnerSourcingLabel.yml new file mode 100644 index 00000000..f4b96925 --- /dev/null +++ b/.github/workflows/AddInnerSourcingLabel.yml @@ -0,0 +1,13 @@ +name: Add Inner Sourcing Label + +on: + pull_request: + types: + - opened + +jobs: + inner_sourcing: + uses: OutSystems/rd.github-reusable-workflows/.github/workflows/add-inner-sourcing-label.yaml@v2.0.2 + with: + codeowners-path: .github/CODEOWNERS + secrets: inherit diff --git a/.github/workflows/dev-pr.yml b/.github/workflows/DevPR.yml similarity index 76% rename from .github/workflows/dev-pr.yml rename to .github/workflows/DevPR.yml index 18432f30..2c23ab68 100644 --- a/.github/workflows/dev-pr.yml +++ b/.github/workflows/DevPR.yml @@ -1,11 +1,9 @@ -name: DEV_PR +name: PullRequest into Dev branch on: # Triggers the workflow on push events but only for the "dev" branch. pull_request: branches: ['dev'] - workflow_dispatch: - jobs: eslint: runs-on: ubuntu-latest @@ -16,10 +14,6 @@ jobs: - name: Checkout branch dev uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '16.x' - - name: Install project dependencies run: npm install @@ -33,10 +27,6 @@ jobs: - name: Checkout branch dev uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: '16.x' - - name: Install project dependencies run: npm install diff --git a/.github/workflows/PreRelease.yml b/.github/workflows/PreRelease.yml new file mode 100644 index 00000000..516514ab --- /dev/null +++ b/.github/workflows/PreRelease.yml @@ -0,0 +1,123 @@ +name: Pre-Release + +on: + workflow_dispatch: + inputs: + new-version: + description: 'New version to be set. (1.0.1)' + type: string + required: true + release-date: + description: 'Release date. (YYYY-MM-DD)' + type: string + required: true + new-dev-release: + description: 'Set the new dev version. (1.0.1)' + type: string + required: false + +jobs: + run-lint-on-dev: + runs-on: ubuntu-latest + + if: ${{ inputs.new-version }} + steps: + - name: Checkout into dev + uses: actions/checkout@v4 + with: + ref: dev + token: ${{ secrets.PAT }} + + - name: Install project dependencies + run: npm install + + - name: Run build + run: npm run build + + create-rc: + needs: run-lint-on-dev + runs-on: ubuntu-latest + + if: ${{ inputs.new-version }} + steps: + - name: Checkout into dev + uses: actions/checkout@v4 + with: + ref: dev + token: ${{ secrets.PAT }} + + - name: Create branch rc${{ inputs.new-version }} + run: | + git checkout -b rc${{ inputs.new-version }} + git push -u origin rc${{ inputs.new-version }} + + set-tag: + needs: create-rc + runs-on: ubuntu-latest + + if: ${{ inputs.new-version }} + steps: + - name: Checkout into rc${{ inputs.new-version }} + uses: actions/checkout@v4 + with: + ref: rc${{ inputs.new-version }} + fetch-depth: 0 + token: ${{ secrets.PAT }} + + - name: Set tag + run: | + git tag v${{ inputs.new-version }} HEAD + git push origin --tags + + set-pre-release: + needs: set-tag + runs-on: ubuntu-latest + + if: ${{ inputs.new-version }} + steps: + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v2.0.5 + with: + tag_name: v${{ inputs.new-version }} + name: Release of version ${{ inputs.new-version }} (${{ inputs.release-date }}) + body: | + ### What's New + - First + - ... + + ### Fixed Issues and Improvements + - First + - ... + + draft: false + prerelease: true + token: ${{ secrets.PAT }} + + update-dev-version: + needs: create-rc + runs-on: ubuntu-latest + + if: ${{ inputs.new-version && inputs.new-dev-release }} + steps: + - name: Checkout into dev + uses: actions/checkout@v4 + with: + ref: dev + token: ${{ secrets.PAT }} + + - name: Install project dependencies + run: npm install + + - name: Update dev version into v${{ inputs.new-dev-release }} + run: | + npm run gta-update-version --newVersion=${{ inputs.new-dev-release }} + + - name: Sign and Commit version increment to branch dev + uses: ./.github/os-git-actions/signed-commit/ + with: + branch: dev + message: 'Updated into v${{ inputs.new-dev-release }} [skip ci]' + newFiles: true + gpgPriv: ${{ secrets.GPG_SIGN_KEY }} + gpgPassPhrase: ${{ secrets.GPG_PASSPHRASE }} diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 00000000..9eb738f9 --- /dev/null +++ b/.github/workflows/Release.yml @@ -0,0 +1,78 @@ +name: Release + +on: + workflow_dispatch: + inputs: + new-version: + description: 'Version to be released.' + type: string + required: true + update-prerelease-into-latest: + description: 'Update pre-release into latest.' + type: boolean + default: true + delete-rc-branch: + description: 'Delete rc* branch at the end of process.' + type: boolean + default: true + +jobs: + run-lint-on-rc: + runs-on: ubuntu-latest + + if: ${{ inputs.new-version }} + steps: + - name: Checkout into rc${{ inputs.new-version }} + uses: actions/checkout@v4 + with: + ref: rc${{ inputs.new-version }} + token: ${{ secrets.PAT }} + + - name: Install project dependencies + run: npm install + + - name: Run build + run: npm run build + + merge-rc-into-main: + needs: run-lint-on-rc + runs-on: ubuntu-latest + + if: ${{ inputs.new-version }} + steps: + - name: Merge rc${{ inputs.new-version }} into main + uses: everlytic/branch-merge@1.1.5 + with: + github_token: ${{ secrets.PAT }} + source_ref: rc${{ inputs.new-version }} + target_branch: 'main' + commit_message_template: 'Merged rc${{ inputs.new-version }} into main. [skip ci]' + + set-pre-release-as-lts: + needs: merge-rc-into-main + runs-on: ubuntu-latest + + steps: + - name: Update v${{ inputs.new-version }} Tag Release from pre-release into latest + if: ${{ inputs.new-version && inputs.update-prerelease-into-latest == true }} + uses: softprops/action-gh-release@v2.0.5 + with: + tag_name: v${{ inputs.new-version }} + prerelease: false + token: ${{ secrets.PAT }} + + delete-rc-branch: + needs: merge-rc-into-main + runs-on: ubuntu-latest + + if: ${{ inputs.delete-rc-branch == true }} + steps: + - name: Checkout branch dev + uses: actions/checkout@v4 + with: + ref: dev + + - name: Delete branch rc${{ inputs.new-version }} + shell: bash + run: | + git push origin -d rc${{ inputs.new-version }} diff --git a/.github/workflows/ValidatePRLabels.yml b/.github/workflows/ValidatePRLabels.yml new file mode 100644 index 00000000..ebdfd039 --- /dev/null +++ b/.github/workflows/ValidatePRLabels.yml @@ -0,0 +1,9 @@ +name: Validate pull request labels + +on: + pull_request: + types: [opened, reopened, labeled, unlabeled] + +jobs: + check-label: + uses: OutSystems/rd.github-reusable-workflows/.github/workflows/validate-pr-labels.yaml@v2.0.2 diff --git a/.github/workflows/ValidatePRTitle.yml b/.github/workflows/ValidatePRTitle.yml new file mode 100644 index 00000000..bab64f95 --- /dev/null +++ b/.github/workflows/ValidatePRTitle.yml @@ -0,0 +1,11 @@ +name: Validate pull request title + +on: + pull_request: + types: [opened, reopened, edited] + +jobs: + build: + uses: OutSystems/rd.github-reusable-workflows/.github/workflows/validate-pr-title.yaml@v2.0.2 + with: + validate-semVer: false diff --git a/.github/workflows/main-push.yml b/.github/workflows/main-push.yml deleted file mode 100644 index e62c5e03..00000000 --- a/.github/workflows/main-push.yml +++ /dev/null @@ -1,86 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: MAIN_PUSH - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the dev branch - push: - branches: ['main'] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - eslint: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./ - steps: - - name: Checkout branch main - uses: actions/checkout@v2 - - - uses: actions/setup-node@v1 - with: - node-version: '16.x' - - - name: Install project dependencies - run: npm install - - - name: Run lint - run: npm run lint - - compile-code: - needs: eslint - runs-on: ubuntu-latest - steps: - - name: Checkout branch dev - uses: actions/checkout@v2 - - - uses: actions/setup-node@v1 - with: - node-version: '16.x' - - - name: Install project dependencies - run: npm install - - - name: Compile code - run: npm run build - - documentation: - needs: compile-code - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Checkout branch main - uses: actions/checkout@v3 - with: - ref: dev - token: ${{ secrets.PAT }} - - - name: Install graphviz - run: sudo apt install -y graphviz - - - uses: actions/setup-node@v3 - with: - node-version: 16 - cache: 'npm' - - - name: Install project dependencies - run: npm install - - - name: Generate documentation - run: npm run docs - - - name: Sign and commit documentation to branch dev - uses: ./.github/os-git-actions/signed-commit/ - with: - branch: main - message: 'Update documentation [skip ci]' - newFiles: true - gpgPriv: ${{ secrets.GPG_SIGN_KEY }} - gpgPassPhrase: ${{ secrets.GPG_PASSPHRASE }} diff --git a/README.md b/README.md index bfe848d5..85f58257 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# OutSystems Maps · [![GitHub license](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/OutSystems/outsystems-maps/blob/master/LICENSE) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg) +# OutSystems Maps · v1.8.0 + +![GitHub License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg) + Add maps to your applications **OutSystems Reactive Web apps** with a single or multiple locations. Fully customizable and adaptable, allows you to change map behaviors, customize your map, add markers and customize each of them, according to your use case. diff --git a/gulp/DefaultSpecs.js b/gulp/DefaultSpecs.js new file mode 100644 index 00000000..0a619110 --- /dev/null +++ b/gulp/DefaultSpecs.js @@ -0,0 +1,31 @@ +/* + * Global constants info + **/ +const constants = { + fileName: 'OutSystemsMaps', + gitUrl: 'https://github.com/OutSystems/outsystems-maps', + websiteUrl: 'hhttps://outsystemsui.outsystems.com/OutSystemsMapsSample/', + envType: { + development: 'dev', + production: 'prod', + }, + // list of files to be excluded from a specific platform + excludeFromTsTranspile: {}, + // list of platforms to compile and create scss files. + platformTarget: { + default: '', + }, +}; + +// Store the default project specifications +const specs = { + version: '1.8.0', + name: 'OutSystems Maps', + description: '', + url: 'Website:\n • ' + constants.websiteUrl, + gitHub: 'GitHub:\n • ' + constants.gitUrl, +}; + +// Expose sections info! +exports.info = specs; +exports.globalConsts = constants; diff --git a/gulp/README.md b/gulp/README.md new file mode 100644 index 00000000..87b565d0 --- /dev/null +++ b/gulp/README.md @@ -0,0 +1,35 @@ +# Gulp + +

+ + + +

Our streaming build system

+

+ + +## This folder contains: + + + +## Project Structure + +Bellow there is some comments about the application structure. + + . + | + ├── gulpfile.js # gulp orchestrator + ├── ... + ├── gulp # Contains gulp specific tasks and templates + | └── Tasks + | ├── TsTranspile.js # TypeScript transpile task definition + | └── UpdateVersion.js # Task used to update the repository task dynamically + | + ├── ... diff --git a/gulp/Tasks/TsTanspile.js b/gulp/Tasks/TsTanspile.js new file mode 100644 index 00000000..10d925a4 --- /dev/null +++ b/gulp/Tasks/TsTanspile.js @@ -0,0 +1,205 @@ +const gulp = require('gulp'); +const { series } = require('gulp'); +const fs = require('fs'); +const sourcemaps = require('gulp-sourcemaps'); +const ts = require('gulp-typescript'); + +const distFolder = './dist'; +const project = require('../DefaultSpecs'); + +let defaultTsConfigText = ''; +let filesPath = {}; + +// Method that will check if platformType has been defined through npm inline variable. If yes, that's the one to be tackled +function getDefaultPlatformType(platformType) { + const pt = { + error: false, + shouldCreateAll: true, + type: '', + }; + + // Check if a platformType has been passed as an npm inline script value + if (process.env.npm_config_target !== undefined) { + if (project.globalConsts.platformTarget[process.env.npm_config_target] === undefined) { + pt.error = true; + pt.errorMessage = `Given platform '${ + process.env.npm_config_target + }' does not exist. Plaforms availabe:\n • ${Object.keys(project.globalConsts.platformTarget).join( + '\n • ' + )}`; + } else { + pt.type = process.env.npm_config_target; + pt.shouldCreateAll = false; + } + } else { + pt.type = platformType !== undefined ? platformType : Object.keys(project.globalConsts.platformTarget)[0]; + } + + return pt; +} + +// Method that will handle the end of tsCompilation +function onTsCompileFinish(platformType, cb, shouldCreateAll) { + const pts = project.globalConsts.platformTarget; + if (shouldCreateAll === false || platformType === pts[Object.keys(pts)[Object.keys(pts).length - 1]]) { + cb(); + } +} + +// Update tsConfig after the compilation in order to ensure it will not be changed dynamically +function rollBackTsConfigFile() { + // Update file with the default text! + fs.writeFileSync('tsconfig.json', defaultTsConfigText, 'utf8'); + defaultTsConfigText = ''; +} + +// Compile TypeScript +function tsTranspile(cb, envMode, platformType) { + // Store the default platformType + const pt = getDefaultPlatformType(platformType); + // Check if platformTye exist and it's valid + if (pt.error) { + console.log(`\n⛔️ ERROR: ${pt.errorMessage}\n`); + return; + } + // Set filesPath accordingly as well + filesPath[pt.type] = `${distFolder}/${envMode === project.globalConsts.envType.production ? '' : envMode + '.'}${ + project.globalConsts.platformTarget[pt.type] !== '' ? project.globalConsts.platformTarget[pt.type] + '.' : '' + }${project.globalConsts.fileName}.js`; + // Update tsConfig file and do the Ts compilation accordingly + updateTsConfigFile(cb, envMode, project.globalConsts.platformTarget[pt.type], pt.shouldCreateAll); + // Check if there is still any pending platform to tackle + if ( + pt.shouldCreateAll && + pt.type !== + Object.keys(project.globalConsts.platformTarget)[ + Object.keys(project.globalConsts.platformTarget).length - 1 + ] + ) { + tsTranspile( + cb, + envMode, + Object.keys(project.globalConsts.platformTarget)[ + Object.keys(project.globalConsts.platformTarget).indexOf(pt.type) + 1 + ] + ); + } +} + +// Method that will trigger the transpile of Ts according if it's development or production mode and platform type (O11 or ODC) +async function tsTranspileBasedOnPlatform(cb, envMode, platformType, shouldCreateAll) { + let tsProject = ts.createProject('tsconfig.json', { + outDir: distFolder, + declaration: envMode === project.globalConsts.envType.production ? true : false, + outFile: `${envMode === project.globalConsts.envType.production ? '' : envMode + '.'}${ + platformType !== '' ? platformType + '.' : '' + }${project.globalConsts.fileName}.js`, + }); + + if (envMode === project.globalConsts.envType.development) { + tsProject + .src() + .pipe(sourcemaps.init()) + .pipe(tsProject()) + .js.pipe(sourcemaps.write('.')) + .pipe(gulp.dest(distFolder)) + .on('finish', () => { + onTsCompileFinish(platformType, cb, shouldCreateAll); + }); + } else { + tsProject + .src() + .pipe(tsProject()) + .pipe(gulp.dest(distFolder)) + .on('finish', () => { + onTsCompileFinish(platformType, cb, shouldCreateAll); + }); + } + + // Rollback tsconfig file to the default state + if (defaultTsConfigText !== '') { + rollBackTsConfigFile(); + } +} + +// Set as Development Mode +function tsTranspileDev(cb) { + tsTranspile(cb, project.globalConsts.envType.development); +} + +// Set as Production Mode +function tsTranspileProd(cb) { + tsTranspile(cb, project.globalConsts.envType.production); +} + +// Add section info to the compiled files. +function updateFwkAndPlatformInfo(cb) { + for (const pt in filesPath) { + // Set the Specifications text info + let specsInfo = ''; + + specsInfo += `/*!\n`; + specsInfo += `${project.info.name} ${project.info.version} ${ + project.globalConsts.platformTarget[pt] !== '' + ? '• ' + project.globalConsts.platformTarget[pt] + ' Platform' + : '' + }\n`; + if (project.info.description !== '') { + specsInfo += `${project.info.description}\n`; + } + specsInfo += `${project.info.url}\n`; + specsInfo += `${project.info.gitHub}\n`; + specsInfo += `*/ \n`; + + // Read file code + let jsCode = fs.readFileSync(filesPath[pt], 'utf8'); + // Set *.d.ts file path + const dtsFilePath = filesPath[pt].replace('.js', '.d.ts'); + // Check if the *.d.ts file exist + let dtsCode = fs.existsSync(dtsFilePath) ? fs.readFileSync(dtsFilePath, 'utf8') : null; + + // Set platformType to the src/OSFramework/DataGrid/Constants.ts + jsCode = jsCode.replace('<->platformType<->', project.globalConsts.platformTarget[pt]); + dtsCode = + dtsCode !== null ? dtsCode.replace('<->platformType<->', project.globalConsts.platformTarget[pt]) : null; + + // Update code + let updatedCode = specsInfo + jsCode; + let updatedDtsCode = dtsCode !== null ? specsInfo + dtsCode : null; + + // Ensure code will be set properly before set the update. + setTimeout(() => { + // Update the existing file info with the new one! + fs.writeFileSync(filesPath[pt], updatedCode, 'utf8'); + if (updatedDtsCode !== null) { + fs.writeFileSync(dtsFilePath, updatedDtsCode, 'utf8'); + } + }, 0); + } + + cb(); +} + +// Method that will update the tsConfig file in order to set the exclude files under given platformType +function updateTsConfigFile(cb, envMode, platformType, shouldCreateAll) { + // Check if there are anything that should be ignored + if (project.globalConsts.excludeFromTsTranspile[platformType] !== undefined) { + // Get the text from tsConfig file + let code = fs.readFileSync('tsconfig.json', 'utf8'); + // Store tsConfig text before updating it! + defaultTsConfigText = code; + + // Create the new exclude text block + const replaceInto = `"exclude": ${JSON.stringify(project.globalConsts.excludeFromTsTranspile[platformType])},`; + // Replace the text from the default one into the updated one! + code = code.replace('"exclude": [],', replaceInto); + // Update file! + fs.writeFileSync('tsconfig.json', code, 'utf8'); + } + + tsTranspileBasedOnPlatform(cb, envMode, platformType, shouldCreateAll); +} + +// TypeScript Transpile Task +exports.transpileDev = series(tsTranspileDev, updateFwkAndPlatformInfo); +exports.transpileProd = series(tsTranspileProd, updateFwkAndPlatformInfo); diff --git a/gulp/Tasks/UpdateVersion.js b/gulp/Tasks/UpdateVersion.js new file mode 100644 index 00000000..8e239485 --- /dev/null +++ b/gulp/Tasks/UpdateVersion.js @@ -0,0 +1,102 @@ +const prompts = require('prompts'); +const fs = require('fs'); + +// Get the default specs +const defaultSpecs = require('./../DefaultSpecs'); + +// Store the new version +let newVersionToBeSet = ''; + +// List of files path to be updated +let filesList = { + constants: './src/OSFramework/Maps/Constants.ts', + package: './package.json', + readme: './README.md', + specs: './gulp/DefaultSpecs.js', +}; + +// Prompt question about the new version to be set +function askForNewVersion(cb) { + (async () => { + const answer = await prompts([ + { + message: 'Set the new version', + name: 'newVersion', + type: 'text', + initial: 'v' + defaultSpecs.info.version, + }, + { + active: 'yes', + inactive: 'no', + initial: true, + message: (prev) => 'Do you confirm the new version will be set is: ' + prev + '?', + name: 'confirm', + type: (prev) => (prev ? 'toggle' : null), + }, + ]); + + if (answer.newVersion && answer.confirm === true) { + newVersionToBeSet = answer.newVersion.replace('v', ''); + getFilesList(cb); + } else { + console.warn(`\n ❌ Process has been canceled! \n \n`); + cb(); + } + })(); +} + +// Get the list of file where the version must be updated! +function getFilesList(cb) { + // Go through all files to be updated! + for (const path in filesList) { + // Find for text + let findFor = ''; + let replaceTo = ''; + + switch (filesList[path]) { + case filesList.constants: + findFor = `OSMapsVersion = '${defaultSpecs.info.version}';`; + replaceTo = `OSMapsVersion = '${newVersionToBeSet}';`; + break; + + case filesList.package: + findFor = `"version": "${defaultSpecs.info.version}",`; + replaceTo = `"version": "${newVersionToBeSet}",`; + break; + + case filesList.specs: + findFor = `version: '${defaultSpecs.info.version}',`; + replaceTo = `version: '${newVersionToBeSet}',`; + break; + + case filesList.readme: + findFor = `# OutSystems Maps · v${defaultSpecs.info.version}`; + replaceTo = `# OutSystems Maps · v${newVersionToBeSet}`; + break; + } + + // Read file code + let code = fs.readFileSync(filesList[path], 'utf8'); + // Update code + let updatedCode = code.replace(findFor, replaceTo); + // Update the existing file info with the new one! + fs.writeFileSync(filesList[path], updatedCode, 'utf8'); + } + + cb(); +} + +// Set the new version script triggered by the GitHub Action, where the new verion will be passed by script variable --newVersion +function gtaSetNewVersion(cb) { + // Check if version exist + if (process.env.npm_config_newversion === undefined) { + console.log(`\n⛔️ ERROR: --newVersion is missing at the script!\n`); + return; + } + // Store the version to be set + newVersionToBeSet = process.env.npm_config_newversion.replace('v', ''); + getFilesList(cb); +} + +exports.setVersion = askForNewVersion; +exports.gtaSetVersion = gtaSetNewVersion; diff --git a/gulp/Template/index.html b/gulp/Template/index.html new file mode 100644 index 00000000..b96428f5 --- /dev/null +++ b/gulp/Template/index.html @@ -0,0 +1,123 @@ + + + + + + + _asset-name_ Dev Mode + + + + + +
+
+ +

+ _asset-name_ • --platform-- +

+

Development mode...

+
+
+
+ +

Welcome to the development mode of _asset-name_.
Here you can find links to the generated files from + our repository.

+
+
+

Below are the links to the generated files:

+
    +
  • +

    Javascript file generated by the TypeScript compilation

    +
      + +
    • jsListItemToBeReplaced
    • +
    +
  • + +
+ +

More info about the repository, here.

+
+
+
+ + + \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..d06f7dd7 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,75 @@ +const gulp = require('gulp'); +const { watch, series, parallel } = require('gulp'); +const browser = require('browser-sync'); +const clean = require('gulp-clean'); +const fs = require('fs'); + +// Get dependencies tasks +const project = require('./gulp/DefaultSpecs'); +const tsTranspile = require('./gulp/Tasks/TsTanspile'); +const updatetVersion = require('./gulp/Tasks/UpdateVersion'); + +// Local configs +const distFolder = './dist'; +const serverPort = 3000; +const watchTsFiles = 'src/**/*.ts'; + +// Clean Dist Folder +function cleanOldFiles(cb) { + if (fs.existsSync(distFolder)) { + gulp.src(distFolder + '/*', { read: false }).pipe(clean()); + } + cb(); +} + +// Starts a Browser instance +function initServer() { + updateIndexTemplateFile(); + setTimeout(() => { + browser.init({ server: distFolder, port: serverPort, cors: true }); + }, 0); +} + +// Method to update development template code +function updateIndexTemplateFile() { + // Get the index.html base file + let code = fs.readFileSync('./gulp/Template/index.html', 'utf8'); + + let jsLinks = ''; + + if ( + process.env.npm_config_target !== undefined && + project.globalConsts.platformTarget[process.env.npm_config_target] !== undefined + ) { + const platformType = project.globalConsts.platformTarget[process.env.npm_config_target]; + code = code.replace(' • --platform--', platformType !== '' ? ' • ' + platformType : ''); + jsLinks = `
  • ${platformType !== '' ? platformType + '.' : ''}${project.globalConsts.fileName}.js

  • `; + } else { + code = code.replace(' • --platform--', ''); + const pts = project.globalConsts.platformTarget; + for (const pt in pts) { + jsLinks += `
  • ${pts[pt] !== '' ? pts[pt] + '.' : ''}${project.globalConsts.fileName}.js

  • \n`; + } + } + code = code.replace('
  • jsListItemToBeReplaced
  • ', jsLinks); + code = code.replaceAll('_asset-name_', project.globalConsts.fileName); + code = code.replace('_more-info-repo-link_', project.globalConsts.gitUrl); + + // Create the new index.html at the dist folder! + fs.writeFileSync(`${distFolder}/index.html`, code, 'utf8'); +} + +// Watch files changed +function watchFiles() { + watch(watchTsFiles, series(tsTranspile.transpileDev)); +} + +// Gulp tasks +exports.startDevelopment = series(cleanOldFiles, tsTranspile.transpileDev, parallel(watchFiles, initServer)); +exports.createProduction = series(cleanOldFiles, tsTranspile.transpileProd); +exports.updateVersion = updatetVersion.setVersion; +exports.gtaSetVersion = updatetVersion.gtaSetVersion; diff --git a/package.json b/package.json index 238b2317..1c8bfde1 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,15 @@ "author": "UI Components Team", "license": "BSD-3-Clause", "scripts": { - "build": "tsc && npm run lint", + "build": "gulp createProduction && npm run lint", + "dev": "gulp startDevelopment", + "docs": "npx typedoc", "lint": "eslint . --ext .ts", - "lintfix": "eslint . --fix --ext .ts", + "lintfix": "eslint . --ext .ts", "prettier": "prettier --config ./.prettierrc.json --write \"**/*.+(js|ts|css)\"", - "setup": "npm i && tsc", "test": "echo \"Error: no test specified\" && exit 1", - "docs": "npx typedoc" + "update-version": "gulp updateVersion", + "gta-update-version": "gulp gtaSetVersion --from" }, "repository": { "type": "git", @@ -24,20 +26,28 @@ "devDependencies": { "@googlemaps/markerclusterer": "^2.5.3", "@types/google.maps": "^3.46.0", - "@types/leaflet": "^1.7.5", "@types/leaflet-routing-machine": "^3.2.3", + "@types/leaflet": "^1.7.5", "@typescript-eslint/eslint-plugin": "^6.19.1", "@typescript-eslint/parser": "^6.19.1", - "eslint": "^8.56.0", + "browser-sync": "^3.0.2", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", + "eslint": "^8.56.0", + "fancy-log": "^2.0.0", + "gulp-clean": "^0.4.0", + "gulp-confirm": "^1.0.8", + "gulp-sourcemaps": "^3.0.0", + "gulp-typescript": "^6.0.0-alpha.1", + "gulp": "^4.0.2", "prettier-eslint": "^16.3.0", - "stylelint": "^14.16.1", + "prompts": "^2.4.2", "stylelint-config-prettier": "^9.0.5", "stylelint-order": "^6.0.4", - "typedoc": "^0.23.9", + "stylelint": "^14.16.1", "typedoc-plugin-merge-modules": "^4.0.1", "typedoc-umlclass": "^0.7.0", + "typedoc": "^0.23.9", "typescript": "^4.5.0" } -} +} \ No newline at end of file diff --git a/src/OSFramework/Maps/Constants.ts b/src/OSFramework/Maps/Constants.ts index 4cd52b34..aafcf9d2 100644 --- a/src/OSFramework/Maps/Constants.ts +++ b/src/OSFramework/Maps/Constants.ts @@ -2,4 +2,11 @@ namespace OSFramework.Maps.Constants { /* OutSystems Maps Version */ export const OSMapsVersion = '1.8.0'; + + /** + * DataGrid Set platform in use. + * - This value will be set dynamically at the compilation momment! + * - Do not change default string value! + */ + export const OSPlatform = '<->platformType<->'; } diff --git a/src/OSFramework/Maps/OSMap/AbstractMap.ts b/src/OSFramework/Maps/OSMap/AbstractMap.ts index 82c90928..1780b1dd 100644 --- a/src/OSFramework/Maps/OSMap/AbstractMap.ts +++ b/src/OSFramework/Maps/OSMap/AbstractMap.ts @@ -10,7 +10,7 @@ namespace OSFramework.Maps.OSMap { private _heatmapLayersSet: Set; private _isReady: boolean; private _mapEvents: Event.OSMap.MapEventsManager; - private _mapRefreshRequest: number; + private _mapRefreshRequest: number | NodeJS.Timeout; private _mapType: Enum.MapType; private _markers: Map; private _markersSet: Set; diff --git a/src/Providers/Maps/Google/Shape/AbstractProviderShape.ts b/src/Providers/Maps/Google/Shape/AbstractProviderShape.ts index 43dc24db..7d888e64 100644 --- a/src/Providers/Maps/Google/Shape/AbstractProviderShape.ts +++ b/src/Providers/Maps/Google/Shape/AbstractProviderShape.ts @@ -6,7 +6,7 @@ namespace Provider.Maps.Google.Shape { T extends OSFramework.Maps.Configuration.IConfigurationShape, W extends google.maps.MVCObject, > extends OSFramework.Maps.Shape.AbstractShape { - private _shapeChangedEventTimeout: number; + private _shapeChangedEventTimeout: number | NodeJS.Timeout; private _resetShapeEvents(): void { // Make sure the listeners get removed before adding the new ones diff --git a/src/Providers/Maps/Leaflet/Shape/AbstractProviderShape.ts b/src/Providers/Maps/Leaflet/Shape/AbstractProviderShape.ts index 4abb5901..e30ee9be 100644 --- a/src/Providers/Maps/Leaflet/Shape/AbstractProviderShape.ts +++ b/src/Providers/Maps/Leaflet/Shape/AbstractProviderShape.ts @@ -6,7 +6,7 @@ namespace Provider.Maps.Leaflet.Shape { T extends OSFramework.Maps.Configuration.IConfigurationShape, W extends L.Path, > extends OSFramework.Maps.Shape.AbstractShape { - private _shapeChangedEventTimeout: number; + private _shapeChangedEventTimeout: number | NodeJS.Timeout; /** Checks if the Shape has associated events */ public get hasEvents(): boolean {