1
-
import * as path from 'path';
2
-
3
-
import chalk from 'chalk';
4
-
import * as Debug from 'debug';
5
1
6
2
import { LOGGER_LEVELS, createPromptModule, createTaskChainWithOutput, parseArgs } from '@ionic/cli-framework';
7
-
import { findBaseDirectory } from '@ionic/cli-framework/utils/fs';
3
+
import { findBaseDirectory, fsReadJsonFile } from '@ionic/cli-framework/utils/fs';
8
4
import { TERMINAL_INFO } from '@ionic/cli-framework/utils/terminal';
5
+
import chalk from 'chalk';
6
+
import * as Debug from 'debug';
7
+
import * as path from 'path';
9
8
10
9
import { ERROR_VERSION_TOO_OLD } from './bootstrap';
11
10
import { PROJECT_FILE } from './constants';
12
-
import { IProject, InfoItem, IonicContext, IonicEnvironment } from './definitions';
11
+
import { IProject, InfoItem, IonicContext, IonicEnvironment, ProjectType } from './definitions';
13
12
import { CONFIG_FILE, Config, DEFAULT_CONFIG_DIRECTORY, gatherFlags } from './lib/config';
14
13
import { Environment } from './lib/environment';
15
14
import { Client } from './lib/http';
@@ -26,24 +25,41 @@ export * from './guards';
26
25
27
26
const debug = Debug('ionic:cli-utils');
28
27
29
-
export async function getProject(projectDir: string | undefined, deps: ProjectDeps): Promise<IProject> {
28
+
export async function getProject(projectDir: string | undefined, projectName: string | undefined, deps: ProjectDeps): Promise<IProject> {
30
29
if (!projectDir) {
31
30
return new OutsideProject('', PROJECT_FILE);
32
31
}
33
32
34
-
const type = await Project.determineType(projectDir, deps);
33
+
const projectFilePath = path.resolve(projectDir, PROJECT_FILE);
34
+
let projectFile: { [key: string]: any; } | undefined;
35
+
let type: ProjectType | undefined;
36
+
37
+
try {
38
+
projectFile = await fsReadJsonFile(projectFilePath);
39
+
} catch (e) {
40
+
debug('Attempted to load project config %s but got error: %O', projectFilePath, e);
41
+
}
42
+
43
+
if (projectFile) {
44
+
type = await Project.determineType(projectDir, projectName, projectFile, deps);
45
+
projectName = projectName || projectFile.defaultProject;
46
+
47
+
debug(`Project name: ${chalk.bold(String(projectName))}`);
48
+
}
35
49
36
50
if (!type) {
37
51
return new OutsideProject('', PROJECT_FILE);
38
52
}
39
53
40
-
return Project.createFromProjectType(projectDir, PROJECT_FILE, deps, type);
54
+
return Project.createFromProjectType(projectDir, PROJECT_FILE, projectName, deps, type);
41
55
}
42
56
43
57
export async function generateIonicEnvironment(ctx: IonicContext, pargv: string[], env: { [key: string]: string; }): Promise<IonicEnvironment> {
44
58
process.chdir(ctx.execPath);
45
59
46
-
const argv = parseArgs(pargv, { boolean: true, string: '_' });
60
+
const argv = parseArgs(pargv, { boolean: ['quiet', 'interactive', 'confirm'], string: ['_', 'project'] });
61
+
62
+
const projectName = argv['project'] ? String(argv['project']) : undefined;
47
63
const config = new Config(env['IONIC_CONFIG_DIRECTORY'] || DEFAULT_CONFIG_DIRECTORY, CONFIG_FILE);
48
64
const flags = gatherFlags(argv);
49
65
@@ -59,7 +75,10 @@ export async function generateIonicEnvironment(ctx: IonicContext, pargv: string[
59
75
handlers: new Set(),
60
76
});
61
77
62
-
const prompt = await createPromptModule({ interactive: flags.interactive, onFallback: createOnFallback({ ...flags, log }) });
78
+
const prompt = await createPromptModule({
79
+
interactive: flags.interactive,
80
+
onFallback: createOnFallback({ ...flags, log }),
81
+
});
63
82
const tasks = createTaskChainWithOutput(
64
83
flags.interactive
65
84
? { output: prompt.output }
@@ -76,7 +95,13 @@ export async function generateIonicEnvironment(ctx: IonicContext, pargv: string[
76
95
const npm = await shell.cmdinfo('npm', ['-v']);
77
96
78
97
const info: InfoItem[] = [
79
-
{ group: 'ionic', key: 'ionic', flair: 'Ionic CLI', value: ctx.version, path: path.dirname(path.dirname(ctx.libPath)) },
98
+
{
99
+
group: 'ionic',
100
+
key: 'ionic',
101
+
flair: 'Ionic CLI',
102
+
value: ctx.version,
103
+
path: path.dirname(path.dirname(ctx.libPath)),
104
+
},
80
105
{ group: 'system', key: 'NodeJS', value: process.version, path: process.execPath },
81
106
{ group: 'system', key: 'npm', value: npm || 'not installed' },
82
107
{ group: 'system', key: 'OS', value: os },
@@ -89,7 +114,7 @@ export async function generateIonicEnvironment(ctx: IonicContext, pargv: string[
89
114
};
90
115
91
116
const shell = new Shell({ log, projectDir });
92
-
const project = await getProject(projectDir, { config, log, shell, tasks });
117
+
const project = await getProject(projectDir, projectName, { config, log, shell, tasks });
93
118
const client = new Client(config);
94
119
const session = new ProSession({ config, client, project });
95
120
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4