@datadog/create-apps 0.1.1 → 0.1.2
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/dist/bin.js +2 -2
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -314,7 +314,7 @@ jobs:
|
|
|
314
314
|
uses: actions/setup-node@v6
|
|
315
315
|
|
|
316
316
|
- name: Deploy
|
|
317
|
-
uses: DataDog/apps-github-action@
|
|
317
|
+
uses: DataDog/apps-github-action@2c2495d48c9569b6eace166a5d43e60d9e5b81da # v0.1.1
|
|
318
318
|
with:
|
|
319
319
|
datadog-api-key: \${{ secrets.DATADOG_API_KEY }}
|
|
320
320
|
datadog-app-key: \${{ secrets.DATADOG_APP_KEY }}
|
|
@@ -788,4 +788,4 @@ export default defineConfig({
|
|
|
788
788
|
`};var ni={name:"Vite & React",description:"A basic React application bundled with Vite.",requiresRumConfig:!0,postScaffoldCommands:{setup:["npm install"],gitInit:["git init","git add .",'git commit -m "Initial commit"']}};var oi={metadata:ni,files:[Kn,jn,Qn,Un,Mn,Ln,Gn,Hn,qn,zn,Yn,Wn,Zn,Xn,Vn,Jn,_n,$n,eo,to]};var Je={"vite-react":oi};function qu(e,t){let n=[];return typeof e!="object"||e===null?(n.push(`[${t}] metadata.json must be a valid JSON object`),n):(!("name"in e)||typeof e.name!="string"?n.push(`[${t}] metadata.json is missing required "name" field (string)`):e.name.trim()===""&&n.push(`[${t}] metadata.json "name" field cannot be empty`),!("description"in e)||typeof e.description!="string"?n.push(`[${t}] metadata.json is missing required "description" field (string)`):e.description.trim()===""&&n.push(`[${t}] metadata.json "description" field cannot be empty`),n)}function Qu(e,t){let n=[];return typeof e!="object"||e===null?(n.push(`[${t}] must export an object`),n):("filepath"in e?typeof e.filepath!="string"&&n.push(`[${t}] "filepath" must be a string, got ${typeof e.filepath}`):n.push(`[${t}] missing required export "filepath"`),"contents"in e?typeof e.contents!="function"&&n.push(`[${t}] "contents" must be a function, got ${typeof e.contents}`):n.push(`[${t}] missing required export "contents"`),n)}var ri=["npm","yarn","git"],ii=["|",">","<","$(","`","&&","||",";"];function Yu(e){let t=e.trim(),r=t.split(/\s+/)[0];if(!r||!ri.includes(r))return!1;for(let o of ii)if(t.includes(o))return!1;return!0}function Ku(e,t){let n=[];if(!e.postScaffoldCommands)return n;let r=[...e.postScaffoldCommands.setup??[],...e.postScaffoldCommands.gitInit??[]];for(let o of r)if(!Yu(o)){let i=ri.join(", "),a=ii.join(", ");n.push(`[${t}] Unsafe post-scaffold command: "${o}".
|
|
789
789
|
Only ${i} commands without dangerous patterns (${a}) are allowed.`)}return n}function si(){let e=[];for(let[t,n]of Object.entries(Je)){e.push(...qu(n.metadata,t)),e.push(...Ku(n.metadata,t));for(let r of n.files)e.push(...Qu(r,n.metadata.name))}if(e.length>0){let t=["Template validation errors:",...e.map(n=>` - ${n}`)].join(`
|
|
790
790
|
`);return console.log(t),1}return 0}function ro(e){let t=Je[e];if(!t){let n=Object.keys(Je).join(", ");throw new Error(`Unknown template "${e}". Available templates: ${n}. Remove the --template option to select from the list instead.`)}return t}async function ai(){let e=Object.values(Je).map(t=>({name:t.metadata.name,value:t,description:t.metadata.description}));if(e.length===0)throw new Error("No templates found.");return In({message:"Select a template",choices:e.map(({name:t,value:n,description:r})=>({name:`${_o(t)}
|
|
791
|
-
${I(r)}`,value:n}))})}async function ui(e,t){let n=t.map(async({filepath:r,contents:o})=>{let i=oo.default.join(e,r);await no.default.mkdir(oo.default.dirname(i),{recursive:!0}),await no.default.writeFile(i,o,Buffer.isBuffer(o)?void 0:{encoding:"utf-8"})});await Promise.all(n)}var It=class extends G.Command{static paths=[G.Command.Default];static usage=G.Command.Usage({description:"Create a new Datadog App",examples:[["Create a new app interactively","npm init @datadog/apps my-app"],["Create a new app non-interactively","npm init @datadog/apps my-app --template vite-react -y"],["Create an app with a custom name and site",'npm init @datadog/apps my-app --name "My App" --site datadoghq.eu -y']]});directory=G.Option.String({required:!1});template=G.Option.String("--template",{required:!1,description:"Template to use (e.g., vite-react)"});appName=G.Option.String("--name",{required:!1,description:"App name (user-facing)"});datadogSite=G.Option.String("--site",{required:!1,description:"Datadog site (e.g. datadoghq.com, datadoghq.eu)"});identifier=G.Option.String("--identifier",{required:!1,description:"App identifier baked into datadog-app.config.json (defaults to a generated value)"});yes=G.Option.Boolean("--yes,-y",{description:"Accept all defaults without prompting"});overwrite=G.Option.Boolean("--overwrite",{description:"Overwrite existing directory without prompting"});validate=G.Option.Boolean("--validate",{description:"Validate templates and exit"});skipPostScaffold=G.Option.Boolean("--skip-post-scaffold",{description:"Skip post-scaffold commands"});async execute(){console.log($o),console.log(),console.log();try{if(this.validate)return si();let t=await ei(this.directory,this.overwrite,this.yes,this.appName,this.datadogSite),n=di.default.resolve(process.cwd(),t.directory),r=this.template?ro(this.template):this.yes?ro("vite-react"):await ai(),o=r.metadata;console.log(),console.log(),console.log(`Creating ${L(t.name)} in ${L(n)}...`),console.log(),console.log();let i=r.files.map(a=>({filepath:a.filepath,contents:a.contents({name:t.name,directoryName:t.directoryName,datadogSite:t.datadogSite,identifier:this.identifier})}));return await ui(n,i),await Xr(n,o,this.skipPostScaffold,this.yes),console.log(nr(t)),0}catch(t){return rr(t)?console.log(tr()):ir(t),1}}};var ci="0.1.
|
|
791
|
+
${I(r)}`,value:n}))})}async function ui(e,t){let n=t.map(async({filepath:r,contents:o})=>{let i=oo.default.join(e,r);await no.default.mkdir(oo.default.dirname(i),{recursive:!0}),await no.default.writeFile(i,o,Buffer.isBuffer(o)?void 0:{encoding:"utf-8"})});await Promise.all(n)}var It=class extends G.Command{static paths=[G.Command.Default];static usage=G.Command.Usage({description:"Create a new Datadog App",examples:[["Create a new app interactively","npm init @datadog/apps my-app"],["Create a new app non-interactively","npm init @datadog/apps my-app --template vite-react -y"],["Create an app with a custom name and site",'npm init @datadog/apps my-app --name "My App" --site datadoghq.eu -y']]});directory=G.Option.String({required:!1});template=G.Option.String("--template",{required:!1,description:"Template to use (e.g., vite-react)"});appName=G.Option.String("--name",{required:!1,description:"App name (user-facing)"});datadogSite=G.Option.String("--site",{required:!1,description:"Datadog site (e.g. datadoghq.com, datadoghq.eu)"});identifier=G.Option.String("--identifier",{required:!1,description:"App identifier baked into datadog-app.config.json (defaults to a generated value)"});yes=G.Option.Boolean("--yes,-y",{description:"Accept all defaults without prompting"});overwrite=G.Option.Boolean("--overwrite",{description:"Overwrite existing directory without prompting"});validate=G.Option.Boolean("--validate",{description:"Validate templates and exit"});skipPostScaffold=G.Option.Boolean("--skip-post-scaffold",{description:"Skip post-scaffold commands"});async execute(){console.log($o),console.log(),console.log();try{if(this.validate)return si();let t=await ei(this.directory,this.overwrite,this.yes,this.appName,this.datadogSite),n=di.default.resolve(process.cwd(),t.directory),r=this.template?ro(this.template):this.yes?ro("vite-react"):await ai(),o=r.metadata;console.log(),console.log(),console.log(`Creating ${L(t.name)} in ${L(n)}...`),console.log(),console.log();let i=r.files.map(a=>({filepath:a.filepath,contents:a.contents({name:t.name,directoryName:t.directoryName,datadogSite:t.datadogSite,identifier:this.identifier})}));return await ui(n,i),await Xr(n,o,this.skipPostScaffold,this.yes),console.log(nr(t)),0}catch(t){return rr(t)?console.log(tr()):ir(t),1}}};var ci="0.1.2";var Tt=new _e.Cli({binaryLabel:"create-apps",binaryName:"npm init @datadog/apps",binaryVersion:ci});Tt.register(It);Tt.register(_e.Builtins.HelpCommand);Tt.register(_e.Builtins.VersionCommand);Tt.runExit(process.argv.slice(2));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/create-apps",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create Datadog Apps",
|
|
6
6
|
"homepage": "https://datadoghq.com",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/node": "catalog:",
|
|
40
40
|
"esbuild": "0.27.5",
|
|
41
41
|
"eslint": "9.29.0",
|
|
42
|
-
"eslint-plugin-react-hooks": "7.
|
|
42
|
+
"eslint-plugin-react-hooks": "7.1.1",
|
|
43
43
|
"eslint-plugin-react-refresh": "0.4.20",
|
|
44
44
|
"globals": "15.15.0",
|
|
45
45
|
"typescript-eslint": "8.56.1"
|