Refactor schema layout and scripts
This commit is contained in:
Родитель
cd8fc77b16
Коммит
3cfea528b3
|
@ -7,6 +7,9 @@
|
|||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts"
|
||||
},
|
||||
"versions": {
|
||||
"workflow": "1.5.0"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"author": "Nathan Evans <naevans@microsoft.com>",
|
||||
"license": "MIT",
|
||||
|
@ -30,12 +33,14 @@
|
|||
"clean": "essex clean dist docs",
|
||||
"build": "essex build --docs --skipExportCheck",
|
||||
"lint": "essex lint --fix",
|
||||
"bundle": "typescript-json-schema tsconfig.json WorkflowJson > ../../schema/workflow.json",
|
||||
"bundle-workflow": "typescript-json-schema tsconfig.json WorkflowJson > ../../schema/workflow.json",
|
||||
"bundle": "run-p bundle-workflow",
|
||||
"release": "yarn npm publish --tolerate-republish --access public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@essex/scripts": "^22.0.5",
|
||||
"@essex/tsconfig-base": "^1.0.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"shx": "^0.3.4",
|
||||
"typescript": "^4.7.4",
|
||||
"typescript-json-schema": "^0.53.1"
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -6,30 +6,43 @@ import fs from 'fs'
|
|||
import path, { dirname } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
// this script copies the released schemas folder into the webapp public folder for deployment to github.io
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
const latestWorkflowSchema = 'workflow.json'
|
||||
const schemaDir = path.join(__dirname, '../schema')
|
||||
const schemaReleases = path.join(schemaDir, 'releases')
|
||||
const webappVersionDirectory = path.join(
|
||||
__dirname,
|
||||
'../javascript/webapp/public/schema/workflow',
|
||||
|
||||
const { versions } = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, '../javascript/schema/package.json'), {
|
||||
encoding: 'utf8',
|
||||
}),
|
||||
)
|
||||
|
||||
if (!fs.existsSync(webappVersionDirectory)) {
|
||||
fs.mkdirSync(webappVersionDirectory)
|
||||
}
|
||||
Object.keys(versions).forEach(name => {
|
||||
const latestSchema = `${name}.json`
|
||||
|
||||
fs.copyFileSync(
|
||||
path.join(schemaDir, latestWorkflowSchema),
|
||||
path.join(webappVersionDirectory, latestWorkflowSchema),
|
||||
)
|
||||
const releaseDirectory = path.join(schemaReleases, name)
|
||||
|
||||
fs.readdirSync(schemaReleases).forEach(file => {
|
||||
const renamedFile = file.replace(/workflow-/, '')
|
||||
fs.copyFileSync(
|
||||
path.join(schemaReleases, file),
|
||||
path.join(webappVersionDirectory, renamedFile),
|
||||
const webappVersionDirectory = path.join(
|
||||
__dirname,
|
||||
`../javascript/webapp/public/schema/${name}`,
|
||||
)
|
||||
|
||||
if (!fs.existsSync(webappVersionDirectory)) {
|
||||
fs.mkdirSync(webappVersionDirectory)
|
||||
}
|
||||
|
||||
// copy the latest named schems (no version #)
|
||||
fs.copyFileSync(
|
||||
path.join(schemaDir, latestSchema),
|
||||
path.join(webappVersionDirectory, latestSchema),
|
||||
)
|
||||
|
||||
// copy each versioned schema into the appropriate public output folder
|
||||
fs.readdirSync(releaseDirectory).forEach(file => {
|
||||
fs.copyFileSync(
|
||||
path.join(releaseDirectory, file),
|
||||
path.join(webappVersionDirectory, file),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,23 +1,34 @@
|
|||
/*!
|
||||
* Copyright (c) Microsoft. All rights reserved.
|
||||
* Licensed under the MIT license. See LICENSE file in the project.
|
||||
*/
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { dirname } from 'path'
|
||||
import path, { dirname } from 'path'
|
||||
import semver from 'semver'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
// this script copies the latest built version of the schema into a releases folder with rolled up version specificity
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
const { version: schemaVersion } = JSON.parse(fs.readFileSync(path.join(__dirname, '../javascript/schema/package.json'), { encoding: 'utf8' }))
|
||||
|
||||
console.log("schema version is", schemaVersion)
|
||||
const currentSchema = path.join(__dirname, '../schema/workflow.json')
|
||||
const schemaReleases = path.join(__dirname, '../schema/releases')
|
||||
|
||||
const majorVersionFile = path.join(schemaReleases, `workflow-v${semver.major(schemaVersion)}.json`)
|
||||
const specificVersionFile = path.join(schemaReleases, `workflow-v${schemaVersion}.json`)
|
||||
const { versions } = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, '../javascript/schema/package.json'), {
|
||||
encoding: 'utf8',
|
||||
}),
|
||||
)
|
||||
|
||||
if (fs.existsSync(specificVersionFile)) {
|
||||
throw new Error(`workflow schema version ${schemaVersion} has already been created`)
|
||||
}
|
||||
fs.copyFileSync(currentSchema, majorVersionFile)
|
||||
fs.copyFileSync(currentSchema, specificVersionFile)
|
||||
Object.entries(versions).forEach(([name, schemaVersion]) => {
|
||||
const currentSchema = path.join(__dirname, `../schema/${name}.json`)
|
||||
const schemaFolder = path.join(schemaReleases, name)
|
||||
if (!fs.existsSync(schemaFolder)) {
|
||||
fs.mkdirSync(schemaFolder)
|
||||
}
|
||||
const majorVersionFile = path.join(
|
||||
schemaFolder,
|
||||
`v${semver.major(schemaVersion)}.json`,
|
||||
)
|
||||
const specificVersionFile = path.join(schemaFolder, `v${schemaVersion}.json`)
|
||||
fs.copyFileSync(currentSchema, majorVersionFile)
|
||||
fs.copyFileSync(currentSchema, specificVersionFile)
|
||||
})
|
||||
|
|
|
@ -3843,6 +3843,7 @@ __metadata:
|
|||
dependencies:
|
||||
"@essex/scripts": ^22.0.5
|
||||
"@essex/tsconfig-base": ^1.0.2
|
||||
npm-run-all: ^4.1.5
|
||||
shx: ^0.3.4
|
||||
typescript: ^4.7.4
|
||||
typescript-json-schema: ^0.53.1
|
||||
|
|
Загрузка…
Ссылка в новой задаче