GithubHelp home page GithubHelp logo

directus-labs / directus-template-cli Goto Github PK

View Code? Open in Web Editor NEW
64.0 64.0 12.0 19.44 MB

Apply "templates" to a new, empty Directus project.

License: MIT License

JavaScript 1.35% Batchfile 0.11% TypeScript 98.54%

directus-template-cli's People

Contributors

alexvdvalk avatar bryantgillespie avatar joggienl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

directus-template-cli's Issues

Error updating block_gallery_files

When applying the Agency OS template, I am receiving the following error:

Error updating block_gallery_files [
  {
    message: 'Invalid foreign key for field "directus_files_id" in collection "block_gallery_files".',
    extensions: {
      code: 'INVALID_FOREIGN_KEY',
      collection: 'block_gallery_files',
      field: 'directus_files_id'
    }
  }
]

The CLI then finishes, but when I try to then load the Nuxt site's homepage, I get the following

 {
  "url": "/",
  "statusCode": 500,
  "statusMessage": "",
  "message": "Cannot read properties of null (reading 'id')",
  "stack": "<pre><span class=\"stack\">at ./components/base/VGallery.vue:101:17</span>\n<span class=\"stack internal\">at Module.ssrRenderList (./node_modules/.pnpm/@[email protected][email protected]/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:433:7)</span>\n<span class=\"stack\">at _sfc_ssrRender (./components/base/VGallery.vue:96:26)</span>\n<span class=\"stack internal\">at renderComponentSubTree (./node_modules/.pnpm/@[email protected][email protected]/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:683:9)</span>\n<span class=\"stack internal\">at renderComponentVNode (./node_modules/.pnpm/@[email protected][email protected]/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:631:12)</span>\n<span class=\"stack internal\">at Module.ssrRenderComponent (./node_modules/.pnpm/@[email protected][email protected]/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:86:10)</span>\n<span class=\"stack\">at ./components/blocks/Gallery.vue:75:40</span>\n<span class=\"stack internal\">at renderFnWithContext (./node_modules/.pnpm/@[email protected]/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:762:13)</span>\n<span class=\"stack internal\">at ssrRenderSlotInner (./node_modules/.pnpm/@[email protected][email protected]/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:113:17)</span>\n<span class=\"stack internal\">at Module.ssrRenderSlot (./node_modules/.pnpm/@[email protected][email protected]/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:95:3)</span></pre>"
}

Getting Warning: Invalid token despite correct token given when attempting to extract a template from a directus docker installation

I'm getting a "Warning: Invalid token" when attempting to extract a template from a Directus docker installation on a local environment. I've verified that the static access token I've provided is correct using Postman.

The Directus instance I have set up is accessible on my local machine at http://localhost:7055/. I'm running the Template CLI using the Docker Desktop Exec interface. This is a preview of the inputs I gave:

What is your Directus URL?: localhost:7055
What is your Directus Admin Token?: <directus admin static access token here>
 ›   Warning: Invalid token

Error: Cannot find module

Hi Dev's,

I am using local Directus instance. Directus is working fine on start but while implementing AgencyOS with "npx directus-template-cli@latest apply" I am getting error.

Error: Cannot find module 'C:\Users\Admin\AppData\Local\npm-cache_npx\623fa71c079d6ec8\node_modules\braces\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:444:19)
at Module._findPath (node:internal/modules/cjs/loader:715:18)
at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object. (C:\Users\Admin\AppData\Local\npm-cache_npx\623fa71c079d6ec8\node_modules@oclif\core\node_modules\micromatch\index.js:4:16)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32) {
code: 'MODULE_NOT_FOUND',
path: 'C:\Users\Admin\AppData\Local\npm-cache\_npx\623fa71c079d6ec8\node_modules\braces\package.json',
requestPath: 'braces'
}

I google it but didn't get any solution, Let me know if anyone knows the solution.

TypeError: Cannot read properties of undefined (reading 'status')

Issue: "TypeError" When Applying Official Template via directus-template-cli

Description

When attempting to apply an official template using directus-template-cli, the process fails with a TypeError. This error occurs regardless of the version used (tested with 0.4.0, 0.4.1, 0.3.6, and '@latest'). The expected behavior is for the template application process to complete successfully without errors.

Error encountered:

Loading 46 files... !
TypeError: Cannot read properties of undefined (reading 'status')

Steps to Reproduce

  1. Run the command npx [email protected] apply.
  2. Choose "Official templates" when prompted for the template type.
  3. Select the "Headless CMS - Website" template.
  4. Observe the TypeError.

Expected Behavior

The template application process should be completed successfully, allowing the "Headless CMS - Website" template to be applied to the Directus project.

Actual Behavior

The process fails with a TypeError related to an undefined property 'status', preventing the successful application of the template.

Possible Solution

N/A

Additional Context

  • The issue persists across multiple versions of directus-template-cli, including 0.4.0, 0.4.1, 0.3.6, and '@latest'.
  • The error specifically mentions a problem with reading 'status', which might indicate an issue with handling response objects from a network request or similar operation.

Frequency

The issue occurs consistently when following the steps to reproduce with the mentioned versions of directus-template-cli.

Error: Cannot find module 'node:url' On Ubuntu

Hi guys I try to follow the guides to install the cli but something is wrong.

If run this:
npx directus-template-cli@latest apply

This is the log
`root@jose-System:~# sudo npx directus-template-cli@latest apply
Need to install the following packages:
directus-template-cli@latest
Ok to proceed? (y) y
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=18.0.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@directus/[email protected]',
npm WARN EBADENGINE required: { node: '>=18.0.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@oclif/[email protected]',
npm WARN EBADENGINE required: { node: '>=18.0.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@oclif/[email protected]',
npm WARN EBADENGINE required: { node: '>=18.0.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@oclif/[email protected]',
npm WARN EBADENGINE required: { node: '>=18.0.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>= 18' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=16' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=16 || 14 >=14.17' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '^14.18.0 || >=16.10.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '^14.16.0 || >=16.10.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=16.17' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=16' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=16.17.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
internal/modules/cjs/loader.js:818
throw err;
^

Error: Cannot find module 'node:url'
Require stack:

  • /root/.npm/_npx/623fa71c079d6ec8/node_modules/@oclif/core/lib/args.js
  • /root/.npm/_npx/623fa71c079d6ec8/node_modules/@oclif/core/lib/index.js
  • /root/.npm/_npx/623fa71c079d6ec8/node_modules/directus-template-cli/bin/run
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/root/.npm/_npx/623fa71c079d6ec8/node_modules/@oclif/core/lib/args.js:4:20)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/root/.npm/_npx/623fa71c079d6ec8/node_modules/@oclif/core/lib/args.js',
    '/root/.npm/_npx/623fa71c079d6ec8/node_modules/@oclif/core/lib/index.js',
    '/root/.npm/_npx/623fa71c079d6ec8/node_modules/directus-template-cli/bin/run'
    ]
    }
    `
    I'm running it under root user.

TypeError when extracting template

Hi,

Im getiing an error when extracting a template form our staging project:

Logged in as Admin User
------------------
Extracted schema snapshot
Extracted collections
Extracted fields
Extracted relations
Extracted folders
Extracted files
Extracted users
Extracted roles
Extracted permissions
Extracted presets
Extracted translations
Extracted flows
Extracted operations
Extracted dashboards
Extracted panels
Extracted settings
Extracted items from collection: config_endpoints
Extracted items from collection: config_endpoints_directus_roles
Extracted items from collection: config_endpoints_directus_users
Extracted items from collection: parking_areas
Extracted items from collection: parking_blocks
Extracted items from collection: parking_destinations
Extracted items from collection: parking_logs
Extracted items from collection: parking_spots
Extracted items from collection: reservations
Extracted items from collection: rides_files_damage
Extracted items from collection: rides_files_mileage
Extracted items from collection: ride_gps_logs
Extracted items from collection: shifts
Extracted items from collection: rides
 ›   Warning: Error downloading null
Extracting template - from [STAGING_URL] to [LOCAL_FOLDER]... !
    TypeError: first argument must be a string or instance of Error

I followed the readme, running the tool locally with:

npx directus-template-cli@latest extract

Please let me know if more info is needed

Issues when the PK isn't "id"

For languages collection for example, PK is "code", well the content loader doesn't load any language provided, therefore the entirety of the app content isn't loaded because translations can't find related language entry.

In Docker, cli installs anew each time when executing the npx command in the Docker shell

I try to use the directus template cli on a locally installed Docker instance (URL: http://localhist:8066/). As far as I know, in order to install the tempalte cli, I first have to switch to Docker's internal shell like this:

docker exec -it directus-agency-tmpl-be-directus-1 sh

Then I can execute

npx directus-template-cli apply

which first downloads the cli and then starts the prompts.

Two problems happen:

  1. Whenever I re-enter the Docker shell (docker exec -it ...) and run npx directus-template-cli appy, the cli is installed again. This happens every time when re-entering the shell and executing the npx command. I would expect that the project remembers that the cli was already downloaded. Why is this not the case?
  2. The prompt asking for the admin token tells me that the token is wrong. I change the token, add the new one, and again I am told that the token is wrong.

The whole process in the Docker shell:

Screenshot 2023-09-20 at 16 14 41

Create new admin token

02-create-new-token

Apply new admin token

03-add-new-token

Difference Schema <-> Collection

I am currently trying my hands on creating a more granular fetching and applying of data.
So far so good, it seems to be working as expected. There are some aspects that def. need to be done together ( i.E. flows&operation or permissions&roles.)

My question comes at the role of Schema and Collection. To me it seems like they should do the same thing. Update the Collection-Schema.
LoadData seems to some more (in regard to other collections too.) but then why also handle collections when they should be handled by the schema?

Add better error logs

Should added some better error logging for third party use cases where extensive testing is not done. IE users extracting and applying their own templates that could potentially have different schemas, primary keys, etc.

Like #46 for instance.

Getting: "You don't have permission to access this" when applying the directus export

Hello Bryant,

Have created a Directus instance on my local machine via Docker and customized it to my needs. Already added more than 100 records. Was very interested in your cli solution since I can import the assets and content together with the schema onto another Directus instance.

I've tried to apply the extracted data via the following command: npx directus-template-cli@latest apply onto my server which support Docker too, using the cli, sh, from Portainer GUI. However, I'm getting the following errors:

{
    message: "You don't have permission to access this.",
    extensions: { code: 'FORBIDDEN' }
}

Getting the same error on all my collections.

Can you please advise...

Thanks in advance,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.