create-psytask 1.2.0-1 → 1.2.0

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/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{confirm as u,isCancel as p,outro as d,select as v,text as w}from"@clack/prompts";import i from"node:fs/promises";import c from"node:path";var f=c.join(import.meta.dirname,"../template"),o=async(e)=>{let t=await e;if(p(t))process.exit(0);return t},m=async(e,t)=>{let r=await i.readFile(e,"utf-8"),s=t(r);await i.writeFile(e,s)};(async()=>{let e=(await o(w({message:"Project name:",placeholder:"psytask-project",defaultValue:"psytask-project"}))).trim(),t=await o(u({message:"Use TypeScript?",initialValue:!1})),r=await o(v({message:"Select a bundler:",options:[{value:"vite"},{value:"bun"}],initialValue:"vite"})),s=c.join(process.cwd(),e);await i.access(s,i.constants.W_OK).then(async()=>{if(!await o(u({message:"Directory already exists. Do you want to overwrite it?",initialValue:!1})))return;await i.rm(s,{recursive:!0,force:!0})},()=>i.mkdir(s,{recursive:!0})),await i.cp(f,s,{recursive:!0});let a=c.join.bind(null,s),l=[m(a("package.json"),(n)=>JSON.stringify(Object.assign(JSON.parse(n),{name:e,scripts:r==="bun"?{dev:"bun index.html",build:"bun build index.html --outdir=dist --production","type-check":t?"tsc --noEmit":void 0}:{dev:"vite",build:"vite build",preview:"vite preview","type-check":t?"tsc --noEmit":void 0},devDependencies:{typescript:t?"^5":void 0,vite:r==="vite"?"^7":void 0}}),null,2))];if(!t)l.push(m(a("index.html"),(n)=>n.replace("main.ts","main.js")),i.rename(a("main.ts"),a("main.js")),i.rename(a("tsconfig.json"),a("jsconfig.json")));await Promise.all(l),d(`Project created successfully: ${s}`)})().catch((e)=>{console.error(e),process.exit(1)});
2
+ import{confirm as u,isCancel as p,outro as d,select as v,text as w}from"@clack/prompts";import e from"node:fs/promises";import c from"node:path";var y=c.join(import.meta.dirname,"../template"),o=async(t)=>{let i=await t;if(p(i))process.exit(0);return i},m=async(t,i)=>{let a=await e.readFile(t,"utf-8"),s=i(a);await e.writeFile(t,s)};(async()=>{let t=(await o(w({message:"Project name:",placeholder:"psytask-project",defaultValue:"psytask-project"}))).trim(),i=await o(u({message:"Use TypeScript?",initialValue:!1})),a=await o(v({message:"Select a bundler:",options:[{value:"vite"},{value:"bun"}],initialValue:"vite"})),s=c.join(process.cwd(),t);await e.access(s,e.constants.W_OK).then(async()=>{if(!await o(u({message:"Directory already exists. Do you want to overwrite it?",initialValue:!1})))return;await e.rm(s,{recursive:!0,force:!0})},()=>e.mkdir(s,{recursive:!0})),await e.cp(y,s,{recursive:!0});let r=c.join.bind(null,s),l=[m(r("package.json"),(n)=>JSON.stringify(Object.assign(JSON.parse(n),{name:t,scripts:a==="bun"?{dev:"bun index.html",build:"bun build index.html --outdir=dist --production","type-check":i?"tsc --noEmit":void 0}:{dev:"vite",build:"vite build",preview:"vite preview","type-check":i?"tsc --noEmit":void 0},devDependencies:{typescript:i?"^5":void 0,vite:a==="vite"?"^7":void 0}}),null,2))];l.push(...i?[e.rm(r("main.js"))]:[m(r("index.html"),(n)=>n.replace("main.ts","main.js")),e.rm(r("main.ts")),e.rename(r("tsconfig.json"),r("jsconfig.json"))]),await Promise.all(l),d(`Project created successfully: ${s}`)})().catch((t)=>{console.error(t),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-psytask",
3
- "version": "1.2.0-1",
3
+ "version": "1.2.0",
4
4
  "description": "CLI tool to create PsyTask project",
5
5
  "type": "module",
6
6
  "engines": {
@@ -0,0 +1,37 @@
1
+ import { adapter } from '@psytask/components';
2
+ import { createApp } from 'psytask';
3
+ import van from 'vanjs-core';
4
+
5
+ const { a, div } = van.tags;
6
+
7
+ using app = await createApp();
8
+ using dc = app.collector('demo.csv');
9
+
10
+ using simpleText = app.scene(
11
+ /** @param {{ content: import('psytask').NodeLike }} props */
12
+ (props) => div({ class: 'psytask-center' }, () => props.content),
13
+ { defaultProps: { content: '' }, adapter },
14
+ );
15
+
16
+ await simpleText.show({
17
+ content: div(
18
+ 'Welcome to PsyTask template!\nsee more ',
19
+ a(
20
+ { href: 'https://bluebonesx.github.io/psytask/play/', target: '_blank' },
21
+ 'Information & Examples',
22
+ ),
23
+ '\n\nClick to continue.',
24
+ ),
25
+ });
26
+ for (let i = 0; i < 3; i++) {
27
+ const { frame_times } = await simpleText.show({
28
+ content: `This is trial ${i + 1}. Click to continue.`,
29
+ });
30
+
31
+ dc.add({ index: i + 1, start_time: /** @type {number} */ (frame_times[0]) });
32
+ }
33
+
34
+ // show data on page and download
35
+ document.body.style.whiteSpace = 'pre-wrap';
36
+ document.body.textContent = dc.final();
37
+ dc.download();