create-psytask 1.1.2 → 1.2.0-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/README.md CHANGED
@@ -1,7 +1 @@
1
- # create-psytask
2
-
3
- ![NPM Version](https://img.shields.io/npm/v/create-psytask)
4
- ![NPM Downloads](https://img.shields.io/npm/dm/create-psytask)
5
- ![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hm/create-psytask)
6
-
7
- Create a new [psytask](https://github.com/bluebones-team/psytask) project.
1
+ A CLI to create [PsyTask](https://github.com/bluebonesx/psytask) project.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{confirm as p,isCancel as m,outro as d,select as v,text as f}from"@clack/prompts";import i from"node:fs/promises";import c from"node:path";var y=c.join(import.meta.dirname,"../template"),o=async(e)=>{let t=await e;if(m(t))process.exit(0);return t},u=async(e,t)=>{let a=await i.readFile(e,"utf-8"),s=t(a);await i.writeFile(e,s)};(async()=>{if(process.argv0!=="bun")console.warn("We only provide templates for bun temporarily, please change package.json scripts yourself.");let e=(await o(f({message:"Project name:",placeholder:"psytask-project",defaultValue:"psytask-project"}))).trim(),t=await o(p({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(),e);await i.access(s,i.constants.W_OK).then(async()=>{if(!await o(p({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(y,s,{recursive:!0});let r=c.join.bind(null,s),l=[u(r("package.json"),(n)=>JSON.stringify(Object.assign(JSON.parse(n),{name:e,scripts:a==="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:a==="vite"?"^7":void 0}}),null,2))];if(!t)l.push(u(r("index.html"),(n)=>n.replace("main.ts","main.js")),i.rename(r("main.ts"),r("main.js")),i.rename(r("tsconfig.json"),r("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 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)});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-psytask",
3
- "version": "1.1.2",
4
- "description": "CLI tool to create a new psytask project",
3
+ "version": "1.2.0-0",
4
+ "description": "CLI tool to create PsyTask project",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=22"
@@ -11,8 +11,13 @@
11
11
  },
12
12
  "files": [
13
13
  "dist",
14
- "template"
14
+ "template",
15
+ "README.md"
15
16
  ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/bluebonesx/psytask.git"
20
+ },
16
21
  "scripts": {
17
22
  "dev": "bun run build --watch",
18
23
  "build": "bun build index.ts --outfile=dist/index.js --target=node --external=@clack/prompts --banner='#!/usr/bin/env node' --production"
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Welcome to Psytask</title>
6
+ <title>Welcome to PsyTask</title>
7
7
  </head>
8
8
  <body>
9
9
  <script type="module" src="./main.ts"></script>
package/template/main.ts CHANGED
@@ -1,18 +1,36 @@
1
1
  import { createApp } from 'psytask';
2
- import 'psytask/main.css';
2
+ import { Container } from '@psytask/components';
3
+ import van from 'vanjs-core';
4
+
5
+ const { a, div } = van.tags;
3
6
 
4
7
  using app = await createApp();
5
8
  using dc = app.collector('demo.csv');
6
9
 
7
- using text = app.text('', { close_on: 'pointerup' });
10
+ using simpleText = app.scene(Container, {
11
+ defaultProps: { content: '' },
12
+ close_on: 'pointerup',
13
+ });
8
14
 
9
- await text.show({
10
- children: 'Welcome to the experiment! Click to continue.',
15
+ await simpleText.show({
16
+ content: div(
17
+ 'Welcome to PsyTask template!\nsee more ',
18
+ a(
19
+ { href: 'https://bluebonesx.github.io/psytask', target: '_blank' },
20
+ 'Information & Examples',
21
+ ),
22
+ '\n\nClick to continue.',
23
+ ),
11
24
  });
12
25
  for (let i = 0; i < 3; i++) {
13
- const { start_time } = await text.show({
14
- children: `This is trial ${i + 1}. Click to continue.`,
26
+ const { start_time } = await simpleText.show({
27
+ content: `This is trial ${i + 1}. Click to continue.`,
15
28
  });
16
29
 
17
30
  dc.add({ index: i + 1, start_time });
18
31
  }
32
+
33
+ // show data on page and download
34
+ document.body.style.whiteSpace = 'pre-wrap';
35
+ document.body.textContent = dc.final();
36
+ dc.download();
@@ -1,9 +1,12 @@
1
1
  {
2
- "name": "base",
2
+ "name": "template",
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "psytask": "^1"
7
+ "psytask": "^1",
8
+ "@psytask/components": "^1",
9
+ "@psytask/jspsych": "^1",
10
+ "vanjs-core": "^1"
8
11
  }
9
12
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  // environment
4
- "lib": ["DOM", "ES2022", "ESNext.Disposable"],
5
- "target": "es2022",
4
+ "lib": ["DOM", "ES2017", "ESNext.Disposable"],
5
+ "target": "es2017",
6
6
  "module": "esnext",
7
7
  "moduleDetection": "force",
8
8
  "jsx": "preserve",