Comparing version 0.134.0-2021111209 to 0.134.0-2021111218
250
bin/patch.js
@@ -9,5 +9,8 @@ #!/usr/bin/env node | ||
const fs = require('fs'); | ||
const colors = require('colors'); | ||
const readline = require('readline'); | ||
const { exec } = require("child_process"); | ||
// const prompt = require('prompt'); | ||
const fs = require('fs'); | ||
const cwd = process.cwd(); | ||
@@ -17,105 +20,174 @@ | ||
let rawdata = fs.readFileSync(cwd + '/' + fileName + '.json'); | ||
rawdata = rawdata.toString().replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m); | ||
rawdata = rawdata | ||
.toString() | ||
.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => | ||
g ? '' : m | ||
); | ||
return JSON.parse(rawdata); | ||
} | ||
function writeJson(fileName, jsonData, comment , callBack) { | ||
function writeJson(fileName, jsonData, comment, callBack) { | ||
let data = JSON.stringify(jsonData, null, 2); | ||
if (comment !== undefined && comment !== null && comment !== '') { | ||
data = '/** ' + comment + ' */\n' + data; | ||
} | ||
if (comment !== undefined && comment !== null && comment !== '') { | ||
data = '/** ' + comment + ' */\n' + data; | ||
} | ||
fs.writeFile(cwd + '/' + fileName + '.json', data, (err) => { | ||
if (err) throw err; | ||
console.log('Json file mofifyed -> ' + (fileName + '.json').red); | ||
if (callBack !== undefined && callBack !== null) { | ||
callBack(); | ||
} | ||
}); | ||
console.log('Json file modified -> ' + (fileName + '.json').red); | ||
if (callBack !== undefined && callBack !== null) { | ||
callBack(); | ||
} | ||
}); | ||
} | ||
const packageJson = readJson('package'); | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
if (packageJson['dependencies'] === undefined) { | ||
packageJson['dependencies'] = {} | ||
} | ||
const dependencies = packageJson['dependencies']; | ||
dependencies["ammojs-typed"] = "^1.0.6"; | ||
dependencies["chroma-js"] = "^2.1.2"; | ||
dependencies["fs"] = "0.0.1-security"; | ||
dependencies["fs-web"] = "^1.0.1"; | ||
dependencies["gsap"] = "^3.8.0"; | ||
dependencies["lil-gui"] = "^0.12.0"; | ||
dependencies["three"] = "^0.134.0"; | ||
const question = | ||
'\n\nThis program will change some json file for ngx3js.\n\nDo you want to check out and modify ' + | ||
'angular.json'.red + | ||
' , ' + | ||
'package.json'.red + | ||
', ' + | ||
'tsconfig.json'.red + | ||
' files? (Y/N)'; | ||
if (packageJson['devDependencies'] === undefined) { | ||
packageJson['devDependencies'] = {} | ||
} | ||
const devDependencies = packageJson['devDependencies']; | ||
devDependencies["@types/three"] = "0.134.0"; | ||
devDependencies["@types/chroma-js"] = "^2.1.2"; | ||
rl.question(question, function (agree) { | ||
rl.close(); | ||
switch (agree) { | ||
case 'YES': | ||
case 'Y': | ||
case 'Yes': | ||
case 'yes': | ||
case 'y': | ||
const packageJson = readJson('package'); | ||
if (packageJson['dependencies'] === undefined) { | ||
packageJson['dependencies'] = {}; | ||
} | ||
const dependencies = packageJson['dependencies']; | ||
dependencies['ammojs-typed'] = '^1.0.6'; | ||
dependencies['chroma-js'] = '^2.1.2'; | ||
dependencies['fs'] = '0.0.1-security'; | ||
dependencies['fs-web'] = '^1.0.1'; | ||
dependencies['gsap'] = '^3.8.0'; | ||
dependencies['lil-gui'] = '^0.12.0'; | ||
dependencies['three'] = '0.134.0'; | ||
if (packageJson['devDependencies'] === undefined) { | ||
packageJson['devDependencies'] = {}; | ||
} | ||
const devDependencies = packageJson['devDependencies']; | ||
devDependencies['@types/three'] = '0.134.0'; | ||
devDependencies['@types/chroma-js'] = '^2.1.2'; | ||
const tsconfigJson = readJson('tsconfig'); | ||
if (tsconfigJson['compilerOptions'] === undefined) { | ||
tsconfigJson['compilerOptions'] = {} | ||
} | ||
const compilerOptions = tsconfigJson['compilerOptions']; | ||
if (compilerOptions['paths'] === undefined) { | ||
compilerOptions['paths'] = {} | ||
} | ||
const compilerOptionsPaths = compilerOptions['paths']; | ||
compilerOptionsPaths["fs"] = ["./node_modules/fs-web"]; | ||
const tsconfigJson = readJson('tsconfig'); | ||
if (tsconfigJson['compilerOptions'] === undefined) { | ||
tsconfigJson['compilerOptions'] = {}; | ||
} | ||
const compilerOptions = tsconfigJson['compilerOptions']; | ||
if (compilerOptions['paths'] === undefined) { | ||
compilerOptions['paths'] = {}; | ||
} | ||
const compilerOptionsPaths = compilerOptions['paths']; | ||
compilerOptionsPaths['fs'] = ['./node_modules/fs-web']; | ||
const angularJson = readJson('angular'); | ||
const angularJson = readJson('angular'); | ||
const defaultProject = angularJson['defaultProject']; | ||
const defaultProject = angularJson['defaultProject']; | ||
const projects = angularJson['projects'][defaultProject]; | ||
if (projects['architect']['build']['options'] === undefined) { | ||
projects['architect']['build']['options'] = {} | ||
} | ||
const architectBuildOptions = projects['architect']['build']['options']; | ||
if (architectBuildOptions['allowedCommonJsDependencies'] === undefined) { | ||
architectBuildOptions['allowedCommonJsDependencies'] = []; | ||
} | ||
const allowedCommonJsDependencies = architectBuildOptions['allowedCommonJsDependencies']; | ||
if (allowedCommonJsDependencies.indexOf('ammojs-typed') === -1) { | ||
allowedCommonJsDependencies.push('ammojs-typed'); | ||
} | ||
if (architectBuildOptions['assets'] === undefined) { | ||
architectBuildOptions['assets'] = [] | ||
} | ||
const assets = architectBuildOptions['assets']; | ||
let isAssetFounded = false; | ||
assets.forEach(function(assInfo) { | ||
if (typeof assInfo === 'string') { | ||
if (assInfo === './node_modules/ngx3js/assets') { | ||
isAssetFounded = true; | ||
} | ||
} else if (assInfo['input'] === './node_modules/ngx3js/assets') { | ||
isAssetFounded = true; | ||
} | ||
const projects = angularJson['projects'][defaultProject]; | ||
if (projects['architect']['build']['options'] === undefined) { | ||
projects['architect']['build']['options'] = {}; | ||
} | ||
const architectBuildOptions = projects['architect']['build']['options']; | ||
if (architectBuildOptions['allowedCommonJsDependencies'] === undefined) { | ||
architectBuildOptions['allowedCommonJsDependencies'] = []; | ||
} | ||
const allowedCommonJsDependencies = | ||
architectBuildOptions['allowedCommonJsDependencies']; | ||
if (allowedCommonJsDependencies.indexOf('ammojs-typed') === -1) { | ||
allowedCommonJsDependencies.push('ammojs-typed'); | ||
} | ||
if (architectBuildOptions['assets'] === undefined) { | ||
architectBuildOptions['assets'] = []; | ||
} | ||
const assets = architectBuildOptions['assets']; | ||
let isAssetFounded = false; | ||
assets.forEach(function (assInfo) { | ||
if (typeof assInfo === 'string') { | ||
if (assInfo === './node_modules/ngx3js/assets') { | ||
isAssetFounded = true; | ||
} | ||
} else if (assInfo['input'] === './node_modules/ngx3js/assets') { | ||
isAssetFounded = true; | ||
} | ||
}); | ||
if (!isAssetFounded) { | ||
assets.push({ | ||
glob: '**/*', | ||
input: './node_modules/ngx3js/assets', | ||
output: '/assets/examples/', | ||
}); | ||
} | ||
writeJson('package', packageJson, null, function () { | ||
console.log( | ||
'./package.json -- dependencies && devDependencies installed!\n' | ||
); | ||
writeJson( | ||
'./tsconfig', | ||
tsconfigJson, | ||
'To learn more about this file see: https://angular.io/config/tsconfig.', | ||
function () { | ||
console.log('./tsconfig.json -- compilerOptions installed!\n'); | ||
writeJson('angular', angularJson, null, function () { | ||
console.log('auto run '+'npm install'.red +'!!!'); | ||
exec("npm install", function(error, stdout, stderr) { | ||
if (error) { | ||
console.log(`error: ${error.message}`); | ||
} | ||
if (stderr) { | ||
console.log(`stderr: ${stderr}`); | ||
} | ||
if (stdout) { | ||
console.log(`stdout: ${stdout}`); | ||
} | ||
console.log( | ||
'./angular.json -- assets && allowedCommonJsDependencies installed!\n' | ||
); | ||
console.log( | ||
'RE RUN TO INSTALL "' + 'npm install'.red + '"' + ' in shell' | ||
); | ||
console.log( | ||
'RE RUN TO UPDATE "' + 'npm update'.red + '"' + ' in shell' | ||
); | ||
console.log('example - https://outmindkjg.github.io/ngx3js-doc/'); | ||
console.log( | ||
'api doc - https://outmindkjg.github.io/ngx3js-doc/docs' | ||
); | ||
console.log( | ||
'git hub - https://github.com/outmindkjg/ngx3js-module' | ||
); | ||
console.log('npm - https://www.npmjs.com/package/ngx3js'); | ||
console.log( | ||
'usage - https://github.com/outmindkjg/ngx3js-module#usage' | ||
); | ||
console.log('question - outmind0@gmail.com'); | ||
console.log( | ||
'\n' + 'Thank You - Patch ' + 'Success'.green + '!.\n\n' | ||
); | ||
}); | ||
}); | ||
} | ||
); | ||
}); | ||
break; | ||
default: | ||
console.log('usage - https://github.com/outmindkjg/ngx3js-module#usage'); | ||
console.log('Read this page to use ngx3js'); | ||
console.log('\n' + 'Thank You - Patch ' + 'Failed'.red + '!\n\n'); | ||
break; | ||
} | ||
}); | ||
if (!isAssetFounded) { | ||
assets.push({ | ||
"glob": "**/*", | ||
"input": "./node_modules/ngx3js/assets", | ||
"output": "/assets/examples/" | ||
}) | ||
} | ||
(async() => { | ||
writeJson('package', packageJson, null, function() { | ||
console.log('package.json dependencies && devDependencies installed!\n'); | ||
writeJson('tsconfig', tsconfigJson, 'To learn more about this file see: https://angular.io/config/tsconfig.', function() { | ||
console.log('tsconfig.json compilerOptions installed!\n'); | ||
writeJson('angular', angularJson, null, function() { | ||
console.log('angular.json assets && allowedCommonJsDependencies installed!\n'); | ||
console.log('RE RUN TO INSTALL "' +'npm install'.red + '"' + ' in shell'); | ||
console.log('RE RUN TO UPDATE "' +'npm update'.red + '"' + ' in shell'); | ||
console.log('\nThank You\n\n'); | ||
}) | ||
}); | ||
}); | ||
})(); | ||
{ | ||
"name": "ngx3js", | ||
"version": "0.134.0-2021111209", | ||
"version": "0.134.0-2021111218", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "three", |
@@ -22,3 +22,3 @@ ngx3js | ||
#### Auto Install #### | ||
#### Ngx3js Install - Method 1 - Recommanded #### | ||
```sh | ||
@@ -32,3 +32,3 @@ # install shell script | ||
#### Npm Install #### | ||
#### Ngx3js Install - Method 2 #### | ||
```sh | ||
@@ -59,3 +59,3 @@ # install by npm | ||
#### Imports Ngx3JsModule #### | ||
#### Imports Ngx3JsModule - Required #### | ||
@@ -75,2 +75,20 @@ To use ngx3js have to import Ngx3JsModule in src/app/app.module.ts or some other place modle.ts | ||
#### Change Default Assets Url - optional #### | ||
If you chhange assets in angular.json file must be setted! | ||
```ts | ||
// src/app/app.component.ts | ||
import { ThreeUtil } from 'ngx3js'; | ||
export class AppComponent { | ||
ngOnInit(): void { | ||
// any where use ngx3js for just one time | ||
ThreeUtil.setAssetUrl('assets/examples/'); | ||
} | ||
} | ||
``` | ||
#### Chane angular.json for ammojs-typed and basic assets #### | ||
@@ -133,4 +151,5 @@ | ||
// src/app/app.component.html | ||
~~~html | ||
<!-- src/app/app.component.html --> | ||
<div style="width: 700px; height: 500px; display: block; position: relative"> | ||
@@ -215,5 +234,7 @@ <ngx3js-renderer | ||
### Change log ### | ||
### Change log & Ask Question ### | ||
[Releases](https://github.com/outmindkjg/ngx3js-module/releases) | ||
- [Releases - GitHub](https://github.com/outmindkjg/ngx3js-module/releases) | ||
- [ISSUE - GitHub](https://github.com/outmindkjg/ngx3js-module/issues) | ||
- [Email - outmind0@gmail.com](outmind0@gmail.com) | ||
@@ -220,0 +241,0 @@ |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
31668345
262501
242
41