Skip to content

Commit

Permalink
fix(cli): add icon code output for ios icons
Browse files Browse the repository at this point in the history
CLI doesn't print out meta tags required for iOS icons, neither saves to index.html. This change
fixes that issue.

fix #26
  • Loading branch information
onderceylan committed Aug 29, 2019
1 parent 183ef33 commit c768fb6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ All other commit types will trigger no new release.

## Testing

The project uses [jest](https://jestjs.io) for unit and integration testing. You can utilize jest's handy [snapshot testing](https://jestjs.io/docs/en/snapshot-testing) feature while testing feature integration specifically, please see [cli.test.js](https://github.com/onderceylan/pwa-asset-generator/blob/master/cli.test.js) file and [snapshots](https://github.com/onderceylan/pwa-asset-generator/tree/master/__snapshots__) folder for examples. Please apply code changes alongside with unit tests.
The project uses [jest](https://jestjs.io) for unit and integration testing. You can utilize jest's handy [snapshot testing](https://jestjs.io/docs/en/snapshot-testing) feature while testing feature integration specifically, please see [cli.test.js](https://github.com/onderceylan/pwa-asset-generator/blob/master/cli.test.js) file and [snapshots](https://github.com/onderceylan/pwa-asset-generator/tree/master/__snapshots__) folder for examples. You can update the snapshots with `npm run jest:update` command when needed.

Tests run with `npm test` command.
Please apply any of your code changes alongside with unit tests. Tests run with `npm run jest` command.

## Continuous integration

Expand Down
8 changes: 8 additions & 0 deletions __snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ exports[`generates icons only 1`] = `
\\"type\\": \\"image/png\\"
}
]
<link rel=\\"apple-touch-icon\\" sizes=\\"180x180\\" href=\\"temp/apple-icon-180.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"167x167\\" href=\\"temp/apple-icon-167.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"152x152\\" href=\\"temp/apple-icon-152.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"120x120\\" href=\\"temp/apple-icon-120.png\\">
<meta name=\\"apple-mobile-web-app-capable\\" content=\\"yes\\">
"
`;
Expand Down
28 changes: 13 additions & 15 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,19 @@ if (!output) {
}
}

if (!options.iconOnly) {
if (options.index) {
await pwa.addMetaTagsToIndexPage(htmlContent, options.index);
logger.success(
`Splash screen meta tags are saved to index html file ${options.index}`,
);
} else {
logger.warn(
'Index html file is not specified, printing out the content to console instead',
);
logger.success(
'Below is the splash screen content for your index.html file. You can copy/paste it manually',
);
process.stdout.write(`\n${htmlContent}\n`);
}
if (options.index) {
await pwa.addMetaTagsToIndexPage(htmlContent, options.index);
logger.success(
`iOS meta tags are saved to index html file ${options.index}`,
);
} else {
logger.warn(
'Index html file is not specified, printing out the content to console instead',
);
logger.success(
'Below is the iOS meta tags content for your index.html file. You can copy/paste it manually',
);
process.stdout.write(`\n${htmlContent}\n`);
}
} catch (e) {
logger.error(e);
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
},
"scripts": {
"test": "npm run lint && jest",
"jest": "jest",
"jest:update": "jest -u",
"commit": "git-cz",
"lint": "eslint \"**/**.js\"",
"lint:fix": "npm run lint -- --fix",
Expand Down
4 changes: 2 additions & 2 deletions puppets.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ const getSplashScreenMetaData = async options => {
splashScreenData,
scaleFactorData,
);
logger.success('Loaded splash screen metadata');
logger.success('Loaded metadata for iOS platform');
} catch (e) {
splashScreenUniformMetaData =
constants.APPLE_HIG_SPLASH_SCREEN_FALLBACK_DATA;
logger.warn(
`Failed to fetch latest specs from Apple Human Interface Guidelines. Using static fallback data from v${packageJson.version}`,
`Failed to fetch latest specs from Apple Human Interface guidelines. Using static fallback data from v${packageJson.version}`,
);
} finally {
browser.close();
Expand Down

0 comments on commit c768fb6

Please sign in to comment.