Closed espen42 closed 4 years ago
Full-stack trace:
Deploying to sandbox 'com.phx.demo'...
> Task :npmInstall
npm WARN rollback Rolling back readable-stream@2.3.6 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\amine.amami\WebstormProjects\enonic\reactxp\node_modules\fsevents\node_modules'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
added 724 packages from 265 contributors and audited 11952 packages in 53.625s
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
> Task :config_react4xp FAILED
undefined:1
{buildRuntimeClient:false,outputFileName:C:\\Users\\amine.amami\\WebstormProjects\\enonic\\reactxp/build/react4xp_constants.json,buildEnv:development,BUILD_ENV:development,masterConfigFileName:build/react4xp_constants.json,overwriteConstantsFile:true,buildExternals:tr
ue,verbose:false}
^
SyntaxError: Unexpected token b in JSON at position 1
at JSON.parse (<anonymous>)
at buildConstants (C:\Users\amine.amami\WebstormProjects\enonic\reactxp\node_modules\react4xp-buildconstants\index.js:25:26)
at Object.<anonymous> (C:\Users\amine.amami\WebstormProjects\enonic\reactxp\node_modules\react4xp-buildconstants\cli.js:15:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':config_react4xp'.
> Process 'command 'node'' finished with non-zero exit value 1
* Try:
* Get more help at https://help.gradle.org
BUILD FAILED in 56s
3 actionable tasks: 2 executed, 1 up-to-date
build.gradle file content (unedited):
plugins {
id 'com.enonic.defaults' version '2.0.1'
id 'com.enonic.xp.app' version '2.0.0'
id "com.moowork.node" version "1.3.1"
id 'maven-publish'
}
app {
name = "${appName}"
displayName = "${appDisplayName}"
vendorName = "${vendorName}"
vendorUrl = "${vendorUrl}"
systemVersion = "${xpVersion}"
}
dependencies {
compile "com.enonic.xp:core-api:${xpVersion}"
compile "com.enonic.xp:portal-api:${xpVersion}"
include "com.enonic.xp:lib-content:${xpVersion}"
include "com.enonic.xp:lib-portal:${xpVersion}"
//include "com.enonic.xp:lib-auth:${xpVersion}"
//include "com.enonic.xp:lib-context:${xpVersion}"
//include "com.enonic.xp:lib-i18n:${xpVersion}"
//include "com.enonic.xp:lib-io:${xpVersion}"
//include "com.enonic.xp:lib-mail:${xpVersion}"
//include "com.enonic.xp:lib-repo:${xpVersion}"
//include "com.enonic.xp:lib-websocket:${xpVersion}"
include "com.enonic.lib:lib-thymeleaf:2.0.0"
include "com.enonic.lib:lib-mustache:2.0.0"
include "com.enonic.lib:lib-util:2.0.0"
include 'com.enonic.lib:lib-react4xp:0.3.8'
}
repositories {
mavenLocal()
jcenter()
xp.enonicRepo()
}
npmInstall.inputs.file("package.json")
npmInstall.inputs.file("package-lock.json")
npmInstall.outputs.dir('node_modules')
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
// Resolves the project folder root
def ROOT = project.projectDir.toString()
def react4xp = {}
file("react4xp.properties").withReader { reader ->
react4xp = new Properties()
react4xp.load(reader)
}
react4xp.outputFileName = ROOT + '/' + react4xp.masterConfigFileName
if(react4xp.nashornPolyfillsSource != null) {
react4xp.NASHORNPOLYFILLS_SOURCE = react4xp.nashornPolyfillsSource
}
if(react4xp.buildEnv != null) {
react4xp.BUILD_ENV = react4xp.buildEnv
}
react4xp.masterConfigFileName = react4xp.masterConfigFileName != null ? react4xp.masterConfigFileName : "build/react4xp_constants.json"
react4xp.outputFileName = ROOT + '/' + react4xp.masterConfigFileName
react4xp.verbose = react4xp.verbose != null && react4xp.verbose.toBoolean()
react4xp.buildRuntimeClient = react4xp.buildRuntimeClient != null && react4xp.buildRuntimeClient.toBoolean()
react4xp.buildExternals = react4xp.buildExternals != null && react4xp.buildExternals.toBoolean()
react4xp.overwriteConstantsFile = react4xp.overwriteConstantsFile != null && react4xp.overwriteConstantsFile.toBoolean()
// Build the master config JSON file and the copy:
task config_react4xp(type: NodeTask) {
group 'React4xp'
description 'Build the master config JSON file and its copy'
script = file('node_modules/react4xp-buildconstants/cli.js')
args = [ ROOT, JsonOutput.toJson(react4xp) ]
}
config_react4xp.inputs.file("react4xp.properties")
config_react4xp.outputs.file(react4xp.masterConfigFileName)
config_react4xp.dependsOn += 'npmInstall'
config_react4xp.dependsOn += 'processResources'
// Necessary placeholder, will be filled during build
def CONFIG = {}
task config_tasks {
// After the above script has run and created the config file, use the constructed values from the script to update the configuration of the next task(s):
doLast {
// Read the file content into an object
def configFile = new File(react4xp.masterConfigFileName)
CONFIG = new JsonSlurper().parseText(configFile.text)
tasks['webpack_react4xp'].configure {
inputs.dir(CONFIG.SRC_SITE)
inputs.dir(CONFIG.SRC_R4X)
outputs.dir(CONFIG.BUILD_R4X)
}
tasks['babelXP'].configure {
args = ["src/main/resources", "--out-dir", CONFIG.BUILD_MAIN, "--ignore", "**/*.jsx"] // <-- Still ignoring JSX in the XP structure
outputs.dir(CONFIG.BUILD_MAIN)
}
}
}
config_tasks.dependsOn += 'config_react4xp'
// Compile:
task webpack_react4xp(type: NodeTask) {
group 'React4xp'
description 'Run the imported react4xp webpack scripts that compile the components and externals (as well as client and nashorn polyfills if needed)'
// 1 MANDATORY STEP: react4xp-build-components compiles the components added in this project into runnable/renderable components. See react4xp-build-components docs.
script = file('node_modules/webpack/bin/webpack.js')
args = ['--config', 'node_modules/react4xp-build-components/webpack.config.js', '--color', '--env.VERBOSE=' + react4xp.verbose]
if (react4xp.overrideComponentWebpack != null) {
args += '--env.OVERRIDE_COMPONENT_WEBPACK=' + react4xp.overrideComponentWebpack
}
// 3 OPTIONAL STEPS. SEE SETTINGS AND (DE)ACTIVATION IN react4xp.properties:
if (react4xp.buildExternals) {
args += ['--config', 'node_modules/react4xp-runtime-externals/webpack.config.js']
}
if (react4xp.buildRuntimeClient) {
args += ['--config', 'node_modules/react4xp-runtime-client/webpack.config.js']
}
if (react4xp.nashornPolyfillsSource != null) {
args += ['--config', 'node_modules/react4xp-runtime-nashornpolyfills/webpack.config.js']
}
// Pretty if chatty
if (react4xp.verbose) {
args += '--progress'
}
// Finally, and mandatorily: tells all of the webpack steps here where to find the react4xp master config file that was built during the config_react4xp task
args += '--env.REACT4XP_CONFIG_FILE=' + react4xp.masterConfigFileName
if (react4xp.verbose) {
println "webpack_react4xp task - args:"
println args
}
inputs.file(react4xp.masterConfigFileName)
inputs.file("package.json")
inputs.file("package-lock.json")
}
webpack_react4xp.dependsOn += 'config_tasks'
task babelXP(type: NodeTask) {
group 'React4xp'
description 'Compile XP components from ES6, ignoring JSX components'
script = file('node_modules/babel-cli/bin/babel.js')
args = ["src/main/resources", "--out-dir", "build/resources/main", "--ignore", "**/*.jsx"] // <-- Ignoring JSX in the XP structure is important!
inputs.dir 'src/main/resources'
outputs.dir("build/resources/main")
}
babelXP.dependsOn += 'config_tasks'
jar.dependsOn += 'webpack_react4xp'
jar.dependsOn += 'babelXP'
// Note: the 2 watcher tasks from previous version are removed. Use "npm run watch" instead, in combination with XP dev mode (e.g. enonic sandbox start --dev)
Fixed: starter version 0.2.10 for XP7 and 0.1.10 for XP6.
Creating a new project using the enonic CLI, following the instructions from https://developer.enonic.com/templates/react4xp#create_project - no setup changed.
Environment: Windows 10, french system language.