FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

docs: update and add page for project types · ascorbic/ionic-cli@8fb9412 · GitHub

Repository navigation

Commit 8fb9412

Browse files
committed
docs: update and add page for project types
1 parent 11f0da6 commit 8fb9412

8 files changed

Lines changed: 163 additions & 48 deletions

File tree

‎packages/@ionic/cli-scripts/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@ionic/cli-framework": "0.1.2",
1515
"@ionic/cli-utils": "1.19.0",
1616
"ansi-styles": "^3.2.0",
17+
"ascii-tree": "^0.3.0",
1718
"escape-string-regexp": "^1.0.5",
1819
"ionic": "3.19.0",
1920
"strip-ansi": "^4.0.0",

‎packages/@ionic/cli-scripts/src/docs/index.ts‎

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ import * as path from 'path';
22

33
import { generateRootPlugin } from 'ionic';
44
import { Command } from '@ionic/cli-framework';
5-
import { copyDirectory, fsMkdirp, fsStat, fsWriteFile } from '@ionic/cli-framework/utils/fs';
6-
5+
import { copyDirectory, fsMkdirp, fsReadDir, fsStat, fsWriteFile } from '@ionic/cli-framework/utils/fs';
76
import { generateIonicEnvironment } from '@ionic/cli-utils';
87

9-
import formatIndexPage from './pages/index';
10-
import formatConfiguringPage from './pages/configuring';
11-
import formatCommandsPage from './pages/commands';
12-
import formatStartersPage from './pages/starters';
138
import { formatCommandDoc, generateFullName, getCommandList } from './pages/commands';
149

1510
export class DocsCommand extends Command {
@@ -24,24 +19,19 @@ export class DocsCommand extends Command {
2419
const plugin = await generateRootPlugin();
2520
const env = await generateIonicEnvironment(plugin, process.argv.slice(2), process.env);
2621

27-
const indexPath = path.resolve(__dirname, '..', '..', '..', '..', '..', 'docs', 'index.md');
28-
const indexDoc = await formatIndexPage(env);
29-
30-
const commandsPath = path.resolve(__dirname, '..', '..', '..', '..', '..', 'docs', 'commands.md');
31-
const commandsDoc = await formatCommandsPage(env);
32-
33-
const configuringPath = path.resolve(__dirname, '..', '..', '..', '..', '..', 'docs', 'configuring.md');
34-
const configuringDoc = await formatConfiguringPage();
22+
const mdPath = path.resolve(__dirname, '..', '..', '..', '..', '..', 'docs');
23+
const pagesDir = path.resolve(__dirname, 'pages');
24+
const pages = (await fsReadDir(pagesDir)).filter(f => path.extname(f) === '.js').map(f => path.resolve(pagesDir, f)); // dist/docs/pages/*.js
3525

36-
const startersPath = path.resolve(__dirname, '..', '..', '..', '..', '..', 'docs', 'starters.md');
37-
const startersDoc = await formatStartersPage();
26+
await fsMkdirp(mdPath);
3827

39-
await fsMkdirp(path.dirname(indexPath));
40-
41-
await fsWriteFile(indexPath, indexDoc, { encoding: 'utf8' });
42-
await fsWriteFile(commandsPath, commandsDoc, { encoding: 'utf8' });
43-
await fsWriteFile(configuringPath, configuringDoc, { encoding: 'utf8' });
44-
await fsWriteFile(startersPath, startersDoc, { encoding: 'utf8' });
28+
for (const p of pages) {
29+
const name = path.basename(p).slice(0, -path.extname(p).length);
30+
const render = require(p).default;
31+
const pageMdPath = path.resolve(mdPath, `${name}.md`);
32+
const renderedPage = await render(env);
33+
await fsWriteFile(pageMdPath, renderedPage, { encoding: 'utf8' });
34+
}
4535

4636
const commands = await getCommandList(env);
4737
const commandPromises = commands.map(async cmd => {

‎packages/@ionic/cli-scripts/src/docs/pages/commands.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default async function(env: IonicEnvironment) {
1919

2020
return `${formatPageHeader('Commands', 'cli-command-list')}
2121
22-
This is a comprehensive list of CLI commands. The \`ionic --help\` command will show a more organized and accurate list of commands.
22+
This is a comprehensive list of CLI commands. Running \`ionic --help\` will also show a list of commands.
2323
2424
Command | Description
2525
------- | -----------

‎packages/@ionic/cli-scripts/src/docs/pages/configuring.ts‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ Configuration values are stored in JSON files.
1212
* Global config file (\`~/.ionic/config.json\`): for global CLI config and auth
1313
* Project config files (\`ionic.config.json\`): for Ionic project config
1414
15-
The CLI provides commands for setting and printing config values from project config files and the global CLI config file. See \`ionic config set --help\` and \`ionic config get --help\` for usage.
15+
The CLI provides the \`ionic config\` commands for setting and printing config values from project config files and the global CLI config file.
1616
1717
## Integrations
1818
19-
Integrations such as Cordova are automatically activated when detected, but can be easily disabled.
19+
You can manage integrations with the \`ionic integrations\` commands.
2020
21-
Integrations hook into CLI events. For example, when the Cordova integration is enabled, \`ionic cordova prepare\` will run after \`ionic build\` runs. See [Hooks](#hooks).
21+
Integrations may also be auto-activated, but can also be disabled easily. When integrations are enabled, the behavior of the CLI may change. For example, when the Cordova integration is enabled, \`ionic cordova prepare\` will run after \`ionic build\` runs.
2222
23-
| integration | enabled when... | disabled with... |
24-
| ------------|-------------------------------------------------------|----------------------------------------------------------|
25-
| Cordova | \`ionic cordova\` commands are run | \`ionic config set integrations.cordova.enabled false\` |
26-
| Gulp | \`gulp\` exists in your \`package.json\` dependencies | \`ionic config set integrations.gulp.enabled false\` |
23+
* \`cordova\`: Provides integration with [Apache Cordova](https://cordova.apache.org/) to target Native iOS and Android.
2724
2825
## Environment Variables
2926
@@ -34,6 +31,8 @@ The CLI will look for the following environment variables:
3431
* \`IONIC_TOKEN\`: For automatic login with an auth token.
3532
* \`IONIC_EMAIL\` / \`IONIC_PASSWORD\`: For automatic login with email & password.
3633
34+
\`IONIC_TOKEN\` and \`IONIC_EMAIL\` / \`IONIC_PASSWORD\` both initiate a session, which means they write your token to the global CLI config file. When the CLI detects a change in these environment variables, a new session is used.
35+
3736
### Command Options
3837
3938
You can express command options (normally set with \`--opt=value\` syntax) with environment variables. The naming of these environment variables follows a pattern: start with \`IONIC_CMDOPTS_\`, add the command name (replacing any spaces with underscores), add the option name (replacing any hyphens with underscores), and then uppercase everything. Boolean flags (command-line options that don't take a value) can be set to \`1\` or \`0\`. Strip the \`--no-\` prefix in boolean flags, if it exists (\`--no-open\` in \`ionic serve\` can be expressed with \`IONIC_CMDOPTS_SERVE_OPEN=0\`, for example).
@@ -57,6 +56,7 @@ CLI flags are global options that alter the behavior of a CLI command.
5756
* \`--verbose\`: Show all log messages for debugging purposes.
5857
* \`--quiet\`: Only show \`WARN\` and \`ERROR\` log messages.
5958
* \`--no-interactive\`: Turn off interactive prompts and fancy outputs. If a CI server is detected (we use [ci-info](https://www.npmjs.com/package/ci-info)), the CLI is automatically non-interactive.
59+
* \`--no-color\`: Turn off colors.
6060
* \`--confirm\`: Turn on auto-confirmation of confirmation prompts. *Careful*: the CLI prompts before doing something potentially harmful. Auto-confirming may have unintended results.
6161
6262
## Hooks
@@ -77,8 +77,6 @@ CLI hooks are how you can run scripts during CLI events, such as "watch" and "bu
7777
}
7878
\`\`\`
7979
80-
*Note: If you use [gulp](https://gulpjs.com/), the CLI will run gulp tasks by the same name as the npm scripts above.*
81-
8280
## Service Proxies
8381
8482
The CLI can add proxies to the HTTP server for "livereload" commands like \`ionic serve\` and \`ionic cordova run android -lc\`. These proxies are useful if you are developing in the browser and you need to make calls to an external API. With this feature you can proxy requests to the external API through the Ionic CLI, which prevents the \`No 'Access-Control-Allow-Origin' header is present on the requested resource\` error.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { generate as generateTree } from 'ascii-tree';
2+
3+
import { formatPageHeader } from '../utils';
4+
5+
export default async function() {
6+
return `${formatPageHeader('Project Types', 'cli-projects')}
7+
8+
{% include fluid/toc.html %}
9+
10+
The Ionic CLI works with a variety of Ionic project types. The type of a project is stored in the project's \`ionic.config.json\` file as \`type\`. Here is a list of project type values:
11+
12+
* \`ionic-angular\`: [Ionic Angular](#ionic-angular)
13+
* \`ionic1\`: [Ionic 1](#ionic-1)
14+
* \`custom\`: The CLI will not invoke anything for build or serve. See [Hooks](/docs/cli/configuring.html#hooks) to use \`ionic build\` and \`ionic serve\` with your own build process.
15+
16+
## Ionic Angular
17+
18+
Ionic Angular ([\`ionic-angular\`](https://www.npmjs.com/package/ionic-angular)) uses [Angular 5](https://angular.io/) and [\`@ionic/app-scripts\`](https://github.com/ionic-team/ionic-app-scripts) for tooling.
19+
20+
You can start a new Ionic Angular app with the following command:
21+
22+
\`\`\`bash
23+
$ ionic start --type=ionic-angular
24+
\`\`\`
25+
26+
See [Starter Templates](/docs/cli/starters.html#ionic-angular) for a list of starters for Ionic Angular.
27+
28+
Ionic Angular apps are written in [TypeScript](https://www.typescriptlang.org/) and [Sass](http://sass-lang.com/) and are compiled and built with [\`@ionic/app-scripts\`](https://github.com/ionic-team/ionic-app-scripts), which is a configurable build system optimized for Ionic Angular.
29+
30+
\`ionic build\` and \`ionic serve\` use \`@ionic/app-scripts\` out of the box, so it doesn't need to be invoked directly. It also ships with good defaults, but can be configured in a variety of ways. See [\`README.md\`](https://github.com/ionic-team/ionic-app-scripts/blob/master/README.md) for configuration details.
31+
32+
### Project Structure
33+
34+
\`\`\`
35+
${generateTree(`
36+
*project/
37+
**ionic.config.json # Ionic project config file
38+
**package.json
39+
**src/
40+
***app/
41+
****app.component.ts # root component for your app
42+
****app.html # app component template
43+
****app.module.ts # NgModule for app component
44+
****app.scss # global SCSS
45+
****main.ts # bootstrap file
46+
***assets/ # put your images, etc. here
47+
***pages/ # contains the page components for your app
48+
***theme/
49+
****variables.scss # see https://ionicframework.com/docs/theming
50+
***index.html # main html file
51+
**www/ # build output directory
52+
`.trim())}
53+
\`\`\`
54+
## Ionic 1
55+
56+
Ionic 1 ([\`ionic-v1\`](https://github.com/ionic-team/ionic-v1/)) uses [AngularJS](https://angularjs.org/).
57+
58+
You can start a new Ionic 1 app with the following command:
59+
60+
\`\`\`bash
61+
$ ionic start --type=ionic1
62+
\`\`\`
63+
64+
See [Starter Templates](/docs/cli/starters.html#ionic-1) for a list of starters for Ionic 1.
65+
66+
Out of the box, Ionic 1 apps have no build process. \`www/index.html\` includes the \`www/css/style.css\` file and the three provided JS files withing \`www/js/\`.
67+
68+
### Project Structure
69+
70+
\`\`\`
71+
${generateTree(`
72+
*project/
73+
**bower.json
74+
**gulpfile.js
75+
**ionic.config.json # Ionic project config file
76+
**package.json
77+
**scss/
78+
***ionic.app.scss # enable sass to use
79+
**www/
80+
***css/
81+
****style.css # vanilla CSS source file
82+
***js/
83+
****app.js # bootstrap file, contains \`.config()\`
84+
****controllers.js # https://docs.angularjs.org/guide/controller
85+
****services.js # https://docs.angularjs.org/guide/services
86+
***templates/ # AngularJS templates
87+
***index.html # main html file
88+
`.trim())}
89+
\`\`\`
90+
91+
### Enabling Sass
92+
93+
You can use [Sass](http://sass-lang.com/) by changing which CSS file \`www/index.html\` uses (\`css/style.css\` is the default, \`css/ionic.app.css\` is generated and includes both Ionic styles and your app's styles).
94+
95+
The main Sass source file is located at \`scss/ionic.app.scss\`.
96+
97+
If your \`gulpfile.js\` contains the \`sass\` task, the CLI will run it automatically during the \`ionic build\` and \`ionic serve\` commands.
98+
99+
`;
100+
}

‎packages/@ionic/cli-scripts/src/docs/pages/starters.ts‎

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
1-
import { StarterTemplate } from '@ionic/cli-utils';
1+
import { ProjectType, StarterTemplate } from '@ionic/cli-utils';
22
import { STARTER_TEMPLATES } from '@ionic/cli-utils/lib/start';
33

44
import { formatPageHeader } from '../utils';
55

66
interface Starter {
7-
type: string;
7+
type: ProjectType;
88
name: string;
9+
description: string;
910
starters: StarterTemplate[];
1011
}
1112

13+
const STARTERS: Starter[] = [
14+
// {
15+
// type: 'angular',
16+
// name: 'Ionic for Angular',
17+
// description: `
18+
// These starters are for Ionic for Angular (\`@ionic/angular\`), which uses the latest version of Angular and the [Angular CLI](https://github.com/angular/angular-cli) for tooling.
19+
// `.trim(),
20+
// starters: STARTER_TEMPLATES.filter(s => s.type === 'angular'),
21+
// },
22+
{
23+
type: 'ionic-angular',
24+
name: 'Ionic Angular',
25+
description: `
26+
These starters are for Ionic Angular (\`ionic-angular\`), which uses Angular 5 and [\`@ionic/app-scripts\`](https://github.com/ionic-team/ionic-app-scripts) for tooling.
27+
`.trim(),
28+
starters: STARTER_TEMPLATES.filter(s => s.type === 'ionic-angular'),
29+
},
30+
{
31+
type: 'ionic1',
32+
name: 'Ionic 1',
33+
description: `
34+
These starters are for [Ionic 1](https://github.com/ionic-team/ionic-v1) and [AngularJS](https://angularjs.org/).
35+
36+
For new apps, we recommend the latest version of [Ionic Angular](https://github.com/ionic-team/ionic).
37+
`.trim(),
38+
starters: STARTER_TEMPLATES.filter(s => s.type === 'ionic1'),
39+
},
40+
];
41+
1242
export default async function() {
1343
const formatStarter = (t: StarterTemplate) => {
1444
return `\`${t.name}\` | ${t.description}\n`;
@@ -18,25 +48,14 @@ export default async function() {
1848
return `
1949
### ${starterType.name}
2050
51+
${starterType.description}
52+
2153
Starter | Description
2254
--------|------------
2355
${starterType.starters.map(formatStarter).join('')}
2456
`;
2557
};
2658

27-
const starters: Starter[] = [
28-
{
29-
type: 'ionic-angular',
30-
name: 'Ionic Angular',
31-
starters: STARTER_TEMPLATES.filter(s => s.type === 'ionic-angular'),
32-
},
33-
{
34-
type: 'ionic1',
35-
name: 'Ionic 1',
36-
starters: STARTER_TEMPLATES.filter(s => s.type === 'ionic1'),
37-
},
38-
];
39-
4059
return `${formatPageHeader('Starter Templates', 'cli-starter-list')}
4160
4261
{% include fluid/toc.html %}
@@ -45,7 +64,7 @@ This is list of official Ionic starter templates, which are ready-to-go starter
4564
4665
## Starter Types
4766
48-
${starters.map(formatStartersTable).join('')}
67+
${STARTERS.map(formatStartersTable).join('')}
4968
5069
## How it Works
5170

‎packages/@ionic/cli-scripts/tsconfig.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"outDir": "./dist"
55
},
66
"include": [
7+
"../../../types/ascii-tree.d.ts",
78
"../../../types/cross-spawn.d.ts",
89
"../../../types/superagent.d.ts",
910
"src/**/*.ts"

‎types/ascii-tree.d.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module 'ascii-tree' {
2+
namespace asciitree {
3+
function generate(input: string): string;
4+
}
5+
export = asciitree;
6+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL