Skip to content

Commit f3bffaf

Browse files
Merge pull request #1387 from contentful/fix/upload-assets-default
fix(upload-assets param): remove the "default: false" Providing a default param (of any type/kind) results in that param existing (aka being set), which triggers the implies("upload-assets", "assets-directory") check, which obviously fails when neither param is passed by user. Also fix a 2nd bug in the CLI, where params were not getting passed when executing the CLI executable. dx-48
2 parents 0293d42 + aa79772 commit f3bffaf

File tree

7 files changed

+639
-5
lines changed

7 files changed

+639
-5
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This library helps you to import files generated by [contentful-export](https://
2727
npm install contentful-import
2828
```
2929

30-
## :hand: Usage
30+
## :hand: Usage as a module
3131

3232
```javascript
3333
const contentfulImport = require('contentful-import')
@@ -51,7 +51,7 @@ contentfulImport(options)
5151
Using ESM:
5252

5353
```javascript
54-
import spaceImport from 'contentful-import';
54+
import spaceImport from "contentful-import";
5555
```
5656

5757
or
@@ -75,6 +75,23 @@ contentfulImport(options)
7575
})
7676
```
7777

78+
## 💾 Usage as a CLI executable
79+
80+
1. Build the package:
81+
82+
```bash
83+
$ npm run build
84+
```
85+
86+
2. Execute the CLI tool by running the binary and passing the required parameters
87+
88+
```bash
89+
$ ./bin/contentful-cli \
90+
--space-id <space-id> \
91+
--management-token <management-token> \
92+
--content-file <content-file>
93+
```
94+
7895
#### Import an environment
7996

8097
```javascript

bin/contentful-import

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
const runContentfulImport = require('../dist/index')
3-
const usageParams = require('../dist/usageParams')
3+
const usageParams = require('../dist/usageParams').default
44
console.log('We moved the CLI version of this tool into our Contentful CLI.\nThis allows our users to use and install only one single CLI tool to get the full Contentful experience.\nFor more info please visit https://github.com/contentful/contentful-cli/tree/master/docs/space/import')
55
runContentfulImport(usageParams)
66
.then(() => {

lib/usageParams.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export default yargs
4848
.option('upload-assets', {
4949
describe: 'Uses local asset files and uploads them instead of pointing to the URLs of previously uploaded assets. Requires assets-directory',
5050
type: 'boolean',
51-
default: false
5251
})
5352
.implies('upload-assets', 'assets-directory')
5453
.option('assets-directory', {

package-lock.json

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
"semantic-release": "^24.2.3",
9494
"ts-jest": "^29.3.2",
9595
"tsup": "^8.4.0",
96-
"typescript": "^5.8.3"
96+
"typescript": "^5.8.3",
97+
"nixt": "^0.5.1"
9798
},
9899
"files": [
99100
"bin",

0 commit comments

Comments
 (0)