This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
forked from mmintel/datocms-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add cleanup option for import models and menus Examines the existing fields and items types compared to the ones being imported. If its isn't being imported then it is assumed it should be deleted. * Update README with new cleanup option * Update README import models param from 'data' to 'models * Remove check for "itemType" given "id" field is enough * More defensive check for itemType before looking up menuItem This is unlikely to happen but did occur during testing and the error stated "TypeError: Cannot read property 'id' of undefined". * Fix mapping to parent menu item by processing parents first * More logging and reduced api calls if content didn't change * Revert reduction in api calls, ensure always called We might want to intentionally set to null for instance * Support "environment" option when importing/exporting * Optimise import models by identifying when items are unchanged * fix: support fieldsets and skip preview fields * feat: add release github action Co-authored-by: David Pike <david.pike@inlight.com.au>
- Loading branch information
1 parent
73f11f3
commit e43a3cf
Showing
12 changed files
with
249 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# From: https://github.com/semantic-release/semantic-release/blob/1405b94296059c0c6878fb8b626e2c5da9317632/docs/recipes/github-actions.md | ||
|
||
name: Release | ||
on: | ||
push: | ||
branches: [master] | ||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Run build | ||
run: npm run build | ||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.INLIGHT_WRITE_PACKAGES_GITHUB_TOKEN }} | ||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' | ||
run: npx semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
hooks: { | ||
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS', | ||
'pre-commit': 'npm run lint && npm run test', | ||
'pre-commit': 'npm run lint', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { SiteClient } from 'datocms-client'; | ||
|
||
export default async function ({ apiKey }) { | ||
export default async function ({ apiKey, environment }) { | ||
if (!apiKey) { | ||
throw new Error('Must pass apiKey.'); | ||
} | ||
const client = new SiteClient(apiKey); | ||
const client = new SiteClient(apiKey, { environment }); | ||
const items = await client.items.all({}, { allPages: true }); | ||
return items; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { SiteClient } from 'datocms-client'; | ||
|
||
export default async function ({ apiKey }) { | ||
const client = new SiteClient(apiKey); | ||
export default async function ({ apiKey, environment }) { | ||
const client = new SiteClient(apiKey, { environment }); | ||
return client.menuItems.all(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { SiteClient } from 'datocms-client'; | ||
import { chain } from 'lodash'; | ||
|
||
export default async function ({ apiKey }) { | ||
export default async function ({ apiKey, environment }) { | ||
if (!apiKey) { | ||
throw new Error('Must pass apiKey.'); | ||
} | ||
const client = new SiteClient(apiKey); | ||
const client = new SiteClient(apiKey, { environment }); | ||
const itemTypes = await client.itemTypes.all(); | ||
const fields = await Promise.all(itemTypes.map(async (itemType) => client.fields.all(itemType.id))); | ||
const fieldsets = await Promise.all(itemTypes.map(async (itemType) => client.fieldsets.all(itemType.id))); | ||
return { | ||
itemTypes, | ||
fields: chain(fields).flatten().sortBy('position').value(), | ||
fieldsets: chain(fieldsets).flatten().sortBy('position').value(), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.