Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
chore(Webpack): trying to build project with webpack instead of parceljs
Browse files Browse the repository at this point in the history
  • Loading branch information
Stradivario committed Nov 18, 2019
1 parent 0646be4 commit 404ad48
Show file tree
Hide file tree
Showing 23 changed files with 3,009 additions and 655 deletions.
12 changes: 0 additions & 12 deletions dist/bin/root.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
#!/usr/bin/env node
import { ExternalImporterIpfsConfig } from '../services/external-importer/external-importer-config';
import { Observable } from 'rxjs';
export interface PackagesConfig {
dependencies: string[];
provider: string;
}
export declare const loadDeps: (jsonIpfs: PackagesConfig) => {
hash: string;
provider: string;
}[];
export declare const DownloadDependencies: (dependencies: ExternalImporterIpfsConfig[]) => Observable<any>;
267 changes: 140 additions & 127 deletions dist/bin/root.js
Original file line number Diff line number Diff line change
@@ -1,127 +1,140 @@
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Container_1 = require("../container/Container");
const external_importer_1 = require("../services/external-importer/external-importer");
const file_service_1 = require("../services/file/file.service");
const config_service_1 = require("../services/config/config.service");
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const includes = (i) => process.argv.toString().includes(i);
const externalImporter = Container_1.Container.get(external_importer_1.ExternalImporter);
const fileService = Container_1.Container.get(file_service_1.FileService);
let p = null;
if (includes('--local-node')) {
p = externalImporter.getProvider('local');
}
if (includes('--cloudflare')) {
p = externalImporter.getProvider('cloudflare');
}
if (includes('--infura')) {
p = externalImporter.getProvider('infura');
}
if (includes('--ipfs')) {
p = externalImporter.getProvider('main-ipfs-node');
}
externalImporter.defaultProvider = p || externalImporter.defaultProvider;
let provider = externalImporter.defaultProvider;
let hash = '';
let modulesToDownload = [];
let customConfigFile;
let packageJsonConfigFile;
let rxdiConfigFile;
let json;
exports.loadDeps = (jsonIpfs) => {
if (!jsonIpfs) {
throw new Error('Missing ipfs config!');
}
if (!jsonIpfs.provider) {
throw new Error('Missing ipfsProvider package.json');
}
jsonIpfs.dependencies = jsonIpfs.dependencies || [];
return jsonIpfs.dependencies.map(hash => {
return { hash, provider: jsonIpfs.provider };
}).filter(res => !!res);
};
exports.DownloadDependencies = (dependencies) => {
return Container_1.Container.get(external_importer_1.ExternalImporter).downloadIpfsModules(dependencies);
};
if (process.argv.toString().includes('-v') || process.argv.toString().includes('--verbose')) {
Container_1.Container.get(config_service_1.ConfigService).setConfig({ logger: { logging: true, hashes: true, date: true, exitHandler: true, fileService: true } });
}
console.log('');
if (process.argv[2] === 'install' || process.argv[2] === 'i') {
process.argv.forEach((val, index) => {
if (index === 3) {
if (val.length === 46) {
hash = val;
}
else if (val.includes('--hash=')) {
hash = val.split('--hash=')[1];
}
else if (val.includes('-h=')) {
hash = val.split('-h=')[1];
}
}
if (index === 4) {
if (val.includes('--provider=')) {
provider = val.split('--provider=')[1];
}
else if (val.includes('http')) {
provider = val;
}
else if (val.includes('-p=')) {
provider = val.split('-p=')[1];
}
}
});
customConfigFile = `${process.cwd()}/${process.argv[3]}`;
packageJsonConfigFile = `${process.cwd()}/package.json`;
rxdiConfigFile = `${process.cwd()}/reactive.json`;
if (!hash && fileService.isPresent(customConfigFile)) {
json = require(customConfigFile).ipfs;
externalImporter.defaultJsonFolder = customConfigFile;
}
if (fileService.isPresent(packageJsonConfigFile)) {
json = require(packageJsonConfigFile).ipfs;
externalImporter.defaultJsonFolder = packageJsonConfigFile;
}
if (fileService.isPresent(rxdiConfigFile)) {
json = require(rxdiConfigFile).ipfs;
externalImporter.defaultJsonFolder = rxdiConfigFile;
}
console.log(`Loaded config ${externalImporter.defaultJsonFolder}`);
console.log('Reactive ipfs modules installing...');
if (hash) {
modulesToDownload = [exports.DownloadDependencies(exports.loadDeps({ provider: p || provider, dependencies: [hash] }))];
}
if (!hash) {
json = json || [];
modulesToDownload = [...modulesToDownload, ...json.map(json => {
json.provider = p || json.provider;
return exports.DownloadDependencies(exports.loadDeps(json));
})];
}
rxjs_1.combineLatest(modulesToDownload)
.pipe(operators_1.tap(() => hash ? externalImporter.addPackageToJson(hash) : null), operators_1.tap(() => externalImporter.filterUniquePackages())).subscribe((res) => {
console.log('Default ipfs provider: ', p || externalImporter.defaultProvider);
console.log(`Inside package.json default provider is ${externalImporter.defaultProvider}`);
console.log(JSON.stringify(res, null, 2), '\nReactive ipfs modules installed!');
// clearInterval(interval);
}, (e) => {
throw new Error(e);
});
}
if (process.argv[2] === '--ng-compat') {
const fileService = Container_1.Container.get(file_service_1.FileService);
const AngularCoreFolder = './node_modules/@angular/core/';
const template = `
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
__export(require("@rxdi/core"));
exports.NgModule = require("@rxdi/core").Module;
`;
fileService.mkdirp(AngularCoreFolder)
.pipe(operators_1.switchMap(() => fileService.writeFileAsyncP(AngularCoreFolder, 'index.js', template))).subscribe(() => console.log('@angular/core folder created with fake index.js exporting @rxdi/core'), console.log.bind(console));
}
// #!/usr/bin/env node
// import { Container } from '../container/Container';
// import { ExternalImporter } from '../services/external-importer/external-importer';
// import { FileService } from '../services/file/file.service';
// import { ExternalImporterIpfsConfig } from '../services/external-importer/external-importer-config';
// import { ConfigService } from '../services/config/config.service';
// import { Observable, combineLatest, pipe } from 'rxjs';
// import { tap, switchMap } from 'rxjs/operators';
// import { writeFileSync } from 'fs';
// import { mkdirp } from '../services/file/dist';
// const includes = (i: string) => process.argv.toString().includes(i);
// const externalImporter = Container.get(ExternalImporter);
// const fileService = Container.get(FileService);
// let p = null;
// if (includes('--local-node')) {
// p = externalImporter.getProvider('local');
// }
// if (includes('--cloudflare')) {
// p = externalImporter.getProvider('cloudflare');
// }
// if (includes('--infura')) {
// p = externalImporter.getProvider('infura');
// }
// if (includes('--ipfs')) {
// p = externalImporter.getProvider('main-ipfs-node');
// }
// externalImporter.defaultProvider = p || externalImporter.defaultProvider;
// let provider = externalImporter.defaultProvider;
// let hash = '';
// let modulesToDownload = [];
// let customConfigFile;
// let packageJsonConfigFile;
// let rxdiConfigFile;
// let json: PackagesConfig[];
// // let interval;
// export interface PackagesConfig {
// dependencies: string[];
// provider: string;
// }
// export const loadDeps = (jsonIpfs: PackagesConfig) => {
// if (!jsonIpfs) {
// throw new Error('Missing ipfs config!');
// }
// if (!jsonIpfs.provider) {
// throw new Error('Missing ipfsProvider package.json');
// }
// jsonIpfs.dependencies = jsonIpfs.dependencies || [];
// return jsonIpfs.dependencies.map(hash => {
// return { hash, provider: jsonIpfs.provider };
// }).filter(res => !!res);
// };
// export const DownloadDependencies = (dependencies: ExternalImporterIpfsConfig[]): Observable<any> => {
// return Container.get(ExternalImporter).downloadIpfsModules(dependencies);
// };
// if (process.argv.toString().includes('-v') || process.argv.toString().includes('--verbose')) {
// Container.get(ConfigService).setConfig({ logger: { logging: true, hashes: true, date: true, exitHandler: true, fileService: true } });
// }
// console.log('');
// if (process.argv[2] === 'install' || process.argv[2] === 'i') {
// process.argv.forEach((val, index) => {
// if (index === 3) {
// if (val.length === 46) {
// hash = val;
// } else if (val.includes('--hash=')) {
// hash = val.split('--hash=')[1];
// } else if (val.includes('-h=')) {
// hash = val.split('-h=')[1];
// }
// }
// if (index === 4) {
// if (val.includes('--provider=')) {
// provider = val.split('--provider=')[1];
// } else if (val.includes('http')) {
// provider = val;
// } else if (val.includes('-p=')) {
// provider = val.split('-p=')[1];
// }
// }
// });
// customConfigFile = `${process.cwd()}/${process.argv[3]}`;
// packageJsonConfigFile = `${process.cwd()}/package.json`;
// rxdiConfigFile = `${process.cwd()}/reactive.json`;
// if (!hash && fileService.isPresent(customConfigFile)) {
// json = require(customConfigFile).ipfs;
// externalImporter.defaultJsonFolder = customConfigFile;
// }
// if (fileService.isPresent(packageJsonConfigFile)) {
// json = require(packageJsonConfigFile).ipfs;
// externalImporter.defaultJsonFolder = packageJsonConfigFile;
// }
// if (fileService.isPresent(rxdiConfigFile)) {
// json = require(rxdiConfigFile).ipfs;
// externalImporter.defaultJsonFolder = rxdiConfigFile;
// }
// console.log(`Loaded config ${externalImporter.defaultJsonFolder}`);
// console.log('Reactive ipfs modules installing...');
// if (hash) {
// modulesToDownload = [DownloadDependencies(loadDeps({ provider: p || provider, dependencies: [hash] }))];
// }
// if (!hash) {
// json = json || [];
// modulesToDownload = [...modulesToDownload, ...json.map(json => {
// json.provider = p || json.provider;
// return DownloadDependencies(loadDeps(json));
// })];
// }
// combineLatest(modulesToDownload)
// .pipe(
// tap(() => hash ? externalImporter.addPackageToJson(hash) : null),
// tap(() => externalImporter.filterUniquePackages())
// ).subscribe(
// (res) => {
// console.log('Default ipfs provider: ', p || externalImporter.defaultProvider);
// console.log(`Inside package.json default provider is ${externalImporter.defaultProvider}`);
// console.log(JSON.stringify(res, null, 2), '\nReactive ipfs modules installed!');
// // clearInterval(interval);
// },
// (e) => {
// throw new Error(e);
// }
// );
// }
// if (process.argv[2] === '--ng-compat') {
// const fileService = Container.get(FileService);
// const AngularCoreFolder = './node_modules/@angular/core/';
// const template = `
// function __export(m) {
// for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
// }
// __export(require("@rxdi/core"));
// exports.NgModule = require("@rxdi/core").Module;
// `;
// fileService.mkdirp(AngularCoreFolder)
// .pipe(
// switchMap(() => fileService.writeFileAsyncP(AngularCoreFolder, 'index.js', template))
// ).subscribe(
// () => console.log('@angular/core folder created with fake index.js exporting @rxdi/core'),
// console.log.bind(console)
// );
// }
2 changes: 1 addition & 1 deletion dist/helpers/reflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ exports.Reflection = {
metadata
};
Object.assign(Reflect, exports.Reflection);
//# sourceMappingURL=index.js.map
// # sourceMappingURL=index.js.map
17 changes: 17 additions & 0 deletions dist/main.bundle.js

Large diffs are not rendered by default.

Loading

0 comments on commit 404ad48

Please sign in to comment.