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

chore: #629 migrate config.json for scaffolder and ts defitions #688

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/foundation-ts-definition-cronjob.yml
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ jobs:

- name: Fetch config
run: |
yarn fetch-config DEV
yarn fetch-config production

- name: Fetch latest definition
run: yarn workspace @reapit/foundations-ts-definitions fetch-definition
6 changes: 1 addition & 5 deletions .github/workflows/pull-request-ci.yml
Original file line number Diff line number Diff line change
@@ -92,11 +92,7 @@ jobs:

- name: Fetch config
run: |
yarn fetch-config DEV

- name: Fetch config1
run: |
yarn fetch-config1 development
yarn fetch-config development

- name: Build
run: |
13 changes: 9 additions & 4 deletions .github/workflows/release-develop.yml
Original file line number Diff line number Diff line change
@@ -41,27 +41,31 @@ jobs:
- name: Install Global Dependencies
run: |
yarn global add aws-cli [email protected]

- name: Set up workspace experimental
run: |
yarn config set workspaces-experimental true

- name: Install dependencies
run: |
yarn

- name: Lint
run: |
yarn lint

- name: Fetch config
run: |
yarn fetch-config DEV
- name: Fetch config1
run: |
yarn fetch-config1 development
yarn fetch-config development

- name: Build
run: |
yarn build

- name: Test
run: |
yarn test

- name: Release Develop
run: |
yarn release:dev
@@ -74,6 +78,7 @@ jobs:
key: ${{ runner.os }}-jest-cache-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-jest-cache-

- name: Write marketplace build cache
uses: actions/cache@v1
with:
6 changes: 1 addition & 5 deletions .github/workflows/release-production.yml
Original file line number Diff line number Diff line change
@@ -65,11 +65,7 @@ jobs:

- name: Fetch config
run: |
yarn fetch-config PROD

- name: Fetch config1
run: |
yarn fetch-config1 production
yarn fetch-config production

- name: Build
run: |
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -18,8 +18,7 @@
},
"scripts": {
"build": "lerna run build:prod --stream",
"fetch-config": "yarn config-manager getSecret reapit-marketplace-app-config",
"fetch-config1": "lerna run --parallel --stream fetch-config --",
"fetch-config": "lerna run --parallel --stream fetch-config --",
"lint": "lerna run --parallel --stream lint",
"lint:fix": "lerna run --parallel --stream lint:fix --",
"release:dev": "lerna run --parallel release:dev",
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { json2ts } = require('json-ts')
const fs = require('fs')
const { REAPIT_TS_DEF_IN_CWD_PATH, REAPIT_TS_DEF_NAME } = require('../paths')
const formatCode = require('../../../../scripts/foundations-ts-definitions/format-code')
const formatCode = require('../../../foundations-ts-definitions/scripts/format-code')

exports.generateConfigTsDef = config => {
try {
5 changes: 5 additions & 0 deletions packages/foundations-ts-definitions/config.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"MARKETPLACE_API_BASE_URL": "",
"MARKETPLACE_API_KEY": "",
"PLATFORM_API_BASE_URL": ""
}
7 changes: 4 additions & 3 deletions packages/foundations-ts-definitions/package.json
Original file line number Diff line number Diff line change
@@ -7,9 +7,10 @@
],
"main": "./types/index.ts",
"scripts": {
"fetch-definition": "node '../../scripts/foundations-ts-definitions/fetch-definition.js'",
"handle-cron-job": "node '../../scripts/foundations-ts-definitions/handle-cronjob.js'",
"release:prod": "node ../../scripts/foundations-ts-definitions/release-npm.js foundations-ts-definitions",
"fetch-config": "yarn config-manager fetchConfig foundations-ts-definitions",
"fetch-definition": "yarn fetch-config && node './scripts/fetch-definition.js'",
"handle-cron-job": "node './scripts/handle-cronjob.js'",
"release:prod": "node ./scripts/release-npm.js foundations-ts-definitions",
"test:update-badges": "echo 'not implmented'"
},
"lint-staged": {
7 changes: 7 additions & 0 deletions packages/foundations-ts-definitions/scripts/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const path = require('path')

module.exports = {
FOUNDATION_ROOT_FOLDER: path.resolve(__dirname, '..'),
FOUNDATION_TYPES_FOLDER: path.resolve(__dirname, '../types'),
PACKAGE_NAME: 'foundations-ts-definitions',
}
Original file line number Diff line number Diff line change
@@ -6,9 +6,7 @@ const sw2dts = require('sw2dts')
const prettifyCode = require('./format-code')

const { FOUNDATION_TYPES_FOLDER } = require('./constants')
const config = require(path.resolve(__dirname, '../../reapit-config.json'))
const configDev = config['DEV']
const { MARKETPLACE_API_BASE_URL, MARKETPLACE_API_KEY } = configDev
const { MARKETPLACE_API_BASE_URL, MARKETPLACE_API_KEY } = require(path.resolve(__dirname, '..', 'config.json'))

// Fetch definitions for a given schema
const fetchDefinitionsForSchema = async schemaConfig => {
Original file line number Diff line number Diff line change
@@ -6,9 +6,7 @@ const sw2dts = require('sw2dts')
const prettifyCode = require('./format-code')

const { FOUNDATION_TYPES_FOLDER } = require('./constants')
const config = require(path.resolve(__dirname, '../../reapit-config.json'))
const configDev = config['DEV']
const { PLATFORM_API_BASE_URL } = configDev
const { PLATFORM_API_BASE_URL } = require(path.resolve(__dirname, '..', 'config.json'))

// Fetch definitions for a given schema
const fetchDefinitionsForSchema = async schemaConfig => {
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const prettier = require('prettier')
const prettierBaseConfig = require('../../.prettierrc.js')
const prettierBaseConfig = require('../../../.prettierrc.js')

module.exports = content => {
const formatContent = prettier.format(content, {
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { runCommand } = require('../../scripts/release/utils')
const gitStatus = runCommand('git', ['status', '-s'])
const { runCommand } = require('../../../scripts/release/utils')
const updateNPM = require('./update-npm')
const releaseGithub = require('./release-github')

const gitStatus = runCommand('git', ['status', '-s'])

console.log(`Cronjob executed at ${new Date().toDateString()} - ${new Date().toTimeString()}`)

if (!gitStatus) {
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const Octokit = require('@octokit/rest')
const getCurrentTimeStamp = require('./get-current-time-stamp-string')
const fs = require('fs')
const path = require('path')
const getCurrentTimeStamp = require('./get-current-time-stamp-string')
const { FOUNDATION_ROOT_FOLDER } = require('./constants')
const { GITHUB_TOKEN } = process.env
const { runCommand } = require('../release/utils')
const { runCommand } = require('../../../scripts/release/utils')
const { execSync } = require('child_process')

const { GITHUB_TOKEN } = process.env

module.exports = async () => {
try {
runCommand('git', ['remote', 'add', 'sshOrigin', `[email protected]:${process.env.GITHUB_REPOSITORY}.git`])
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { execSync } = require('child_process')
const { getPreviousTag, editReleaseNote, getVersionTag } = require('../release/utils')
const { getPreviousTag, editReleaseNote, getVersionTag } = require('../../../scripts/release/utils')
const publishTimeStampTag = require('./publish-time-stamp-tag')
const { FOUNDATION_ROOT_FOLDER } = require('./constants')

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const semver = require('semver')
const { runCommand } = require('../release/utils')
const { runCommand } = require('../../../scripts/release/utils')
const fs = require('fs')
const path = require('path')
const { FOUNDATION_ROOT_FOLDER, PACKAGE_NAME } = require('./constants')
Loading