@cognite/cli 0.5.2 → 0.6.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -33
- package/_templates/app/new/config/eslint.config.mjs.ejs.t +99 -0
- package/_templates/app/new/config/tsconfig.json.ejs.t +35 -0
- package/_templates/app/new/config/tsconfig.node.json.ejs.t +27 -0
- package/_templates/app/new/config/vite.config.ts.ejs.t +28 -0
- package/_templates/app/new/config/vitest.config.ts.ejs.t +14 -0
- package/_templates/app/new/config/vitest.setup.ts.ejs.t +4 -0
- package/_templates/app/new/github/ci.yml.ejs.t +36 -0
- package/_templates/app/new/prompt.js +49 -0
- package/_templates/app/new/root/.npmrc.ejs.t +4 -0
- package/_templates/app/new/root/AGENTS.md.ejs.t +215 -0
- package/_templates/app/new/root/SPEC.md.ejs.t +77 -0
- package/_templates/app/new/root/app.json.ejs.t +20 -0
- package/_templates/app/new/root/gitignore.ejs.t +21 -0
- package/_templates/app/new/root/index.html.ejs.t +36 -0
- package/_templates/app/new/root/manifest.json.ejs.t +9 -0
- package/_templates/app/new/root/package.json.ejs.t +65 -0
- package/_templates/app/new/src/App.test.tsx.ejs.t +45 -0
- package/_templates/app/new/src/App.tsx.ejs.t +234 -0
- package/_templates/app/new/src/lib/utils.ts.ejs.t +9 -0
- package/_templates/app/new/src/main.tsx.ejs.t +27 -0
- package/_templates/app/new/src/styles.css.ejs.t +12 -0
- package/_vendor/spec-kit/.version +4 -0
- package/_vendor/spec-kit/README.md +39 -0
- package/_vendor/spec-kit/commands/speckit.analyze.md +249 -0
- package/_vendor/spec-kit/commands/speckit.checklist.md +361 -0
- package/_vendor/spec-kit/commands/speckit.clarify.md +247 -0
- package/_vendor/spec-kit/commands/speckit.implement.md +198 -0
- package/_vendor/spec-kit/commands/speckit.plan.md +149 -0
- package/_vendor/spec-kit/commands/speckit.specify.md +327 -0
- package/_vendor/spec-kit/commands/speckit.tasks.md +200 -0
- package/_vendor/spec-kit/scripts/bash/check-prerequisites.sh +190 -0
- package/_vendor/spec-kit/scripts/bash/common.sh +645 -0
- package/_vendor/spec-kit/scripts/bash/setup-plan.sh +75 -0
- package/_vendor/spec-kit/templates/checklist-template.md +40 -0
- package/_vendor/spec-kit/templates/plan-template.md +104 -0
- package/_vendor/spec-kit/templates/spec-template.md +128 -0
- package/_vendor/spec-kit/templates/tasks-template.md +251 -0
- package/dist/chunk-6IFTGM5Y.js +6 -0
- package/dist/chunk-6JBK3X6U.js +2 -0
- package/dist/chunk-7BIIU2MQ.js +8 -0
- package/dist/chunk-CQ5OFVL5.js +2 -0
- package/dist/chunk-F3TJC2SP.js +2 -0
- package/dist/cli/cli.js +350 -0
- package/dist/esm-OFTP7G2W.js +34 -0
- package/dist/getMachineId-bsd-3GB6MPGO.js +2 -0
- package/dist/getMachineId-darwin-4AJ74CH4.js +3 -0
- package/dist/getMachineId-linux-IEUC3AW3.js +2 -0
- package/dist/getMachineId-unsupported-YOCUE26C.js +2 -0
- package/dist/getMachineId-win-DDKCA2D6.js +2 -0
- package/dist/skills-R7PLBJFQ.js +2 -0
- package/package.json +26 -17
- package/index.js +0 -116
- package/operations.js +0 -113
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as i}from"./chunk-CQ5OFVL5.js";import{p as r,u as n}from"./chunk-F3TJC2SP.js";import{a as t}from"./chunk-6JBK3X6U.js";import{promises as s}from"fs";n();async function d(){try{return(await s.readFile("/etc/hostid",{encoding:"utf8"})).trim()}catch(e){r.debug(`error reading machine id: ${e}`)}try{return(await i("kenv -q smbios.system.uuid")).stdout.trim()}catch(e){r.debug(`error reading machine id: ${e}`)}}t(d,"getMachineId");export{d as getMachineId};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as c}from"./chunk-CQ5OFVL5.js";import{p as n,u as o}from"./chunk-F3TJC2SP.js";import{a as i}from"./chunk-6JBK3X6U.js";o();async function u(){try{let t=(await c('ioreg -rd1 -c "IOPlatformExpertDevice"')).stdout.split(`
|
|
3
|
+
`).find(d=>d.includes("IOPlatformUUID"));if(!t)return;let r=t.split('" = "');if(r.length===2)return r[1].slice(0,-1)}catch(e){n.debug(`error reading machine id: ${e}`)}}i(u,"getMachineId");export{u as getMachineId};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{p as t,u as a}from"./chunk-F3TJC2SP.js";import{a as r}from"./chunk-6JBK3X6U.js";a();import{promises as o}from"fs";async function s(){let i=["/etc/machine-id","/var/lib/dbus/machine-id"];for(let n of i)try{return(await o.readFile(n,{encoding:"utf8"})).trim()}catch(e){t.debug(`error reading machine id: ${e}`)}}r(s,"getMachineId");export{s as getMachineId};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{p as n,u as d}from"./chunk-F3TJC2SP.js";import{a as e}from"./chunk-6JBK3X6U.js";d();async function r(){n.debug("could not read machine-id: unsupported platform")}e(r,"getMachineId");export{r as getMachineId};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as c}from"./chunk-CQ5OFVL5.js";import{p as s,u as a}from"./chunk-F3TJC2SP.js";import{a as n}from"./chunk-6JBK3X6U.js";import*as r from"process";a();async function p(){let o="QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",e="%windir%\\System32\\REG.exe";r.arch==="ia32"&&"PROCESSOR_ARCHITEW6432"in r.env&&(e="%windir%\\sysnative\\cmd.exe /c "+e);try{let i=(await c(`${e} ${o}`)).stdout.split("REG_SZ");if(i.length===2)return i[1].trim()}catch(t){s.debug(`error reading machine id: ${t}`)}}n(p,"getMachineId");export{p as getMachineId};
|
package/package.json
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognite/cli",
|
|
3
|
+
"version": "0.6.0-alpha.26",
|
|
4
|
+
"description": "CLI for Cognite Data Fusion",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Cognite",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/cognitedata/dune.git",
|
|
10
|
+
"directory": "packages/cli"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
3
13
|
"bin": {
|
|
4
|
-
"
|
|
14
|
+
"dune": "./dist/cli/cli.js"
|
|
5
15
|
},
|
|
6
16
|
"files": [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
17
|
+
"dist",
|
|
18
|
+
"_templates",
|
|
19
|
+
"_vendor"
|
|
9
20
|
],
|
|
10
|
-
"version": "0.5.2",
|
|
11
|
-
"description": "a cli for cognite data fusion",
|
|
12
|
-
"main": "index.js",
|
|
13
21
|
"scripts": {
|
|
14
|
-
"
|
|
22
|
+
"build": "tsup && cp -r ../dune/_templates . && cp -r ../dune/_vendor .",
|
|
23
|
+
"prepublishOnly": "pnpm run build",
|
|
24
|
+
"refresh-spec-kit": "bash ../dune/scripts/refresh-spec-kit.sh"
|
|
15
25
|
},
|
|
16
|
-
"author": "You",
|
|
17
|
-
"license": "MIT",
|
|
18
26
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"pipe-args": "^1.3.0",
|
|
22
|
-
"yargs": "^13.3.0"
|
|
27
|
+
"commander": "^14.0.3",
|
|
28
|
+
"skills": "^1.4.3"
|
|
23
29
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^24.10.1",
|
|
32
|
+
"tsup": "^8.4.0",
|
|
33
|
+
"typescript": "^5.0.0"
|
|
27
34
|
},
|
|
28
|
-
"
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20"
|
|
37
|
+
}
|
|
29
38
|
}
|
package/index.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
require('pipe-args').load();
|
|
3
|
-
const yargs = require('yargs');
|
|
4
|
-
const { CogniteClient } = require('@cognite/sdk');
|
|
5
|
-
const yaml = require('js-yaml');
|
|
6
|
-
const getOperation = require('./operations');
|
|
7
|
-
|
|
8
|
-
if (!(process.env.COGNITE_CREDENTIALS && process.env.COGNITE_PROJECT)) {
|
|
9
|
-
console.error(`Both COGNITE_CREDENTIALS and COGNITE_PROJECT needs to be set`);
|
|
10
|
-
process.exit(1);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const sdk = new CogniteClient({
|
|
14
|
-
appId: 'cdf-cli',
|
|
15
|
-
baseUrl: process.env.COGNITE_BASE_URL || 'https://api.cognitedata.com',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
sdk.loginWithApiKey({
|
|
19
|
-
apiKey: process.env.COGNITE_CREDENTIALS,
|
|
20
|
-
project: process.env.COGNITE_PROJECT,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Supported resource types
|
|
24
|
-
const resourceTypes = [
|
|
25
|
-
'timeseries',
|
|
26
|
-
'sequences',
|
|
27
|
-
'assets',
|
|
28
|
-
'events',
|
|
29
|
-
'files',
|
|
30
|
-
'datapoints',
|
|
31
|
-
'apiKeys',
|
|
32
|
-
'securityCategories',
|
|
33
|
-
'serviceAccounts',
|
|
34
|
-
'groups',
|
|
35
|
-
'raw',
|
|
36
|
-
'models3D',
|
|
37
|
-
'revisions3D',
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
// Remove these nonsense properties from the resourceTypes
|
|
41
|
-
// and assume the rest is the actual operations
|
|
42
|
-
const BLACKLIST = [
|
|
43
|
-
'transformTo',
|
|
44
|
-
'client',
|
|
45
|
-
'resourcePath',
|
|
46
|
-
'map',
|
|
47
|
-
'callListEndpointWithGet',
|
|
48
|
-
'callListEndpointWithPost',
|
|
49
|
-
'sequenceRowsAPI',
|
|
50
|
-
'rawTablesApi',
|
|
51
|
-
'rawRowsApi',
|
|
52
|
-
].map(i => new RegExp(i, 'gi'));
|
|
53
|
-
|
|
54
|
-
function cleanArguments(args) {
|
|
55
|
-
const cp = {
|
|
56
|
-
...args,
|
|
57
|
-
};
|
|
58
|
-
// Remove the ones that will not get passed on to the SDK
|
|
59
|
-
delete cp['$0'];
|
|
60
|
-
delete cp['_'];
|
|
61
|
-
delete cp['o'];
|
|
62
|
-
return cp;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const mainHandler = (resourceType, operation) => async yargz => {
|
|
66
|
-
const func = getOperation(
|
|
67
|
-
resourceType,
|
|
68
|
-
operation,
|
|
69
|
-
sdk,
|
|
70
|
-
cleanArguments(yargz)
|
|
71
|
-
);
|
|
72
|
-
if (!func) {
|
|
73
|
-
console.error(
|
|
74
|
-
`Sorry, ${resourceType} ${operation} is not implemented yet :-(`
|
|
75
|
-
);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Handle result
|
|
80
|
-
try {
|
|
81
|
-
let extraArguments = [];
|
|
82
|
-
if (yargz['_'].length > 2) {
|
|
83
|
-
// Some arguments should go to the sdk
|
|
84
|
-
// this would be all non-options after cdf revisions3D list
|
|
85
|
-
extraArguments = yargz['_'].slice(2);
|
|
86
|
-
}
|
|
87
|
-
let result = await func(...extraArguments);
|
|
88
|
-
if (result.map) {
|
|
89
|
-
// This is an array, remove nonsense objects
|
|
90
|
-
result = result.map(r => JSON.parse(JSON.stringify(r)));
|
|
91
|
-
}
|
|
92
|
-
const YAML_OUTPUT = /yaml|yml/.test(yargz.o);
|
|
93
|
-
if (YAML_OUTPUT) {
|
|
94
|
-
console.log(yaml.safeDump(result));
|
|
95
|
-
} else {
|
|
96
|
-
console.log(JSON.stringify(result, null, 2));
|
|
97
|
-
}
|
|
98
|
-
} catch (ex) {
|
|
99
|
-
console.error(ex);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
for (const resourceType of resourceTypes) {
|
|
104
|
-
const validOperations = Object.keys(sdk[resourceType]).filter(
|
|
105
|
-
key => !BLACKLIST.some(regEx => regEx.test(key))
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
yargs.command(`${resourceType} <operation>`, '', yargz => {
|
|
109
|
-
// Create the subcommands
|
|
110
|
-
for (const operation of validOperations) {
|
|
111
|
-
yargz.command(operation, '', {}, mainHandler(resourceType, operation));
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
yargs.help().argv;
|
package/operations.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
function getOperation(resourceType, operation, sdk, args) {
|
|
2
|
-
// Generic function that can read a single entity from options
|
|
3
|
-
// e.g `cdf timeseries create --externalId=my.extid --name=my.name`
|
|
4
|
-
// or it reads a piped/buffered input and assumes an array
|
|
5
|
-
// e.g `cat timeseries.json | cdf timeseries create`
|
|
6
|
-
const argsOrPipedOperation = operation => {
|
|
7
|
-
return () => {
|
|
8
|
-
// Check if any normal arguments are sent
|
|
9
|
-
let arrayArgs;
|
|
10
|
-
if (Object.keys(args).length > 0) {
|
|
11
|
-
arrayArgs = [{ ...args }];
|
|
12
|
-
} else {
|
|
13
|
-
// Assume that stuff is piped
|
|
14
|
-
const buffer = process.argv[process.argv.length - 1];
|
|
15
|
-
arrayArgs = JSON.parse(buffer);
|
|
16
|
-
}
|
|
17
|
-
return sdk[resourceType][operation](arrayArgs);
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const operationMap = {
|
|
22
|
-
list: function() {
|
|
23
|
-
let assetIds = args.assetIds;
|
|
24
|
-
switch (typeof assetIds) {
|
|
25
|
-
case 'number':
|
|
26
|
-
assetIds = [assetIds];
|
|
27
|
-
break;
|
|
28
|
-
case 'string':
|
|
29
|
-
if (assetIds.startsWith('[')) {
|
|
30
|
-
assetIds = assetIds.slice(1);
|
|
31
|
-
}
|
|
32
|
-
if (assetIds.endsWith(']')) {
|
|
33
|
-
assetIds = assetIds.slice(0, assetIds.length - 1);
|
|
34
|
-
}
|
|
35
|
-
const splitted = assetIds.split(',');
|
|
36
|
-
if (splitted.length > 1) {
|
|
37
|
-
assetIds = splitted.map(Number);
|
|
38
|
-
} else {
|
|
39
|
-
assetIds = [Number(assetIds)];
|
|
40
|
-
}
|
|
41
|
-
break;
|
|
42
|
-
default:
|
|
43
|
-
assetIds = undefined;
|
|
44
|
-
}
|
|
45
|
-
// Some list operations take more just one object
|
|
46
|
-
// Check if this function was called with any direct objects and pass them on
|
|
47
|
-
// ex. cdf revisions3D list 123123 --filter
|
|
48
|
-
// To make the code worse, make sure there's nothing undefined #javascript
|
|
49
|
-
const sdkArguments = [
|
|
50
|
-
...arguments,
|
|
51
|
-
{
|
|
52
|
-
...args,
|
|
53
|
-
assetIds,
|
|
54
|
-
limit: undefined,
|
|
55
|
-
},
|
|
56
|
-
].filter(a => a !== undefined);
|
|
57
|
-
const promise = sdk[resourceType].list(...sdkArguments);
|
|
58
|
-
if (promise.autoPagingToArray) {
|
|
59
|
-
return promise.autoPagingToArray({ limit: args.limit });
|
|
60
|
-
}
|
|
61
|
-
return promise;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
list3DNodes: function() {
|
|
65
|
-
const sdkArguments = [
|
|
66
|
-
...arguments,
|
|
67
|
-
{
|
|
68
|
-
...args,
|
|
69
|
-
},
|
|
70
|
-
].filter(a => a !== undefined);
|
|
71
|
-
|
|
72
|
-
return sdk[resourceType].list3DNodes(...sdkArguments);
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
retrieve: () => {
|
|
76
|
-
const externalIds =
|
|
77
|
-
(args.externalIds && String(args.externalIds).split(',')) || [];
|
|
78
|
-
const ids = (args.ids && String(args.ids).split(',')) || [];
|
|
79
|
-
const allIds = [
|
|
80
|
-
...ids.map(i => ({ id: i })),
|
|
81
|
-
...externalIds.map(i => ({ externalId: i })),
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
if (resourceType === 'datapoints') {
|
|
85
|
-
// This has to be handled separately.
|
|
86
|
-
const clonedArgs = {
|
|
87
|
-
...args,
|
|
88
|
-
ids: undefined,
|
|
89
|
-
externalIds: undefined,
|
|
90
|
-
};
|
|
91
|
-
return sdk.datapoints.retrieve({ ...clonedArgs, items: allIds });
|
|
92
|
-
}
|
|
93
|
-
return sdk[resourceType].retrieve(allIds);
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
retrieveLatest: argsOrPipedOperation('retrieveLatest'),
|
|
97
|
-
|
|
98
|
-
search: () => sdk[resourceType].search(args),
|
|
99
|
-
|
|
100
|
-
create: argsOrPipedOperation('create'),
|
|
101
|
-
|
|
102
|
-
delete: argsOrPipedOperation('delete'),
|
|
103
|
-
|
|
104
|
-
update: argsOrPipedOperation('update'),
|
|
105
|
-
};
|
|
106
|
-
const func = operationMap[operation];
|
|
107
|
-
if (func) {
|
|
108
|
-
return func;
|
|
109
|
-
}
|
|
110
|
-
throw new Error(`${resourceType}.${operation} isn't implemented yet :-(`);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
module.exports = getOperation;
|