2021-03-15 16:13:07 -07:00
|
|
|
apply plugin: 'distribution'
|
|
|
|
apply plugin: 'com.github.node-gradle.node'
|
|
|
|
|
|
|
|
node {
|
|
|
|
|
|
|
|
// If true, it will download node using above parameters.
|
|
|
|
// If false, it will try to use globally installed node.
|
2021-11-09 20:50:06 +01:00
|
|
|
if (project.hasProperty('useSystemNode') && project.getProperty('useSystemNode').toBoolean()) {
|
|
|
|
download = false
|
|
|
|
} else {
|
|
|
|
download = true
|
|
|
|
}
|
2021-03-15 16:13:07 -07:00
|
|
|
|
|
|
|
// Version of node to use.
|
2022-08-05 18:03:57 -05:00
|
|
|
version = '16.16.0'
|
2021-03-15 16:13:07 -07:00
|
|
|
|
|
|
|
// Version of Yarn to use.
|
|
|
|
yarnVersion = '1.22.0'
|
|
|
|
|
2022-03-31 16:15:25 +01:00
|
|
|
// Base URL for fetching node distributions (set nodeDistBaseUrl if you have a mirror).
|
|
|
|
if (project.hasProperty('nodeDistBaseUrl')) {
|
|
|
|
distBaseUrl = project.getProperty('nodeDistBaseUrl')
|
|
|
|
} else {
|
|
|
|
distBaseUrl = 'https://nodejs.org/dist'
|
|
|
|
}
|
2021-03-15 16:13:07 -07:00
|
|
|
|
|
|
|
// Set the work directory for unpacking node
|
|
|
|
workDir = file("${project.projectDir}/.gradle/nodejs")
|
|
|
|
|
|
|
|
// Set the work directory for NPM
|
|
|
|
yarnWorkDir = file("${project.projectDir}/.gradle/yarn")
|
|
|
|
|
|
|
|
// Set the work directory where node_modules should be located
|
|
|
|
nodeModulesDir = file("${project.projectDir}")
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
Re-trigger build if any markdown files change anywhere in the project
|
|
|
|
*/
|
|
|
|
def projectMdFiles = project.fileTree("${project.projectDir}") {
|
|
|
|
include '**/*.md'
|
|
|
|
include '**/*.js'
|
|
|
|
include '**/*.ts'
|
|
|
|
exclude 'node_modules'
|
|
|
|
exclude '**/dist/**'
|
|
|
|
}
|
|
|
|
|
2021-09-22 17:30:15 -07:00
|
|
|
// Combine GraphQL schemas for documentation.
|
|
|
|
task generateGraphQLSchema(type: Exec) {
|
|
|
|
workingDir "$projectDir/graphql"
|
|
|
|
commandLine './generateGraphQLSchema.sh'
|
|
|
|
}
|
2021-03-15 16:13:07 -07:00
|
|
|
|
2022-06-06 09:31:44 +02:00
|
|
|
task generateJsonSchema(type: Exec, dependsOn: [':metadata-ingestion:docGen']) {
|
|
|
|
workingDir "$projectDir/genJsonSchema"
|
|
|
|
commandLine './generateJsonSchema.sh'
|
|
|
|
}
|
|
|
|
|
2021-03-15 16:13:07 -07:00
|
|
|
/*
|
|
|
|
Wrappers around Yarn Tasks.
|
|
|
|
*/
|
|
|
|
task yarnInstall(type: YarnTask) {
|
|
|
|
logger.info('CI = "{}"', System.env.CI)
|
|
|
|
if (System.env.CI != null && System.env.CI == "true") {
|
|
|
|
args = ['install','--frozen-lockfile']
|
|
|
|
} else {
|
|
|
|
args = ['install']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-15 05:43:17 +00:00
|
|
|
task yarnGenerate(type: YarnTask, dependsOn: [yarnInstall, generateGraphQLSchema, generateJsonSchema, ':metadata-ingestion:modelDocGen', ':metadata-ingestion:docGen'] ) {
|
2021-03-15 16:13:07 -07:00
|
|
|
inputs.files(projectMdFiles)
|
|
|
|
outputs.cacheIf { true }
|
|
|
|
args = ['run', 'generate']
|
|
|
|
}
|
|
|
|
|
2022-08-15 05:43:17 +00:00
|
|
|
task yarnStart(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) {
|
2021-03-15 16:13:07 -07:00
|
|
|
args = ['run', 'start']
|
|
|
|
}
|
2022-11-29 00:52:16 -05:00
|
|
|
task fastReload(type: YarnTask) {
|
|
|
|
args = ['run', 'generate-rsync']
|
|
|
|
}
|
2021-03-15 16:13:07 -07:00
|
|
|
|
|
|
|
task yarnLint(type: YarnTask, dependsOn: [yarnInstall]) {
|
|
|
|
inputs.files(projectMdFiles)
|
|
|
|
args = ['run', 'lint-check']
|
|
|
|
outputs.dir("dist")
|
|
|
|
// tell gradle to apply the build cache
|
|
|
|
outputs.cacheIf { true }
|
|
|
|
}
|
|
|
|
|
2022-02-11 22:33:01 +05:30
|
|
|
task yarnLintFix(type: YarnTask, dependsOn: [yarnInstall]) {
|
|
|
|
inputs.files(projectMdFiles)
|
|
|
|
args = ['run', 'lint-fix']
|
|
|
|
outputs.dir("dist")
|
|
|
|
// tell gradle to apply the build cache
|
|
|
|
outputs.cacheIf { true }
|
|
|
|
}
|
|
|
|
|
|
|
|
task serve(type: YarnTask, dependsOn: [yarnInstall] ) {
|
|
|
|
args = ['run', 'serve']
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-15 16:13:07 -07:00
|
|
|
task yarnBuild(type: YarnTask, dependsOn: [yarnLint, yarnGenerate]) {
|
|
|
|
inputs.files(projectMdFiles)
|
|
|
|
inputs.file("package.json").withPathSensitivity(PathSensitivity.RELATIVE)
|
|
|
|
inputs.dir("src").withPathSensitivity(PathSensitivity.RELATIVE)
|
|
|
|
inputs.dir("static").withPathSensitivity(PathSensitivity.RELATIVE)
|
|
|
|
inputs.file("yarn.lock").withPathSensitivity(PathSensitivity.RELATIVE)
|
|
|
|
outputs.dir("dist")
|
|
|
|
// tell gradle to apply the build cache
|
|
|
|
outputs.cacheIf { true }
|
|
|
|
args = ['run', 'build']
|
|
|
|
|
|
|
|
}
|
|
|
|
task yarnClear(type: YarnTask) {
|
|
|
|
args = ['run','clear']
|
|
|
|
}
|
|
|
|
clean {
|
|
|
|
delete 'node_modules'
|
|
|
|
delete 'dist'
|
|
|
|
delete 'tmp'
|
|
|
|
delete 'build'
|
|
|
|
delete 'just'
|
2022-07-15 06:08:32 -04:00
|
|
|
delete fileTree(dir: 'genDocs', exclude: '.gitignore')
|
|
|
|
delete fileTree(dir: 'docs', exclude: '.gitignore')
|
|
|
|
delete 'graphql/combined.graphql'
|
2021-03-15 16:13:07 -07:00
|
|
|
yarnClear
|
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
|
|
|
dependsOn yarnBuild
|
|
|
|
}
|