Skip to content

Commit

Permalink
Merge pull request #7 from ShikharY10/features/docs
Browse files Browse the repository at this point in the history
New Features
  • Loading branch information
ShikharY10 authored Oct 26, 2023
2 parents 9d76e3f + 262aa62 commit 63328a8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ Replace the below command with `"dev"` script in generated `package.json` file o
```json
{
"scripts": {
"dev": "concurrently \"directutils gossip <project-name> <extension-type> <extension-name>\" \"directus-extension build -w --no-minify\""
"dev": "concurrently \"directutils gossip <destination-file>\" \"directus-extension build -w --no-minify\""
}
}
```

Be make sure replace these in above command

- `<project-name>` name of the directus repo
- `<extension-type>` type of the extension like hooks, endpoints, etc
- `<extension-name>` name of the extension
- `<destination-file>` : Full path of the destination file in which you want the content to be copied.

## Environment variable expected by this package

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Utility for directus extensions",
"main": "./src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"publish": "npm publish"
},
"bin": {
"directutils": "./src/cli.js"
Expand Down
12 changes: 5 additions & 7 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ function handleCLIargs() {
// creating tool
program
.name("directus_utils")
.description("A CLI tool for performing simple math functions")
.version("1.0.0");
.description("Utility For Directus Extensions")
.version("1.0.4");

// adding command
program
.command("gossip")
.description("Watches for file change")
.argument("<project_name>", "Project Name")
.argument("<extension_type>", "Extension Type")
.argument("<extension name>", "Extension Name")
.action((a, b, c) => {
listner(a, b, c);
.argument("<destination_file>", "Destination File")
.action((a) => {
listner(a);
});

program.parse();
Expand Down
6 changes: 3 additions & 3 deletions src/lib/db_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function readCollectionDataById(collection, item, query, isCustom = true)
url: url,
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${ADMIN_STATIC_TOKEN}`
'Authorization': `Bearer ${process.env.STATIC_ACCESS_TOKEN}`
},
};

Expand All @@ -46,7 +46,7 @@ async function readCollectionDataById(collection, item, query, isCustom = true)
* @returns {object} Returns collection read object or list based `expectMultiple` params
*/
async function readCollectionDataByQuery(collection, query, expectMultiple=false, isCustom=true) {
var url = isCustom ? `${BASE_URL}/items/${collection}?` : `${BASE_URL}/${collection}`
var url = isCustom ? `${getBaseUrl()}/items/${collection}?` : `${getBaseUrl()}/${collection}`

Object.entries(query).forEach(([key, value]) => {
if (key == "filter") {
Expand All @@ -62,7 +62,7 @@ async function readCollectionDataByQuery(collection, query, expectMultiple=false
url: url,
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.ADMIN_STATIC_TOKEN}`
'Authorization': `Bearer ${process.env.STATIC_ACCESS_TOKEN}`
},
};

Expand Down
8 changes: 2 additions & 6 deletions src/lib/listner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ const copyFileContent = (source, destination) => {
}
};

function listener(project_name, extension_type, extension_name) {

const PROJECT_NAME = (project_name != null) ? project_name : process.env.PROJECT_NAME;
const EXT_TYPE = (extension_type != null) ? extension_type : process.env.EXT_TYPE;
const EXT_NAME = (extension_name != null) ? extension_name : process.env.EXT_NAME;
function listener(destinationFile) {

const SOURCE = './dist/index.js';
const DESTINATION = `../../${PROJECT_NAME}/extensions/${EXT_TYPE}/${EXT_NAME}/index.js`;
const DESTINATION = (destinationFile != null) ? destinationFile : process.env.DESTINATION_FILE;

const watcher = chokidar.watch(SOURCE, { ignoreInitial: true });

Expand Down

0 comments on commit 63328a8

Please sign in to comment.