| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,7 @@ | |||
| 14 | 14 | "@ionic/cli-framework": "0.1.2", | |
| 15 | 15 | "@ionic/cli-utils": "1.19.0", | |
| 16 | 16 | "ansi-styles": "^3.2.0", | |
| 17 | + "ascii-tree": "^0.3.0", | ||
| 17 | 18 | "escape-string-regexp": "^1.0.5", | |
| 18 | 19 | "ionic": "3.19.0", | |
| 19 | 20 | "strip-ansi": "^4.0.0", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,14 +2,9 @@ import * as path from 'path'; | |||
| 2 | 2 | ||
| 3 | 3 | import { generateRootPlugin } from 'ionic'; | |
| 4 | 4 | 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'; | ||
| 7 | 6 | import { generateIonicEnvironment } from '@ionic/cli-utils'; | |
| 8 | 7 | ||
| 9 | - import formatIndexPage from './pages/index'; | ||
| 10 | - import formatConfiguringPage from './pages/configuring'; | ||
| 11 | - import formatCommandsPage from './pages/commands'; | ||
| 12 | - import formatStartersPage from './pages/starters'; | ||
| 13 | 8 | import { formatCommandDoc, generateFullName, getCommandList } from './pages/commands'; | |
| 14 | 9 | ||
| 15 | 10 | export class DocsCommand extends Command { | |
@@ -24,24 +19,19 @@ export class DocsCommand extends Command { | |||
| 24 | 19 | const plugin = await generateRootPlugin(); | |
| 25 | 20 | const env = await generateIonicEnvironment(plugin, process.argv.slice(2), process.env); | |
| 26 | 21 | ||
| 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 | ||
| 35 | 25 | ||
| 36 | - const startersPath = path.resolve(__dirname, '..', '..', '..', '..', '..', 'docs', 'starters.md'); | ||
| 37 | - const startersDoc = await formatStartersPage(); | ||
| 26 | + await fsMkdirp(mdPath); | ||
| 38 | 27 | ||
| 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 | + } | ||
| 45 | 35 | ||
| 46 | 36 | const commands = await getCommandList(env); | |
| 47 | 37 | const commandPromises = commands.map(async cmd => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ export default async function(env: IonicEnvironment) { | |||
| 19 | 19 | ||
| 20 | 20 | return `${formatPageHeader('Commands', 'cli-command-list')} | |
| 21 | 21 | ||
| 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. | ||
| 23 | 23 | ||
| 24 | 24 | Command | Description | |
| 25 | 25 | ------- | ----------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,18 +12,15 @@ Configuration values are stored in JSON files. | |||
| 12 | 12 | * Global config file (\`~/.ionic/config.json\`): for global CLI config and auth | |
| 13 | 13 | * Project config files (\`ionic.config.json\`): for Ionic project config | |
| 14 | 14 | ||
| 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. | ||
| 16 | 16 | ||
| 17 | 17 | ## Integrations | |
| 18 | 18 | ||
| 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. | ||
| 20 | 20 | ||
| 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. | ||
| 22 | 22 | ||
| 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. | ||
| 27 | 24 | ||
| 28 | 25 | ## Environment Variables | |
| 29 | 26 | ||
@@ -34,6 +31,8 @@ The CLI will look for the following environment variables: | |||
| 34 | 31 | * \`IONIC_TOKEN\`: For automatic login with an auth token. | |
| 35 | 32 | * \`IONIC_EMAIL\` / \`IONIC_PASSWORD\`: For automatic login with email & password. | |
| 36 | 33 | ||
| 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 | + | ||
| 37 | 36 | ### Command Options | |
| 38 | 37 | ||
| 39 | 38 | 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. | |||
| 57 | 56 | * \`--verbose\`: Show all log messages for debugging purposes. | |
| 58 | 57 | * \`--quiet\`: Only show \`WARN\` and \`ERROR\` log messages. | |
| 59 | 58 | * \`--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. | ||
| 60 | 60 | * \`--confirm\`: Turn on auto-confirmation of confirmation prompts. *Careful*: the CLI prompts before doing something potentially harmful. Auto-confirming may have unintended results. | |
| 61 | 61 | ||
| 62 | 62 | ## Hooks | |
@@ -77,8 +77,6 @@ CLI hooks are how you can run scripts during CLI events, such as "watch" and "bu | |||
| 77 | 77 | } | |
| 78 | 78 | \`\`\` | |
| 79 | 79 | ||
| 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 | - | ||
| 82 | 80 | ## Service Proxies | |
| 83 | 81 | ||
| 84 | 82 | 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. | |
| Original file line number | Diff line number | Diff 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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,44 @@ | |||
| 1 | - import { StarterTemplate } from '@ionic/cli-utils'; | ||
| 1 | + import { ProjectType, StarterTemplate } from '@ionic/cli-utils'; | ||
| 2 | 2 | import { STARTER_TEMPLATES } from '@ionic/cli-utils/lib/start'; | |
| 3 | 3 | ||
| 4 | 4 | import { formatPageHeader } from '../utils'; | |
| 5 | 5 | ||
| 6 | 6 | interface Starter { | |
| 7 | - type: string; | ||
| 7 | + type: ProjectType; | ||
| 8 | 8 | name: string; | |
| 9 | + description: string; | ||
| 9 | 10 | starters: StarterTemplate[]; | |
| 10 | 11 | } | |
| 11 | 12 | ||
| 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 | + | ||
| 12 | 42 | export default async function() { | |
| 13 | 43 | const formatStarter = (t: StarterTemplate) => { | |
| 14 | 44 | return `\`${t.name}\` | ${t.description}\n`; | |
@@ -18,25 +48,14 @@ export default async function() { | |||
| 18 | 48 | return ` | |
| 19 | 49 | ### ${starterType.name} | |
| 20 | 50 | ||
| 51 | + ${starterType.description} | ||
| 52 | + | ||
| 21 | 53 | Starter | Description | |
| 22 | 54 | --------|------------ | |
| 23 | 55 | ${starterType.starters.map(formatStarter).join('')} | |
| 24 | 56 | `; | |
| 25 | 57 | }; | |
| 26 | 58 | ||
| 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 | - | ||
| 40 | 59 | return `${formatPageHeader('Starter Templates', 'cli-starter-list')} | |
| 41 | 60 | ||
| 42 | 61 | {% include fluid/toc.html %} | |
@@ -45,7 +64,7 @@ This is list of official Ionic starter templates, which are ready-to-go starter | |||
| 45 | 64 | ||
| 46 | 65 | ## Starter Types | |
| 47 | 66 | ||
| 48 | - ${starters.map(formatStartersTable).join('')} | ||
| 67 | + ${STARTERS.map(formatStartersTable).join('')} | ||
| 49 | 68 | ||
| 50 | 69 | ## How it Works | |
| 51 | 70 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | "outDir": "./dist" | |
| 5 | 5 | }, | |
| 6 | 6 | "include": [ | |
| 7 | + "../../../types/ascii-tree.d.ts", | ||
| 7 | 8 | "../../../types/cross-spawn.d.ts", | |
| 8 | 9 | "../../../types/superagent.d.ts", | |
| 9 | 10 | "src/**/*.ts" | |
| Original file line number | Diff line number | Diff 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments