create-qwik 1.2.0 → 1.2.1

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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * create-qwik 1.2.0
3
+ * create-qwik 1.2.1
4
4
  * Copyright Builder.io, Inc. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/BuilderIO/qwik/blob/main/LICENSE
@@ -88,8 +88,8 @@ ${T("\u251C"+"\u2500".repeat(s+2)+"\u256F")}
88
88
  `))}if(!n){let a=`${ou(` ${e} install failed `)}
89
89
  You might need to run ${S(`"${e} install"`)} manually inside the root of the project.
90
90
 
91
- `;B.error(a)}return n}}}function ts(e){let t="create-qwik-"+Math.round(Math.random()*Number.MAX_SAFE_INTEGER).toString(36).toLowerCase(),D=I.default.join(Nt.default.tmpdir(),t);try{q.default.mkdirSync(D)}catch(i){B.error(`\u274C ${x(String(i))}`)}let s=I.default.join(e.dir,"package.json"),r=I.default.join(D,"package.json");return q.default.copyFileSync(s,r),{tmpInstallDir:D}}var A=y(require("fs"),1),tu=require("path");async function ee(e,t,D,s){let r=await A.default.promises.readdir(D);await Promise.all(r.map(async i=>{let u=i==="gitignore"?".gitignore":i,n=(0,tu.extname)(u),a=(0,tu.join)(D,i),c=(0,tu.join)(s,u),p=await A.default.promises.stat(a);p.isDirectory()?await ee(e,t,a,c):p.isFile()&&(u==="package.json"?await Ds(e,a,c):u==="settings.json"?await ss(e,a,c):u==="README.md"?await is(e,a,c):u===".gitignore"||u===".prettierignore"||u===".eslintignore"?await ns(e,a,c):n===".css"?await os(e,a,c):A.default.existsSync(c)?e.files.push({path:c,content:await A.default.promises.readFile(a),type:"overwrite"}):e.files.push({path:c,content:await A.default.promises.readFile(a),type:"create"}))}))}async function Ds(e,t,D){var u;let s=await A.default.promises.readFile(t,"utf-8"),r=JSON.parse(s),i=["scripts","dependencies","devDependencies"];try{let n=JSON.parse(await A.default.promises.readFile(D,"utf-8"));if(i.forEach(a=>{rs(r,n,a)}),(u=n.scripts)!=null&&u.qwik){let a=n.scripts.qwik;delete n.scripts.qwik,n.scripts.qwik=a}e.files.push({path:D,content:JSON.stringify(n,null,2)+`
92
- `,type:"modify"})}catch{e.files.push({path:D,content:s,type:"create"})}}async function ss(e,t,D){let s=await A.default.promises.readFile(t,"utf-8"),r=JSON.parse(s);try{let i=JSON.parse(await A.default.promises.readFile(D,"utf-8"));Object.assign(r,i),e.files.push({path:D,content:JSON.stringify(r,null,2)+`
91
+ `;B.error(a)}return n}}}function ts(e){let t="create-qwik-"+Math.round(Math.random()*Number.MAX_SAFE_INTEGER).toString(36).toLowerCase(),D=I.default.join(Nt.default.tmpdir(),t);try{q.default.mkdirSync(D)}catch(i){B.error(`\u274C ${x(String(i))}`)}let s=I.default.join(e.dir,"package.json"),r=I.default.join(D,"package.json");return q.default.copyFileSync(s,r),{tmpInstallDir:D}}var A=y(require("fs"),1),tu=require("path");async function ee(e,t,D,s){let r=await A.default.promises.readdir(D);await Promise.all(r.map(async i=>{let u=i==="gitignore"?".gitignore":i,n=(0,tu.extname)(u),a=(0,tu.join)(D,i),c=(0,tu.join)(s,u),p=await A.default.promises.stat(a);p.isDirectory()?await ee(e,t,a,c):p.isFile()&&(u==="package.json"?await Ds(e,a,c):u==="settings.json"?await ss(e,a,c):u==="README.md"?await is(e,a,c):u===".gitignore"||u===".prettierignore"||u===".eslintignore"?await ns(e,a,c):n===".css"?await os(e,a,c):A.default.existsSync(c)?e.files.push({path:c,content:await A.default.promises.readFile(a),type:"overwrite"}):e.files.push({path:c,content:await A.default.promises.readFile(a),type:"create"}))}))}async function Ds(e,t,D){var r;let s=await A.default.promises.readFile(t,"utf-8");try{let i=JSON.parse(s),u=["scripts","dependencies","devDependencies"],n=JSON.parse(await A.default.promises.readFile(D,"utf-8"));if(u.forEach(a=>{rs(i,n,a)}),(r=n.scripts)!=null&&r.qwik){let a=n.scripts.qwik;delete n.scripts.qwik,n.scripts.qwik=a}e.files.push({path:D,content:JSON.stringify(n,null,2)+`
92
+ `,type:"modify"})}catch{e.files.push({path:D,content:s,type:"create"})}}async function ss(e,t,D){let s=await A.default.promises.readFile(t,"utf-8");try{let r=JSON.parse(s),i=JSON.parse(await A.default.promises.readFile(D,"utf-8"));Object.assign(r,i),e.files.push({path:D,content:JSON.stringify(r,null,2)+`
93
93
  `,type:"modify"})}catch{e.files.push({path:D,content:s,type:"create"})}}function rs(e,t,D){if(e[D]){t[D]?Object.assign(t[D],{...e[D]}):t[D]={...e[D]};let s={},r=Object.keys(t[D]).sort();for(let i of r)s[i]=t[D][i];t[D]=s}}async function is(e,t,D){let s=await A.default.promises.readFile(t,"utf-8"),r,i="";try{i=await A.default.promises.readFile(D,"utf-8"),i=i.trim()+`
94
94
 
95
95
  `+s,r="modify"}catch{i=s,r="create"}let u=M();u!=="npm"&&(i=i.replace(/npm run/g,u)),e.files.push({path:D,content:i.trim()+`
@@ -100,4 +100,4 @@ ${T("\u251C"+"\u2500".repeat(s+2)+"\u256F")}
100
100
  `+r.trim()+`
101
101
  `;e.files.push({path:D,content:i,type:"modify"})}catch{e.files.push({path:D,content:s,type:"create"})}}async function De(e,t){let s=(await K()).find(n=>n.id===t.integration);if(!s)throw new Error(`Unable to find integration "${t.integration}"`);let r={files:[],installedDeps:{},installedScripts:Object.keys(s.pkgJson.scripts||{})};t.installDeps&&(r.installedDeps={...s.pkgJson.dependencies,...s.pkgJson.devDependencies}),await ee(r,t,s.dir,t.rootDir);let i=async n=>{let a=Object.keys(r.installedDeps).length>0,c=hu();n&&c.start(`Updating app${a?" and installing dependencies":""}...`);let p=!0;try{let l=new Set(r.files.map(C=>(0,qt.dirname)(C.path)));for(let C of Array.from(l))try{te.default.mkdirSync(C,{recursive:!0})}catch{}let F=Promise.all(r.files.map(async C=>{await te.default.promises.writeFile(C.path,C.content)}));if(t.installDeps&&Object.keys(r.installedDeps).length>0){let{install:C}=eu(e,t.rootDir);p=await C}if(await F,n&&c.stop("App updated"),!p){let C=`${ou(` ${e} install failed `)}
102
102
  You might need to run "${S(`${e} install`)}" manually inside the root of the project.`;B.error(C)}}catch(l){n&&c.stop("App updated"),U(String(l))}};return{rootDir:t.rootDir,integration:s,updates:r,commit:i}}var Lt=y(require("os"));async function se(e,t){as()?t=process.cwd():(t=ie(t),Du.default.existsSync(t)&&U(`Directory "${t}" already exists. Please either remove this directory, or choose another location.`));let D=M(),r=await su({starterId:e,outDir:t});return re(D,r,!1),r}function re(e,t,D){let s=process.cwd()===t.outDir,r=(0,_.relative)(process.cwd(),t.outDir),i=[];s?i.push(`\u{1F984} ${$u(" Success! ")}`):i.push(`\u{1F984} ${$u(" Success! ")} ${S("Project created in")} ${Ce(k(r))} ${S("directory")}`),i.push(""),i.push(`\u{1F430} ${S("Next steps:")}`),s||i.push(` cd ${r}`),D||i.push(` ${e} install`),i.push(` ${e} start`),i.push("");let u=e!=="npm"?`${e} qwik add`:"npm run qwik add";return i.push(`\u{1F90D} ${S("Integrations? Add Netlify, Cloudflare, Tailwind...")}`),i.push(` ${u}`),i.push(""),i.push(Rt(t.docs)),i.push(`\u{1F440} ${S("Presentations, Podcasts and Videos:")}`),i.push(" https://qwik.builder.io/media/"),i.push(""),i.join(`
103
- `)}async function su(e){let t=M();if(!Jt(e.starterId))throw new Error("Missing starter id");if(!Jt(e.outDir))throw new Error("Missing outDir");if(!(0,_.isAbsolute)(e.outDir))throw new Error("outDir must be an absolute path");Du.default.existsSync(e.outDir)||Du.default.mkdirSync(decodeURIComponent(e.outDir),{recursive:!0});let D={starterId:e.starterId,outDir:e.outDir,docs:[]},s=(await K()).filter(i=>i.type==="app");if(e.starterId==="library"){let i=s.find(u=>u.id==="library");if(!i)throw new Error("Unable to find base app");await Wt(t,D,i)}else{let i=s.find(n=>n.id==="base");if(!i)throw new Error("Unable to find base app");let u=s.find(n=>n.id===e.starterId);if(!u)throw new Error(`Invalid starter id "${e.starterId}". It can only be one of${s.map(n=>` "${n.id}"`)}.`);await Wt(t,D,i,u)}return D}async function Wt(e,t,D,s){t.docs.push(...D.docs);let r=s??D,i=Ot({...D.pkgJson,name:`my-${r.pkgJson.name}`,description:r.pkgJson.description,scripts:void 0,dependencies:void 0,devDependencies:void 0});await jt(t.outDir,i);let u=(0,_.join)(t.outDir,"README.md");await Du.default.promises.writeFile(u,""),await(await De(e,{rootDir:t.outDir,integration:D.id,installDeps:!1})).commit(!1),s&&(t.docs.push(...s.docs),await(await De(e,{rootDir:t.outDir,integration:s.id,installDeps:!1})).commit(!1))}function Jt(e){return typeof e=="string"&&e.trim().length>0}function ie(e){return e.startsWith("~/")?(0,_.resolve)(Lt.default.homedir(),e):(0,_.resolve)(process.cwd(),e)}function as(){return cs()}function cs(){try{return process.cwd().startsWith("/home/projects/")}catch{}return!1}var Y=y(require("fs")),ru=require("path");async function ne(){Pe(`Let's create a ${fu(" Qwik App ")} \u2728 (v1.2.0)`),await It(500);let e="./qwik-app",t=await Te({message:`Where would you like to create your new project? ${T("(Use '.' or './' for current directory)")}`,placeholder:e})||e;N(t)&&(uu("Operation cancelled."),process.exit(0));let D=M(),r=(await K()).filter($=>$.type==="app"),i=r.find($=>$.id==="base"),u=r.filter($=>$.id!==i.id),n=Mt(D,i),a=ie(t.trim());B.info(`Creating new project in ${fu(" "+a+" ")} ... \u{1F407}`);let c=null;if(Y.default.existsSync(a)&&Y.default.readdirSync(a).length>0){let $=await qu({message:`Directory "./${(0,ru.relative)(process.cwd(),a)}" already exists and is not empty. What would you like to do?`,options:[{value:"exit",label:"Do not overwrite this directory and exit"},{value:"replace",label:"Remove contents of this directory"}]});(N($)||$==="exit")&&(uu("Operation cancelled."),process.exit(0)),$==="replace"&&(c=Y.default.promises.readdir(a).then(W=>Promise.all(W.map(Vt=>Y.default.promises.rm((0,ru.join)(a,Vt),{recursive:!0})))))}let p=await qu({message:"Select a starter",options:u.map($=>{var W;return{label:$.name,value:$.id,hint:(W=$.pkgJson)==null?void 0:W.description}})});N(p)&&(uu("Operation cancelled."),process.exit(0));let l=p,F=await Mu({message:`Would you like to install ${D} dependencies?`,initialValue:!0});N(F)&&(uu("Operation cancelled."),process.exit(0));let C=await Mu({message:"Initialize a new git repository?",initialValue:!0});c&&await c;let w=F;w||n.abort();let R={starterId:l,outDir:a},O=hu();O.start("Creating App...");let iu=await su(R);if(O.stop("App Created \u{1F430}"),C)if(Y.default.existsSync((0,ru.join)(a,".git")))B.info("Git has already been initialized before. Skipping...");else{O.start("Git initializing...");try{let $=[];if($.push(await G("git",["init"],a).install),$.push(await G("git",["add","-A"],a).install),$.push(await G("git",["commit","-m","Initial commit \u26A1\uFE0F"],a).install),$.some(W=>W===!1))throw"";O.stop("Git initialized \u{1F3B2}")}catch{O.stop("Git failed to initialize"),B.error(x("Git failed to initialize. You can do this manually by running: git init"))}}let H=!1;return w&&(O.start(`Installing ${D} dependencies...`),H=await n.complete(iu.outDir),H&&(H=await eu(D,iu.outDir).install),O.stop(`${H?"Installed":"Failed to install"} ${D} dependencies \u{1F4CB}`)),Pt(re(D,iu,H),"Result"),Wu("Happy coding! \u{1F407}"),iu}async function ls(){console.clear(),Tt(),ps();try{let e=process.argv.slice(2);e.length>=2?await se(e[0],e[1]):await ne()}catch(e){U(e.message||e)}}function ps(){let e=process.version,[t,D]=e.replace("v","").split(".");Number(t)<16?(console.error(x(`Qwik requires Node.js 16.8 or higher. You are currently running Node.js ${e}.`)),process.exit(1)):Number(t)===16?Number(D)<8&&console.warn(me(`Node.js 16.8 or higher is recommended. You are currently running Node.js ${e}.`)):Number(t)===18&&Number(D)<11&&console.error(x(`Node.js 18.11 or higher is REQUIRED. From Node 18.0.0 to 18.11.0, there is a bug preventing correct behaviour of Qwik. You are currently running Node.js ${e}. https://github.com/BuilderIO/qwik/issues/3035`))}0&&(module.exports={createApp,runCli,runCreateCli,runCreateInteractiveCli});
103
+ `)}async function su(e){let t=M();if(!Jt(e.starterId))throw new Error("Missing starter id");if(!Jt(e.outDir))throw new Error("Missing outDir");if(!(0,_.isAbsolute)(e.outDir))throw new Error("outDir must be an absolute path");Du.default.existsSync(e.outDir)||Du.default.mkdirSync(decodeURIComponent(e.outDir),{recursive:!0});let D={starterId:e.starterId,outDir:e.outDir,docs:[]},s=(await K()).filter(i=>i.type==="app");if(e.starterId==="library"){let i=s.find(u=>u.id==="library");if(!i)throw new Error("Unable to find base app");await Wt(t,D,i)}else{let i=s.find(n=>n.id==="base");if(!i)throw new Error("Unable to find base app");let u=s.find(n=>n.id===e.starterId);if(!u)throw new Error(`Invalid starter id "${e.starterId}". It can only be one of${s.map(n=>` "${n.id}"`)}.`);await Wt(t,D,i,u)}return D}async function Wt(e,t,D,s){t.docs.push(...D.docs);let r=s??D,i=Ot({...D.pkgJson,name:`my-${r.pkgJson.name}`,description:r.pkgJson.description,scripts:void 0,dependencies:void 0,devDependencies:void 0});await jt(t.outDir,i);let u=(0,_.join)(t.outDir,"README.md");await Du.default.promises.writeFile(u,""),await(await De(e,{rootDir:t.outDir,integration:D.id,installDeps:!1})).commit(!1),s&&(t.docs.push(...s.docs),await(await De(e,{rootDir:t.outDir,integration:s.id,installDeps:!1})).commit(!1))}function Jt(e){return typeof e=="string"&&e.trim().length>0}function ie(e){return e.startsWith("~/")?(0,_.resolve)(Lt.default.homedir(),e):(0,_.resolve)(process.cwd(),e)}function as(){return cs()}function cs(){try{return process.cwd().startsWith("/home/projects/")}catch{}return!1}var Y=y(require("fs")),ru=require("path");async function ne(){Pe(`Let's create a ${fu(" Qwik App ")} \u2728 (v1.2.1)`),await It(500);let e="./qwik-app",t=await Te({message:`Where would you like to create your new project? ${T("(Use '.' or './' for current directory)")}`,placeholder:e})||e;N(t)&&(uu("Operation cancelled."),process.exit(0));let D=M(),r=(await K()).filter($=>$.type==="app"),i=r.find($=>$.id==="base"),u=r.filter($=>$.id!==i.id),n=Mt(D,i),a=ie(t.trim());B.info(`Creating new project in ${fu(" "+a+" ")} ... \u{1F407}`);let c=null;if(Y.default.existsSync(a)&&Y.default.readdirSync(a).length>0){let $=await qu({message:`Directory "./${(0,ru.relative)(process.cwd(),a)}" already exists and is not empty. What would you like to do?`,options:[{value:"exit",label:"Do not overwrite this directory and exit"},{value:"replace",label:"Remove contents of this directory"}]});(N($)||$==="exit")&&(uu("Operation cancelled."),process.exit(0)),$==="replace"&&(c=Y.default.promises.readdir(a).then(W=>Promise.all(W.map(Vt=>Y.default.promises.rm((0,ru.join)(a,Vt),{recursive:!0})))))}let p=await qu({message:"Select a starter",options:u.map($=>{var W;return{label:$.name,value:$.id,hint:(W=$.pkgJson)==null?void 0:W.description}})});N(p)&&(uu("Operation cancelled."),process.exit(0));let l=p,F=await Mu({message:`Would you like to install ${D} dependencies?`,initialValue:!0});N(F)&&(uu("Operation cancelled."),process.exit(0));let C=await Mu({message:"Initialize a new git repository?",initialValue:!0});c&&await c;let w=F;w||n.abort();let R={starterId:l,outDir:a},O=hu();O.start("Creating App...");let iu=await su(R);if(O.stop("App Created \u{1F430}"),C)if(Y.default.existsSync((0,ru.join)(a,".git")))B.info("Git has already been initialized before. Skipping...");else{O.start("Git initializing...");try{let $=[];if($.push(await G("git",["init"],a).install),$.push(await G("git",["add","-A"],a).install),$.push(await G("git",["commit","-m","Initial commit \u26A1\uFE0F"],a).install),$.some(W=>W===!1))throw"";O.stop("Git initialized \u{1F3B2}")}catch{O.stop("Git failed to initialize"),B.error(x("Git failed to initialize. You can do this manually by running: git init"))}}let H=!1;return w&&(O.start(`Installing ${D} dependencies...`),H=await n.complete(iu.outDir),H&&(H=await eu(D,iu.outDir).install),O.stop(`${H?"Installed":"Failed to install"} ${D} dependencies \u{1F4CB}`)),Pt(re(D,iu,H),"Result"),Wu("Happy coding! \u{1F407}"),iu}async function ls(){console.clear(),Tt(),ps();try{let e=process.argv.slice(2);e.length>=2?await se(e[0],e[1]):await ne()}catch(e){U(e.message||e)}}function ps(){let e=process.version,[t,D]=e.replace("v","").split(".");Number(t)<16?(console.error(x(`Qwik requires Node.js 16.8 or higher. You are currently running Node.js ${e}.`)),process.exit(1)):Number(t)===16?Number(D)<8&&console.warn(me(`Node.js 16.8 or higher is recommended. You are currently running Node.js ${e}.`)):Number(t)===18&&Number(D)<11&&console.error(x(`Node.js 18.11 or higher is REQUIRED. From Node 18.0.0 to 18.11.0, there is a bug preventing correct behaviour of Qwik. You are currently running Node.js ${e}. https://github.com/BuilderIO/qwik/issues/3035`))}0&&(module.exports={createApp,runCli,runCreateCli,runCreateInteractiveCli});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-qwik",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Interactive CLI for create Qwik projects and adding features.",
5
5
  "bin": "./create-qwik.cjs",
6
6
  "main": "./index.cjs",
@@ -11,7 +11,7 @@
11
11
  "skipFiles": ["<node_internals>/**"],
12
12
  "cwd": "${workspaceFolder}",
13
13
  "program": "${workspaceFolder}/node_modules/vite/bin/vite.js",
14
- "args": ["--mode", "ssr", "--force"],
15
- },
14
+ "args": ["--mode", "ssr", "--force"]
15
+ }
16
16
  ]
17
17
  }
@@ -13,21 +13,13 @@
13
13
  "scope": "javascriptreact,typescriptreact",
14
14
  "prefix": "qloader$",
15
15
  "description": "loader$()",
16
- "body": [
17
- "export const $1 = routeLoader$(() => {",
18
- " $0",
19
- "});"
20
- ]
16
+ "body": ["export const $1 = routeLoader$(() => {", " $0", "});"]
21
17
  },
22
18
  "action$": {
23
19
  "scope": "javascriptreact,typescriptreact",
24
20
  "prefix": "qaction$",
25
21
  "description": "action$()",
26
- "body": [
27
- "export const $1 = routeAction$((data) => {",
28
- " $0",
29
- "});"
30
- ]
22
+ "body": ["export const $1 = routeAction$((data) => {", " $0", "});"]
31
23
  },
32
24
  "Full Page": {
33
25
  "scope": "javascriptreact,typescriptreact",
@@ -36,9 +28,9 @@
36
28
  "body": [
37
29
  "import { component$ } from '@builder.io/qwik';",
38
30
  "",
39
- "export default component$(() => {",
40
- " $0",
41
- "});"
31
+ "export default component$(() => {",
32
+ " $0",
33
+ "});"
42
34
  ]
43
35
  }
44
36
  }
@@ -1,96 +1,78 @@
1
1
  {
2
- "Qwik component (simple)": {
3
- "scope": "javascriptreact,typescriptreact",
4
- "prefix": "qcomponent$",
5
- "description": "Simple Qwik component",
6
- "body": [
7
- "export const ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}} = component$(() => {",
8
- " return <${2:div}>$4</$2>",
9
- "});"
10
- ]
11
- },
12
- "Qwik component (props)": {
13
- "scope": "typescriptreact",
14
- "prefix": "qcomponent$ + props",
15
- "description": "Qwik component w/ props",
16
- "body": [
17
- "export interface ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}}Props {",
18
- " $2",
19
- "}",
20
- "",
21
- "export const $1 = component$<$1Props>((props) => {",
22
- " const ${2:count} = useSignal(0);",
23
- " return (",
24
- " <${3:div} on${4:Click}$={(ev) => {$5}}>",
25
- " $6",
26
- " </${3}>",
27
- " );",
28
- "});"
29
- ]
30
- },
31
- "Qwik signal": {
32
- "scope": "javascriptreact,typescriptreact",
33
- "prefix": "quseSignal",
34
- "description": "useSignal() declaration",
35
- "body": [
36
- "const ${1:foo} = useSignal($2);",
37
- "$0"
38
- ]
39
- },
40
- "Qwik store": {
41
- "scope": "javascriptreact,typescriptreact",
42
- "prefix": "quseStore",
43
- "description": "useStore() declaration",
44
- "body": [
45
- "const ${1:state} = useStore({",
46
- " $2",
47
- "});",
48
- "$0"
49
- ]
50
- },
51
- "$ hook": {
52
- "scope": "javascriptreact,typescriptreact",
53
- "prefix": "q$",
54
- "description": "$() function hook",
55
- "body": [
56
- "$(() => {",
57
- " $0",
58
- "});",
59
- ""
60
- ]
61
- },
62
- "useVisibleTask": {
63
- "scope": "javascriptreact,typescriptreact",
64
- "prefix": "quseVisibleTask",
65
- "description": "useVisibleTask$() function hook",
66
- "body": [
67
- "useVisibleTask$(({ track }) => {",
68
- " $0",
69
- "});",
70
- ""
71
- ]
72
- },
73
- "useTask": {
74
- "scope": "javascriptreact,typescriptreact",
75
- "prefix": "quseTask$",
76
- "description": "useTask$() function hook",
77
- "body": [
78
- "useTask$(({ track }) => {",
79
- " track(() => $1);",
80
- " $0",
81
- "});",
82
- ""
83
- ]
84
- },
85
- "useResource": {
86
- "scope": "javascriptreact,typescriptreact",
87
- "prefix": "quseResource$",
88
- "description": "useResource$() declaration",
89
- "body": [
90
- "const $1 = useResource$(({ track, cleanup }) => {",
91
- " $0",
92
- "});",
93
- ""
94
- ]
95
- }
96
- }
2
+ "Qwik component (simple)": {
3
+ "scope": "javascriptreact,typescriptreact",
4
+ "prefix": "qcomponent$",
5
+ "description": "Simple Qwik component",
6
+ "body": [
7
+ "export const ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}} = component$(() => {",
8
+ " return <${2:div}>$4</$2>",
9
+ "});"
10
+ ]
11
+ },
12
+ "Qwik component (props)": {
13
+ "scope": "typescriptreact",
14
+ "prefix": "qcomponent$ + props",
15
+ "description": "Qwik component w/ props",
16
+ "body": [
17
+ "export interface ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}}Props {",
18
+ " $2",
19
+ "}",
20
+ "",
21
+ "export const $1 = component$<$1Props>((props) => {",
22
+ " const ${2:count} = useSignal(0);",
23
+ " return (",
24
+ " <${3:div} on${4:Click}$={(ev) => {$5}}>",
25
+ " $6",
26
+ " </${3}>",
27
+ " );",
28
+ "});"
29
+ ]
30
+ },
31
+ "Qwik signal": {
32
+ "scope": "javascriptreact,typescriptreact",
33
+ "prefix": "quseSignal",
34
+ "description": "useSignal() declaration",
35
+ "body": ["const ${1:foo} = useSignal($2);", "$0"]
36
+ },
37
+ "Qwik store": {
38
+ "scope": "javascriptreact,typescriptreact",
39
+ "prefix": "quseStore",
40
+ "description": "useStore() declaration",
41
+ "body": ["const ${1:state} = useStore({", " $2", "});", "$0"]
42
+ },
43
+ "$ hook": {
44
+ "scope": "javascriptreact,typescriptreact",
45
+ "prefix": "q$",
46
+ "description": "$() function hook",
47
+ "body": ["$(() => {", " $0", "});", ""]
48
+ },
49
+ "useVisibleTask": {
50
+ "scope": "javascriptreact,typescriptreact",
51
+ "prefix": "quseVisibleTask",
52
+ "description": "useVisibleTask$() function hook",
53
+ "body": ["useVisibleTask$(({ track }) => {", " $0", "});", ""]
54
+ },
55
+ "useTask": {
56
+ "scope": "javascriptreact,typescriptreact",
57
+ "prefix": "quseTask$",
58
+ "description": "useTask$() function hook",
59
+ "body": [
60
+ "useTask$(({ track }) => {",
61
+ " track(() => $1);",
62
+ " $0",
63
+ "});",
64
+ ""
65
+ ]
66
+ },
67
+ "useResource": {
68
+ "scope": "javascriptreact,typescriptreact",
69
+ "prefix": "quseResource$",
70
+ "description": "useResource$() declaration",
71
+ "body": [
72
+ "const $1 = useResource$(({ track, cleanup }) => {",
73
+ " $0",
74
+ "});",
75
+ ""
76
+ ]
77
+ }
78
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "material-icon-theme.activeIconPack": "qwik"
3
- }
3
+ }
@@ -16,13 +16,13 @@
16
16
  "qwik": "qwik"
17
17
  },
18
18
  "devDependencies": {
19
- "@builder.io/qwik": "^1.2.0",
20
- "@builder.io/qwik-city": "^1.2.0",
19
+ "@builder.io/qwik": "^1.2.1",
20
+ "@builder.io/qwik-city": "^1.2.1",
21
21
  "@types/eslint": "8.40.2",
22
22
  "@types/node": "^20.3.1",
23
23
  "@typescript-eslint/eslint-plugin": "5.60.0",
24
24
  "@typescript-eslint/parser": "5.60.0",
25
- "eslint-plugin-qwik": "^1.2.0",
25
+ "eslint-plugin-qwik": "^1.2.1",
26
26
  "eslint": "8.43.0",
27
27
  "undici": "5.22.1",
28
28
  "prettier": "2.8.8",
@@ -32,7 +32,7 @@
32
32
  "release": "np"
33
33
  },
34
34
  "devDependencies": {
35
- "@builder.io/qwik": "1.2.0",
35
+ "@builder.io/qwik": "1.2.1",
36
36
  "@types/eslint": "8.40.2",
37
37
  "@types/node": "^20.3.1",
38
38
  "@typescript-eslint/eslint-plugin": "5.60.0",