Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getProjectAnalyzer (waneCompilerOptions: Partial = {}): ProjectAnalyzer {
// console.log(`Compiling a Wane app with the following options:`)
// console.log(JSON.stringify(options, null, 2))
/**
* Setting up phase. We copy all files from the source to destination directory.
* Then we manipulate the copies of files.
*/
const { srcDir, distDir } = getDirs(waneCompilerOptions)
fs.removeSync(distDir)
fs.mkdirpSync(distDir)
fs.copySync(srcDir, distDir)
/**
* We load the project (from the desination folder) into a new ts-simple-ast Project.
*/
const projectOptions = {
compilerOptions: {
outDir: distDir,
experimentalDecorators: true,
target: ScriptTarget.ES2017,
module: ModuleKind.ES2015,
strict: true,
noFallthroughCasesInSwitch: true,
noImplicitReturns: true,
});
})
.then(() => {
console.log(`${appToConvert.name} converted successfully`);
return null;
})
.catch(() => {
console.error(`${appToConvert.name} conversion failed. See ${logFile}.`);
return appToConvert.name;
});
};
global.argOpts = {};
const rootTmpDir = tmp.tmpNameSync();
fse.removeSync(rootTmpDir);
fse.ensureDirSync(rootTmpDir);
const tasks = _.map(appsToConvert, template =>
testConvertedApp(template, rootTmpDir)
);
Promise.all(tasks).then(results => {
const failures = _.filter(results, result => result !== null);
if (failures.length) {
console.error('these apps failed conversion:', failures.join(', '));
} else {
console.log('apps converted successfully');
}
});
it('should transform and generate or copy the files', () => {
let distFile1 = path.join(distPath, 'boolean.txt')
let fixFile1 = path.join(__dirname, 'fixtures/generator/compare/boolean.txt')
let distFile2 = path.join(distPath, 'number.txt')
let fixFile2 = path.join(__dirname, 'fixtures/generator/compare/number.txt')
let distFile3 = path.join(distPath, 'some-module-name/some-module-name.txt')
let fixFile3 = path.join(__dirname, 'fixtures/generator/compare/some-module-name/some-module-name.txt')
let distFile4 = path.join(distPath, 'favicon.png')
fs.removeSync(distPath)
assert.equal(fs.existsSync(distPath), false)
generator.run()
assert.equal(fs.existsSync(distPath), true)
assert.equal(fs.existsSync(distFile1), true)
assert.equal(fs.existsSync(distFile2), true)
assert.equal(fs.existsSync(distFile3), true)
assert.equal(fs.readFileSync(distFile1, 'utf8'), fs.readFileSync(fixFile1, 'utf8'))
assert.equal(fs.readFileSync(distFile2, 'utf8'), fs.readFileSync(fixFile2, 'utf8'))
assert.equal(fs.readFileSync(distFile3, 'utf8'), fs.readFileSync(fixFile3, 'utf8'))
assert.equal(fs.existsSync(distFile4), true)
})
afterEach(async function () {
fs.removeSync('./contracts')
fs.removeSync('./deployment')
fs.removeSync('./test')
fs.removeSync('./web')
fs.removeSync('./node_modules')
fs.removeSync('./package.json')
fs.removeSync('./package-lock.json');
fs.removeSync('./README.md');
fs.removeSync('./.git');
fs.removeSync('./.etherlime-store')
fs.removeSync('./.gitignore')
process.chdir(currentDir);
});
try {
var stat = fse.statSync(json)
}catch(e) {
chai.expect(stat).to.be.undefined;
}
try {
var stat = fse.statSync(html)
}catch(e) {
chai.expect(stat).to.be.undefined;
}
json = path.join(config.root, config.data.url, resSave2.json.abe_meta.latest.abeUrl.replace('.html', '.json'))
var stat = fse.statSync(json)
if (stat) {
chai.expect(stat).to.not.be.undefined;
}
fse.removeSync(json)
done()
}.bind(this));
}.bind(this));
switch (template) {
case 'vue':
await cloneProjectFromGithub('https://github.com/PortalNetwork/vue-truffle.git', projectName);
break;
case 'react-near':
await cloneProjectFromGithub('https://github.com/PortalNetwork/react-near.git', projectName);
break;
case 'plain-near':
await cloneProjectFromGithub('https://github.com/PortalNetwork/plain-near.git', projectName);
break;
case 'react':
default:
await cloneProjectFromGithub('https://github.com/PortalNetwork/react-truffle.git', projectName);
break;
}
fsx.removeSync(`./${projectName}/.git`);
Spinner.stop();
Log.SuccessLog(`\nCreate ${projectName} Successfully`);
Log.NormalLog('Now you can use ' + `'cd ${projectName}'`.yellow + ' to the project folder.');
Log.NormalLog('After you get into the folder, you can install the node packages by using ' + '\'npm install\''.yellow);
Log.NormalLog('Let\'s start BUIDL!'.green);
} catch (error) {
Spinner.stop();
Log.ErrorLog('something went wrong!');
console.error(error);
}
}
deleteDataFileSync(filePath) {
const fullPath = path.join(this._dataPath, filePath);
fs.removeSync(fullPath);
}
}
async function getReleases() {
fs.removeSync('./releases')
fs.mkdirSync('./releases')
let hasNext = true
let after
while (hasNext) {
const {
data: {
data: {
repository: {
releases: {
pageInfo: { hasNextPage, endCursor },
nodes,
},
},
},
private handleAppend(relativePath: string) {
let upstreamPath = join(this.upstreamDir, relativePath);
let outputPath = join(this.outputPath, relativePath);
let ext = extname(relativePath);
if (!existsSync(upstreamPath)) {
removeSync(outputPath);
return;
}
let sourceDir = join(this.appendedDir, this.reverseMappings.get(relativePath)!);
if (!existsSync(sourceDir)) {
symlinkOrCopy.sync(upstreamPath, outputPath);
return;
}
const separator = (ext === '.js') ? ';\n' : '\n';
let appendedContent = readdirSync(sourceDir).map(name => {
if (name.endsWith(ext)) {
return readFileSync(join(sourceDir, name), 'utf8');
}
}).filter(Boolean).join(separator);
async build() {
await super.build();
let appHelpersDir = join(this.outputPath, '_app_', 'helpers');
let addonHelpersDir = join(this.inputPaths[0], 'helpers');
for (let filename of readdirSync(appHelpersDir)) {
if (!pathExistsSync(join(addonHelpersDir, filename))) {
removeSync(join(appHelpersDir, filename));
}
}
let src = readFileSync(join(this.inputPaths[0], 'index.js'), 'utf8');
let plugins = [stripBadReexportsPlugin({ resolveBase: this.outputPath })];
writeFileSync(join(this.outputPath, 'index.js'), transform(src, { plugins })!.code);
}
}