sebavan 6 gadi atpakaļ
vecāks
revīzija
e76008b439

+ 42 - 1
Tools/Gulp/config.json

@@ -61,6 +61,7 @@
             "webpack": "../../../src/webpack.config.js",
             "srcDirectory": "../../src/",
             "distOutputDirectory": "/",
+            "packageJSON": "../../package.json",
             "processDeclaration": {
                 "filename": "babylon.module.d.ts",
                 "packageName": "babylonjs",
@@ -85,6 +86,10 @@
                 ],
                 "doNotAppendNamespace": true,
                 "prependToNamespaceText": "declare module 'babylonjs' { export = BABYLON; }"
+            },
+            "es6": {
+                "packageName": "babylonjs-es6",
+                "tsFolder": "../../src/"
             }
         }
     },
@@ -182,6 +187,10 @@
                 "classMap": {
                     "babylonjs": "BABYLON"
                 }
+            },
+            "es6": {
+                "packageName": "babylonjs-materials-es6",
+                "tsFolder": "../../materialsLibrary/"
             }
         }
     },
@@ -208,12 +217,16 @@
             "distOutputDirectory": "/postProcessesLibrary/",
             "processDeclaration": {
                 "filename": "babylonjs.postProcess.module.d.ts",
-                "packageName": "babylonjs-postProcessLibrary",
+                "packageName": "babylonjs-post-process",
                 "moduleName": "BABYLON",
                 "importsToRemove": [],
                 "classMap": {
                     "babylonjs": "BABYLON"
                 }
+            },
+            "es6": {
+                "packageName": "babylonjs-post-process-es6",
+                "tsFolder": "../../postProcessLibrary/"
             }
         }
     },
@@ -286,6 +299,10 @@
                 "classMap": {
                     "babylonjs": "BABYLON"
                 }
+            },
+            "es6": {
+                "packageName": "babylonjs-procedural-textures-es6",
+                "tsFolder": "../../proceduralTexturesLibrary/"
             }
         }
     },
@@ -352,6 +369,10 @@
                     "babylonjs": "BABYLON",
                     "babylonjs-gltf2interface": "BABYLON.GLTF2"
                 }
+            },
+            "es6": {
+                "packageName": "babylonjs-loaders-es6",
+                "tsFolder": "../../loaders/"
             }
         }
     },
@@ -405,6 +426,10 @@
                         "namespace": "BABYLON"
                     }
                 ]
+            },
+            "es6": {
+                "packageName": "babylonjs-serializers-es6",
+                "tsFolder": "../../serializers/"
             }
         }
     },
@@ -429,6 +454,10 @@
                     "babylonjs-loaders": "BABYLON",
                     "babylonjs-serializers": "BABYLON"
                 }
+            },
+            "es6": {
+                "packageName": "babylonjs-gui-es6",
+                "tsFolder": "../../gui/"
             }
         }
     },
@@ -457,6 +486,10 @@
                     "babylonjs-serializers": "BABYLON",
                     "babylonjs-gui": "BABYLON.GUI"
                 }
+            },
+            "es6": {
+                "packageName": "babylonjs-inspector-es6",
+                "tsFolder": "../../inspector/"
             }
         }
     },
@@ -525,6 +558,14 @@
                         }
                     ]
                 }
+            ],
+            "es6": {
+                "packageName": "babylonjs-viewer-es6",
+                "tsFolder": "../../viewer/"
+            },
+            "requiredFiles": [
+                "../../Viewer/README.md",
+                "../../Viewer/package.json"
             ]
         }
     },

+ 2 - 21
Tools/Gulp/helpers/gulp-rmDir.js

@@ -1,26 +1,7 @@
-var path = require("path");
-var fs = require("fs");
+var fs = require("fs-extra");
 
 var rmDir = function(dirPath) {
-    let files = null;
-    try { 
-        files = fs.readdirSync(dirPath); 
-    }
-    catch (e) {
-        return; 
-    }
-    
-    if (files && files.length > 0) {
-        for (var i = 0; i < files.length; i++) {
-            var filePath = path.join(dirPath, files[i]);
-            if (fs.statSync(filePath).isFile())
-                fs.unlinkSync(filePath);
-            else
-                rmDir(filePath);
-        }
-    }
-
-    fs.rmdirSync(dirPath);
+    fs.removeSync(dirPath);
 }
 
 module.exports = function(dirPath) {

+ 0 - 132
Tools/Publisher/config/config.json

@@ -1,132 +0,0 @@
-{
-    "basePath": "../../dist/preview release/",
-    "packages": [
-        {
-            "name": "core",
-            "path": "../../"
-        },
-        {
-            "name": "gui",
-            "path": "gui/"
-        },
-        {
-            "name": "materials",
-            "path": "materialsLibrary/"
-        },
-        {
-            "name": "postProcess",
-            "path": "postProcessesLibrary/"
-        },
-        {
-            "name": "gltf2interface",
-            "path": "gltf2interface/"
-        },
-        {
-            "name": "loaders",
-            "path": "loaders/"
-        },
-        {
-            "name": "serializers",
-            "path": "serializers/"
-        },
-        {
-            "name": "proceduralTextures",
-            "path": "proceduralTexturesLibrary/"
-        },
-        {
-            "name": "inspector",
-            "path": "inspector/"
-        },
-        {
-            "name": "viewer",
-            "path": "Viewer/"
-        },
-        {
-            "name": "viewer-assets",
-            "path": "Viewer/build/assets/",
-            "required": [
-                "../../Viewer/assets/readme.md",
-                "../../Viewer/assets/package.json"
-            ]
-        }
-    ],
-    "es6": [
-        {
-            "name": "gui",
-            "path": "../../gui/",
-            "buildPath": "build/",
-            "packageName": "babylonjs-gui-es6",
-            "payload": {
-                "name": "babylonjs-gui-es6",
-                "description": "The Babylon.js GUI library is an extension you can use to generate interactive user interface. It is build on top of the DynamicTexture.",
-                "keywords": [
-                    "gui"
-                ],
-                "dependencies": {
-                    "babylonjs": true
-                }
-            }
-        },
-        {
-            "name": "materialsLibrary",
-            "path": "../../materialsLibrary/",
-            "buildPath": "build/",
-            "packageName": "babylonjs-materials-es6",
-            "payload": {
-                "name": "babylonjs-materials-es6",
-                "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-                "keywords": [
-                    "3D",
-                    "javascript",
-                    "html5",
-                    "webgl",
-                    "materials"
-                ],
-                "dependencies": {
-                    "babylonjs": true
-                }
-            }
-        },
-        {
-            "name": "inspector",
-            "path": "../../inspector/",
-            "buildPath": "build/",
-            "packageName": "babylonjs-inspector-es6",
-            "payload": {
-                "name": "babylonjs-inspector-es6",
-                "description": "The Babylon.js inspector.",
-                "keywords": [
-                    "inspector"
-                ],
-                "dependencies": {
-                    "babylonjs-gui": true,
-                    "babylonjs": true
-                }
-            }
-        },
-        {
-            "name": "viewer",
-            "path": "../../Viewer/",
-            "buildPath": "build/src/",
-            "packageName": "babylonjs-viewer-es6",
-            "payload": {
-                "name": "babylonjs-viewer-es6",
-                "description": "A simple-to-use viewer based on BabylonJS to display 3D elements natively",
-                "keywords": [
-                    "viewer"
-                ],
-                "dependencies": {
-                    "babylonjs-loaders": true,
-                    "babylonjs": true,
-                    "babylonjs-gltf2interface": true,
-                    "pepjs": "^0.4.3",
-                    "deepmerge": "^2.1.1",
-                    "handlebars": "^4.0.11"
-                },
-                "peerDependencies": {
-                    "babylonjs-viewer-assets": true
-                }
-            }
-        }
-    ]
-}

+ 0 - 29
Tools/Publisher/config/template.package.json

@@ -1,29 +0,0 @@
-{
-    "author": {
-        "name": "David CATUHE"
-    },
-    "contributors": [
-        "David ROUSSET",
-        "Sebastien VANDENBERGHE",
-        "Raanan Weber"
-    ],
-    "name": "",
-    "description": "",
-    "version": "",
-    "repository": {
-        "type": "git",
-        "url": "https://github.com/BabylonJS/Babylon.js.git"
-    },
-    "main": "index.js",
-    "module": "index.js",
-    "esnext": "index.js",
-    "files": [],
-    "typings": "index.d.ts",
-    "keywords": [
-        "3D",
-        "javascript",
-        "html5",
-        "webgl"
-    ],
-    "license": "Apache-2.0"
-}

+ 75 - 58
Tools/Publisher/publisher.js

@@ -4,9 +4,6 @@ const shelljs = require('shelljs');
 const fs = require('fs-extra');
 const path = require('path');
 
-// This can be changed when we have a new major release.
-const minimumDependency = '>=3.4.0-alpha';
-
 // CMD Arguments Management.
 let doNotBuild = false;
 let doNotPublish = false;
@@ -15,9 +12,10 @@ let doNotPublish = false;
 process.env.PATH += (path.delimiter + path.join(__dirname, 'node_modules', '.bin'));
 
 // Global Variables.
-const config = require("./config/config.json");
-const basePath = config.basePath;
-const packages = config.packages;
+const config = require("../gulp/config.json");
+const modules = config.modules.concat(config.viewerModules);
+const basePath = config.build.outputDirectory;
+const tempPath = config.build.tempDirectory + "es6/";
 
 /**
  * Remove a directory.
@@ -121,18 +119,22 @@ function buildBabylonJSAndDependencies() {
  * Process Legacy Packages.
  */
 function processLegacyPackages(version) {
-    packages.forEach((package) => {
-        if (package.name === "core") {
-            processCore(package, version);
+    console.log("Process Legacy Packages...");
+    modules.forEach(moduleName => {
+        let module = config[moduleName];
+
+        if (moduleName === "core") {
+            processLegacyCore(version);
         }
         else {
-            if (package.required) {
-                package.required.forEach(file => {
-                    fs.copySync(basePath + file, basePath + package.path + '/' + path.basename(file));
+            if (module.build.requiredFiles) {
+                module.build.requiredFiles.forEach(file => {
+                    console.error("    ", file, basePath + module.build.distOutputDirectory + '/' + path.basename(file));
+                    fs.copySync(file, basePath + module.build.distOutputDirectory + '/' + path.basename(file));
                 });
             }
 
-            let packageJson = require(basePath + package.path + 'package.json');
+            let packageJson = require(basePath + module.build.distOutputDirectory + 'package.json');
             packageJson.version = version;
             if (packageJson.dependencies) {
                 Object.keys(packageJson.dependencies).forEach(key => {
@@ -141,10 +143,9 @@ function processLegacyPackages(version) {
                     }
                 });
             }
-            if (packageJson.peerDependencies) packageJson.peerDependencies.babylonjs = minimumDependency;
-            fs.writeFileSync(basePath + package.path + 'package.json', JSON.stringify(packageJson, null, 4));
+            fs.writeFileSync(basePath + module.build.distOutputDirectory+ 'package.json', JSON.stringify(packageJson, null, 4));
 
-            publish(version, package.name, basePath + package.path);
+            publish(version, moduleName, basePath + module.build.distOutputDirectory);
         }
     });
 }
@@ -153,85 +154,101 @@ function processLegacyPackages(version) {
  * Process ES6 Packages.
  */
 function processEs6Packages(version) {
-    let es6Packages = config.es6;
-
-    es6Packages.forEach(package => {
-        let projectPath = package.path;
-        let buildPath = path.normalize(basePath + projectPath + package.buildPath);
-
-        if (package.required) {
-            package.required.forEach(file => {
-                fs.copySync(file, basePath + '/' + path.basename(file));
-            });
+    console.log("Process ES6 Packages...");
+    modules.forEach(moduleName => {
+        let module = config[moduleName];
+        let es6Config = module.build.es6;
+        if (!es6Config) {
+            return;
         }
 
+        let projectPath = es6Config.tsFolder;
+        let buildPath = path.normalize(tempPath + moduleName);
+        let legacyPackageJson = require(module.build.packageJSON || basePath + module.build.distOutputDirectory + 'package.json');
+
         console.log("Cleanup " + buildPath);
         rmDir(buildPath);
 
-        console.log("Executing " + 'tsc -t es6 -m esNext -p ' + projectPath);
+        let command = 'tsc -t es6 -m esNext -p ' + projectPath + ' --outDir ' + buildPath;
+        console.log("Executing " + command);
 
-        let tscCompile = shelljs.exec('tsc -t es6 -m esNext -p ' + projectPath);
+        let tscCompile = shelljs.exec(command);
         if (tscCompile.code !== 0) {
             throw new Error("Tsc compilation failed");
         }
 
-        let packageJson = require("./config" + '/template.package.json');
-        let files = getFiles(buildPath).map(f => f.replace(buildPath + "/", "")).filter(f => f.indexOf("assets/") === -1);
+        if (module.build.requiredFiles) {
+            module.build.requiredFiles.forEach(file => {
+                fs.copySync(file, buildPath + '/' + path.basename(file));
+            });
+        }
 
-        packageJson.files = files;
-        packageJson.version = version;
+        let files = getFiles(buildPath).map(f => f.replace(buildPath + "/", "")).filter(f => f.indexOf("assets/") === -1);
 
-        Object.keys(package.payload).forEach(key => {
-            packageJson[key] = package.payload[key]
-        });
+        legacyPackageJson.name = es6Config.packageName;
+        legacyPackageJson.version = version;
+        legacyPackageJson.main = "index.js";
+        legacyPackageJson.module = "index.js";
+        legacyPackageJson.esnext = "index.js";
+        legacyPackageJson.typings = "index.d.ts";
+        legacyPackageJson.files = files;
 
         ["dependencies", "peerDependencies", "devDependencies"].forEach(key => {
-            if (package.payload[key]) {
-                packageJson[key] = {};
-                Object.keys(package.payload[key]).forEach(packageName => {
-                    if (package.payload[key][packageName] === true) {
-                        packageJson[key][packageName] = version;
+            if (legacyPackageJson[key]) {
+                let dependencies = legacyPackageJson[key];
+                legacyPackageJson[key] = {};
+                Object.keys(dependencies).forEach(packageName => {
+                    if (dependencies[packageName].indexOf("babylonjs") !== -1) {
+                        legacyPackageJson[key][packageName + "-es6"] = version;
                     } else {
-                        packageJson[key][packageName] = package.payload[key][packageName];
+                        legacyPackageJson[key][packageName] = dependencies[packageName];
                     }
                 });
             }
         });
 
-        fs.writeFileSync(buildPath + '/package.json', JSON.stringify(packageJson, null, 4));
+        fs.writeFileSync(buildPath + '/package.json', JSON.stringify(legacyPackageJson, null, 4));
 
-        publish(version, package.name, buildPath);
+        publish(version, es6Config.packageName, buildPath);
     });
 }
 
 /**
- * Special treatment for core.
+ * Special treatment for legacy core.
  */
-function processCore(package, version) {
-    let packageJson = require(package.path + 'package.json');
+function processLegacyCore(version) {
+    let package = {
+        "name": "core",
+        "path": "/../../"
+    };
+    let packageJson = require('../../package.json');
 
     // make a temporary directory
-    fs.ensureDirSync(basePath + 'package/');
+    fs.ensureDirSync(basePath + '/package/');
 
     let files = [
         {
-            path: basePath + "babylon.d.ts",
+            path: basePath + "/babylon.d.ts",
             objectName: "babylon.d.ts"
         },
         {
-            path: basePath + "babylon.js",
+            path: basePath + "/babylon.js",
             objectName: "babylon.js"
         },
         {
-            path: basePath + "babylon.max.js",
+            path: basePath + "/babylon.js.map",
+            objectName: "babylon.js.map"
+        },
+        {
+            path: basePath + "/babylon.max.js",
             objectName: "babylon.max.js"
         },
         {
-            path: basePath + "babylon.worker.js",
-            objectName: "babylon.worker.js"
+            path: basePath + "/babylon.max.js.map",
+            objectName: "babylon.max.js.map"
         },
         {
-            path: basePath + "Oimo.js",
+            path: basePath + "/Oimo.js",
             objectName: "Oimo.js"
         },
         {
@@ -242,7 +259,7 @@ function processCore(package, version) {
 
     //copy them to the package path
     files.forEach(file => {
-        fs.copySync(file.path, basePath + 'package/' + file.objectName);
+        fs.copySync(file.path, basePath + '/package/' + file.objectName);
     });
 
     // update package.json
@@ -262,12 +279,12 @@ function processCore(package, version) {
     packageJson.main = "babylon.js";
     packageJson.typings = "babylon.d.ts";
 
-    fs.writeFileSync(basePath + 'package/' + 'package.json', JSON.stringify(packageJson, null, 4));
+    fs.writeFileSync(basePath + '/package/' + 'package.json', JSON.stringify(packageJson, null, 4));
 
-    publish(version, package.name, basePath + 'package/');
+    publish(version, package.name, basePath + '/package/');
 
     // remove package directory
-    fs.removeSync(basePath + 'package/');
+    fs.removeSync(basePath + '/package/');
 
     // now update the main package.json
     packageJson.files = packageJson.files.map(file => {
@@ -280,7 +297,7 @@ function processCore(package, version) {
     packageJson.main = "dist/preview release/babylon.js";
     packageJson.typings = "dist/preview release/babylon.d.ts";
 
-    fs.writeFileSync(package.path + 'package.json', JSON.stringify(packageJson, null, 4));
+    fs.writeFileSync('../../package.json', JSON.stringify(packageJson, null, 4));
 }
 
 const createVersion = function(version) {

+ 1 - 1
Viewer/assets/readme.md

@@ -1,6 +1,6 @@
 # Babylon.js Viewer Assets
 
-Babylon's viewer assets package contains all needed binsry assets neeed for the proper operation of the viewer's templating system.
+Babylon's viewer assets package contains all needed binary assets neeed for the proper operation of the viewer's templating system.
 
 This packes is only needed when intalling the viewer's npm package and is installed  and used automatically.
 

+ 3 - 3
package.json

@@ -18,10 +18,10 @@
     "files": [
         "package.json",
         "dist/preview release/babylon.d.ts",
-        "dist/preview release/es6.js",
         "dist/preview release/babylon.js",
+        "dist/preview release/babylon.js.map",
         "dist/preview release/babylon.max.js",
-        "dist/preview release/babylon.worker.js",
+        "dist/preview release/babylon.max.js.map",
         "dist/preview release/Oimo.js",
         "readme.md"
     ],
@@ -105,4 +105,4 @@
         "webpack-dev-server": "^3.1.5",
         "webpack-stream": "5.0.0"
     }
-}
+}