Skip to content

Commit aa57563

Browse files
committed
deprecate credentials file
1 parent daf5ce2 commit aa57563

File tree

7 files changed

+19
-15
lines changed

7 files changed

+19
-15
lines changed

packages/content/docs/contentful-source.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Also supports all fields of the Contentful SDK's config.
99
See: 'Configuration' under https://contentful.github.io/contentful.js/contentful/9.1.7/
1010
| Property | Type | Default | Description |
1111
| - | - | - | - |
12-
| <a name="module_contentful-source.ContentfulOptions+space">`space`</a> | <code>string</code>| <code>''</code> | Your Contentful space ID. Note that credentials.json will require an accessToken in addition to this |
12+
| <a name="module_contentful-source.ContentfulOptions+space">`space`</a> | <code>string</code>| <code>''</code> | Your Contentful space ID. Note that an accessToken will be required in addition to this |
1313
| <a name="module_contentful-source.ContentfulOptions+locale">`locale`</a> | <code>string</code>| <code>'en-US'</code> | Optional. Used to pull localized images. |
1414
| <a name="module_contentful-source.ContentfulOptions+filename">`filename`</a> | <code>string</code>| <code>'content.json'</code> | Optional. The filename you want to use for where all content (entries and assets metadata) will be stored. |
1515
| <a name="module_contentful-source.ContentfulOptions+contentTypes">`contentTypes`</a> | <code>Array.&lt;string&gt;</code>| | Optionally limit queries to these content types.<br>This will also apply to linked assets.<br>Types that link to other types will include up to 10 levels of child content.<br>E.g. filtering by Story, might also include Chapters and Images.<br>Uses `searchParams['sys.contentType.sys.id[in]']` under the hood. |

packages/content/docs/strapi-source.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ Options for StrapiSource
1313
| <a name="module_strapi-source.StrapiOptions+limit">`limit`</a> | <code>number</code>| <code>100</code> | Max number of entries per page. |
1414
| <a name="module_strapi-source.StrapiOptions+maxNumPages">`maxNumPages`</a> | <code>number</code>| <code>-1</code> | Max number of pages. Use the default of `-1` for all pages |
1515
| <a name="module_strapi-source.StrapiOptions+pageNumZeroPad">`pageNumZeroPad`</a> | <code>number</code>| <code>0</code> | How many zeros to pad each json filename index with. |
16-
| <a name="module_strapi-source.StrapiOptions+identifier">`identifier`</a> | <code>string</code>| | Username or email. Should be configured via `./credentials.json` |
17-
| <a name="module_strapi-source.StrapiOptions+password">`password`</a> | <code>string</code>| | Should be configured via `./credentials.json` |
16+
| <a name="module_strapi-source.StrapiOptions+identifier">`identifier`</a> | <code>string</code>| | Username or email. Should be configured via `./.env.local` |
17+
| <a name="module_strapi-source.StrapiOptions+password">`password`</a> | <code>string</code>| | Should be configured via `./.env.local` |
1818
| <a name="module_strapi-source.StrapiOptions+token">`token`</a> | <code>string</code>| | Can be used instead of identifer/password if you previously generated one. Otherwise this will be automatically generated using the identifier or password. |

packages/content/lib/content-options.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const TIMESTAMP_TOKEN = '%TIMESTAMP%';
2121
* @property {Array<Object<string, number>>} [imageTransforms] A list of image transforms to apply to a copy of each downloaded image.
2222
* @property {Object<string, string>} [contentTransforms] A list of content transforms to apply to all donwloaded content.
2323
* @property {string} [downloadPath] The path at which to store all downloaded files. Defaults to '.downloads/'.
24-
* @property {string} [credentialsPath] The path to the json containing credentials for all content sources. Defaults to '.credentials.json'.
24+
* @property {string} [credentialsPath] The path to the json containing credentials for all content sources. Defaults to '.credentials.json'. Deprecated in favor of `.env`/`.env.local`.
2525
* @property {string} [tempPath] Temp file directory path. Defaults to '%DOWNLOAD_PATH%/.tmp/'.
2626
* @property {string} [backupPath] Temp directory path where all downloaded content will be backed up before removal. Defaults to '%TIMESTAMP%/.tmp-backup/'.
2727
* @property {string} [keep] Which files to keep in `dest` if `clearOldFilesOnSuccess` or `clearOldFilesOnStart` are `true`. E.g. `'*.json|*.csv|*.xml|*.git*'`
@@ -41,14 +41,13 @@ export const TIMESTAMP_TOKEN = '%TIMESTAMP%';
4141
*/
4242

4343
/**
44-
* @type {Required<ContentOptions>}
44+
* @satisfies {ContentOptions}
4545
*/
4646
export const CONTENT_OPTION_DEFAULTS = {
4747
sources: [],
4848
imageTransforms: [],
4949
contentTransforms: {},
5050
downloadPath: '.downloads/',
51-
credentialsPath: '.credentials.json',
5251
tempPath: '%DOWNLOAD_PATH%/.tmp/',
5352
backupPath: '%TIMESTAMP%/.tmp-backup/',
5453
keep: '',

packages/content/lib/content-sources/contentful-source.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { Logger } from '@bluecadet/launchpad-utils';
3030

3131
/**
3232
* @typedef BaseContentfulOptions
33-
* @property {string} space Your Contentful space ID. Note that credentials.json will require an accessToken in addition to this
33+
* @property {string} space Your Contentful space ID. Note that an accessToken is required in addition to this
3434
* @property {string} [locale] Optional. Used to pull localized images.
3535
* @property {string} [filename] Optional. The filename you want to use for where all content (entries and assets metadata) will be stored. Defaults to 'content.json'
3636
* @property {string} [protocol] Optional. Defaults to 'https'

packages/content/lib/content-sources/strapi-source.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import { Logger } from '@bluecadet/launchpad-utils';
2626

2727
/**
2828
* @typedef StrapiLoginCredentials
29-
* @property {string} identifier Username or email. Should be configured via `./credentials.json`
30-
* @property {string} password Should be configured via `./credentials.json`
29+
* @property {string} identifier Username or email. Should be configured via `./.env.local`
30+
* @property {string} password Should be configured via `./.env.local`
3131
*
3232
* @typedef StrapiTokenCredentials
3333
* @property {string} token Can be used instead of identifer/password if you previously generated one. Otherwise this will be automatically generated using the identifier or password.

packages/content/lib/credentials.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@ class Credentials {
1212
static logger = console;
1313

1414
/**
15-
* @param {string} credentialsPath
15+
* @param {string} [credentialsPath]
1616
* @param {Logger | Console} logger
1717
*/
1818
static init(credentialsPath, logger = console) {
1919
this.logger = logger;
20+
21+
if (!credentialsPath) {
22+
return;
23+
}
24+
25+
this.logger.warn(`${chalk.white('credentialsPath')} option is deprecated. Please use ${chalk.white('.env')}/${chalk.white('.env.local')} instead.`);
26+
2027
try {
21-
if (credentialsPath && fsx.existsSync(credentialsPath)) {
28+
if (fsx.existsSync(credentialsPath)) {
2229
this.logger.info(chalk.gray(`Loading credentials from '${chalk.white(credentialsPath)}'`));
2330
const rawdata = fsx.readFileSync(credentialsPath);
2431
creds = JSON.parse(rawdata.toString());
25-
} else if (credentialsPath) {
26-
this.logger.warn(`No credentials file found at '${credentialsPath}'`);
2732
} else {
28-
this.logger.warn(chalk.yellow('No credentials path specified'));
33+
this.logger.warn(`No credentials file found at '${credentialsPath}'`);
2934
}
3035
} catch (err) {
3136
if (err instanceof Error) {

packages/content/lib/launchpad-content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class LaunchpadContent {
6060
}
6161
}
6262

63-
/** @type {Required<import('./content-options.js').ResolvedContentOptions>} */
63+
/** @type {import('./content-options.js').ResolvedContentOptions} */
6464
_config;
6565

6666
/** @type {Logger} */

0 commit comments

Comments
 (0)