feat: additional base setup

This commit is contained in:
Igor Randjelovic
2020-11-14 16:16:49 +01:00
parent 2be179a8d0
commit b22e1c2361
6 changed files with 248 additions and 77 deletions

View File

@@ -1,27 +1,40 @@
import { existsSync } from 'fs';
import { resolve } from 'path';
import { IWebpackEnv } from '@nativescript/webpack';
import { existsSync } from "fs";
import { resolve } from "path";
export function getDistPath(env: IWebpackEnv) {
if (env.ios) {
return `platforms/ios/[todo]/app`;
}
if (env.android) {
return `platforms/android/app/src/main/assets/app`;
}
// todo: additional platforms
// perhaps we could combine platform specifics into "plugins"
// 3rd party platforms would be treated the same
}
export function getPackageJson(projectDir: string) {
const packageJsonPath = getPackageJsonPath(projectDir);
const result = readJsonFile(packageJsonPath);
const packageJsonPath = getPackageJsonPath(projectDir);
const result = readJsonFile(packageJsonPath);
return result;
return result;
}
export function readJsonFile(filePath:string) {
return require(filePath) as {
main:string
// to be extended?
};
export function readJsonFile(filePath: string) {
return require(filePath) as {
main: string;
// to be extended?
};
}
export function getPackageJsonPath (projectDir: string) {
const packagePath = resolve(projectDir, "package.json");
if (existsSync(packagePath)) {
return packagePath;
} else {
return getPackageJsonPath(resolve(projectDir, '..'));
}
}
export function getPackageJsonPath(projectDir: string) {
const packagePath = resolve(projectDir, 'package.json');
if (existsSync(packagePath)) {
return packagePath;
} else {
return getPackageJsonPath(resolve(projectDir, '..'));
}
}