@upstart.gg/sdk 0.0.51
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/LICENSE +633 -0
- package/README.md +11 -0
- package/custom-attrs.d.ts +63 -0
- package/dist/node/cli/api.js +3 -0
- package/dist/node/cli/commands/build/cmd-build.js +3 -0
- package/dist/node/cli/commands/login/cmd-login.js +10 -0
- package/dist/node/cli/commands/logout/cmd-logout.js +3 -0
- package/dist/node/cli/commands/publish/cmd-publish.js +36 -0
- package/dist/node/cli/commands/publish/parse-gitignore.js +14 -0
- package/dist/node/cli/commands/publish/uploader.js +17 -0
- package/dist/node/cli/constants.js +2 -0
- package/dist/node/cli/program.js +48 -0
- package/dist/node/cli/store.js +3 -0
- package/dist/node/cli/types.js +1 -0
- package/dist/node/cli/utils.js +2 -0
- package/dist/node/metafile-esm.json +1 -0
- package/dist/node/shared/config.js +12 -0
- package/dist/node/shared/logger.js +3 -0
- package/dist/shared/ajv.d.ts +6 -0
- package/dist/shared/ajv.js +2 -0
- package/dist/shared/attributes.d.ts +102 -0
- package/dist/shared/attributes.js +2 -0
- package/dist/shared/bricks.d.ts +140 -0
- package/dist/shared/bricks.js +2 -0
- package/dist/shared/datasources/external/facebook/posts/fetcher.d.ts +16 -0
- package/dist/shared/datasources/external/facebook/posts/fetcher.js +2 -0
- package/dist/shared/datasources/external/facebook/posts/schema.d.ts +31 -0
- package/dist/shared/datasources/external/facebook/posts/schema.js +2 -0
- package/dist/shared/datasources/external/instagram/feed/fetcher.d.ts +16 -0
- package/dist/shared/datasources/external/instagram/feed/fetcher.js +2 -0
- package/dist/shared/datasources/external/instagram/feed/schema.d.ts +23 -0
- package/dist/shared/datasources/external/instagram/feed/schema.js +2 -0
- package/dist/shared/datasources/external/json/fetcher.d.ts +17 -0
- package/dist/shared/datasources/external/json/fetcher.js +2 -0
- package/dist/shared/datasources/external/json/options.d.ts +11 -0
- package/dist/shared/datasources/external/json/options.js +2 -0
- package/dist/shared/datasources/external/mastodon/account/fetcher.d.ts +15 -0
- package/dist/shared/datasources/external/mastodon/account/fetcher.js +2 -0
- package/dist/shared/datasources/external/mastodon/account/schema.d.ts +43 -0
- package/dist/shared/datasources/external/mastodon/account/schema.js +2 -0
- package/dist/shared/datasources/external/mastodon/options.d.ts +10 -0
- package/dist/shared/datasources/external/mastodon/options.js +2 -0
- package/dist/shared/datasources/external/mastodon/status/fetcher.d.ts +15 -0
- package/dist/shared/datasources/external/mastodon/status/fetcher.js +2 -0
- package/dist/shared/datasources/external/mastodon/status/sample.array.d.ts +53 -0
- package/dist/shared/datasources/external/mastodon/status/sample.array.js +2 -0
- package/dist/shared/datasources/external/mastodon/status/sample.single.d.ts +53 -0
- package/dist/shared/datasources/external/mastodon/status/sample.single.js +2 -0
- package/dist/shared/datasources/external/mastodon/status/schema.d.ts +261 -0
- package/dist/shared/datasources/external/mastodon/status/schema.js +2 -0
- package/dist/shared/datasources/external/meta/oauth/config.d.ts +21 -0
- package/dist/shared/datasources/external/meta/oauth/config.js +1 -0
- package/dist/shared/datasources/external/meta/options.d.ts +10 -0
- package/dist/shared/datasources/external/meta/options.js +2 -0
- package/dist/shared/datasources/external/rss/fetcher.d.ts +15 -0
- package/dist/shared/datasources/external/rss/fetcher.js +2 -0
- package/dist/shared/datasources/external/rss/options.d.ts +10 -0
- package/dist/shared/datasources/external/rss/options.js +2 -0
- package/dist/shared/datasources/external/rss/schema.d.ts +19 -0
- package/dist/shared/datasources/external/rss/schema.js +2 -0
- package/dist/shared/datasources/external/threads/media/fetcher.d.ts +19 -0
- package/dist/shared/datasources/external/threads/media/fetcher.js +2 -0
- package/dist/shared/datasources/external/threads/media/schema.d.ts +30 -0
- package/dist/shared/datasources/external/threads/media/schema.js +2 -0
- package/dist/shared/datasources/external/tiktok/oauth/config.d.ts +22 -0
- package/dist/shared/datasources/external/tiktok/oauth/config.js +1 -0
- package/dist/shared/datasources/external/tiktok/video/fetcher.d.ts +16 -0
- package/dist/shared/datasources/external/tiktok/video/fetcher.js +2 -0
- package/dist/shared/datasources/external/tiktok/video/options.d.ts +10 -0
- package/dist/shared/datasources/external/tiktok/video/options.js +2 -0
- package/dist/shared/datasources/external/tiktok/video/schema.d.ts +25 -0
- package/dist/shared/datasources/external/tiktok/video/schema.js +2 -0
- package/dist/shared/datasources/external/youtube/list/fetcher.d.ts +16 -0
- package/dist/shared/datasources/external/youtube/list/fetcher.js +2 -0
- package/dist/shared/datasources/external/youtube/list/options.d.ts +14 -0
- package/dist/shared/datasources/external/youtube/list/options.js +2 -0
- package/dist/shared/datasources/external/youtube/list/schema.d.ts +43 -0
- package/dist/shared/datasources/external/youtube/list/schema.js +2 -0
- package/dist/shared/datasources/external/youtube/oauth/config.d.ts +22 -0
- package/dist/shared/datasources/external/youtube/oauth/config.js +1 -0
- package/dist/shared/datasources/internal/contact-info/schema.d.ts +17 -0
- package/dist/shared/datasources/internal/contact-info/schema.js +2 -0
- package/dist/shared/datasources/internal/faq/schema.d.ts +12 -0
- package/dist/shared/datasources/internal/faq/schema.js +2 -0
- package/dist/shared/datasources/internal/links/schema.d.ts +12 -0
- package/dist/shared/datasources/internal/links/schema.js +2 -0
- package/dist/shared/datasources/samples.d.ts +13 -0
- package/dist/shared/datasources/samples.js +2 -0
- package/dist/shared/datasources/types.d.ts +9 -0
- package/dist/shared/datasources/types.js +2 -0
- package/dist/shared/datasources/utils.d.ts +3 -0
- package/dist/shared/datasources/utils.js +2 -0
- package/dist/shared/datasources-DAysbbXK.d.ts +201 -0
- package/dist/shared/datasources.d.ts +9 -0
- package/dist/shared/datasources.js +2 -0
- package/dist/shared/env.d.ts +27 -0
- package/dist/shared/env.js +1 -0
- package/dist/shared/errors.d.ts +1 -0
- package/dist/shared/errors.js +2 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.js +2 -0
- package/dist/shared/layout-constants.d.ts +20 -0
- package/dist/shared/layout-constants.js +2 -0
- package/dist/shared/manifest.d.ts +34 -0
- package/dist/shared/manifest.js +2 -0
- package/dist/shared/metafile-esm.json +1 -0
- package/dist/shared/page.d.ts +9 -0
- package/dist/shared/page.js +2 -0
- package/dist/shared/responsive.d.ts +6 -0
- package/dist/shared/responsive.js +2 -0
- package/dist/shared/social-icons.d.ts +6 -0
- package/dist/shared/social-icons.js +2 -0
- package/dist/shared/template-config.d.ts +9 -0
- package/dist/shared/template-config.js +1 -0
- package/dist/shared/theme.d.ts +37 -0
- package/dist/shared/theme.js +2 -0
- package/dist/shared/themes/all-themes.d.ts +6 -0
- package/dist/shared/themes/all-themes.js +2 -0
- package/dist/shared/themes/color-system.d.ts +323 -0
- package/dist/shared/themes/color-system.js +2 -0
- package/dist/shared/utils/invariant.d.ts +8 -0
- package/dist/shared/utils/invariant.js +2 -0
- package/dist/shared/utils/layout-utils.d.ts +24 -0
- package/dist/shared/utils/layout-utils.js +2 -0
- package/env.d.ts +24 -0
- package/package.json +162 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type {};
|
|
2
|
+
declare global {
|
|
3
|
+
type Boolish = boolean | "true" | "false" | "1" | "0" | "yes" | "no";
|
|
4
|
+
|
|
5
|
+
interface HTMLElement {
|
|
6
|
+
"ep-appear-animation"?: string;
|
|
7
|
+
"ep-appear-animation-duration"?: string;
|
|
8
|
+
"ep-hover-animation"?: string;
|
|
9
|
+
"ep-hover-animation-duration"?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Label for the element. Will be displayed to the user.
|
|
12
|
+
* If not provided, the element "id" will be used.
|
|
13
|
+
*/
|
|
14
|
+
"ep-label"?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A Boolean value indicating whether or not the direct children of the element can be **reordered**.
|
|
17
|
+
*/
|
|
18
|
+
"ep-allow-reorder"?: Boolish;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A Boolean value indicating whether or not its contents should be parsed by liquid.
|
|
22
|
+
*/
|
|
23
|
+
"ep-bind"?: Boolish;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A Boolean value indicating whether or not the element can be **duplicated**.
|
|
27
|
+
*/
|
|
28
|
+
"ep-allow-duplicate"?: Boolish;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A Boolean value indicating whether or not the element can be **deleted**.
|
|
32
|
+
*/
|
|
33
|
+
"ep-allow-delete"?: Boolish;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The type of the element. When not specified, the default value is "element".
|
|
37
|
+
*
|
|
38
|
+
* - A value of "page" indicates that the element is the uppermost container of the page.
|
|
39
|
+
* - A value of "element" indicates that the element is a regular element.
|
|
40
|
+
* - A value of "container" indicates that the element is a container.
|
|
41
|
+
*/
|
|
42
|
+
"ep-type"?: "page" | "element" | "container";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* **Enpage custom attribute**
|
|
46
|
+
*
|
|
47
|
+
* A Boolean value indicating whether or not the content of the element can be edited.
|
|
48
|
+
* When set to "plain-text", the content will be plain text. When set to "html", the content will be HTML.
|
|
49
|
+
* When set to true, the content will be plain text.
|
|
50
|
+
*/
|
|
51
|
+
"ep-text-editable"?: "plain" | "html" | boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* **Enpage custom attribute**
|
|
55
|
+
*
|
|
56
|
+
* Commas separated list of style properties that can be edited.
|
|
57
|
+
* When set to "all", all style properties can be edited.
|
|
58
|
+
* When set to "none", no style properties can be edited.
|
|
59
|
+
* When set to "default", the default style properties can be edited depending on the block type.
|
|
60
|
+
*/
|
|
61
|
+
"ep-style-props"?: string;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import{createLogger as h}from"vite";var g="0.0.51";import i from"chalk";function E(e,t,o=!1){let r=h(e==="debug"?"info":e,{prefix:"[enpage]",allowClearScreen:t});return o&&r.info(i.hex("#7270c6").bold(`\u{1F680} Enpage v${g}
|
|
3
|
+
`)),{...r,success:(s,n)=>r.info(i.green(s),n),error:(s,n)=>r.error(i.red(s),n),warn:(s,n)=>r.warn(i.yellow(s),n),warnOnce:(s,n)=>r.warnOnce(i.yellow(s),n),debug:(s,n)=>{e==="debug"&&r.info(i.gray(s),n)}}}var p=E();var m="enpage-cli";var I=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",u=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",A=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co";import _ from"conf";import c from"node:path";import T from"node:crypto";import a from"node:fs";import{fileURLToPath as x}from"node:url";import M from"chalk";var L=x(new URL(".",import.meta.url)),R=O(),d=new _({projectName:m,encryptionKey:R,clearInvalidConfig:!0});function k(){let e=L;for(;e!==c.parse(e).root;){let t=c.join(e,"node_modules");if(a.existsSync(t))return t;e=c.dirname(e)}return null}function O(){let e=k();if(!e)throw new Error("Could not find nearest node_modules directory.");let t=c.join(e,".enpage-tmp");a.existsSync(t)||a.mkdirSync(t,{recursive:!0,mode:448});let o=c.join(t,".enpage-key");if(!a.existsSync(o)){let s=T.randomBytes(32).toString("hex");return a.writeFileSync(o,s,{mode:384,flush:!0}),s}return a.readFileSync(o,"utf8")}async function J(e,t,o={}){d.get("access_token")&&(o.Authorization=`Bearer ${d.get("access_token")}`);let r=await fetch(l(e),{method:"POST",headers:{"Content-Type":t instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...o},body:t instanceof URLSearchParams?t:JSON.stringify(t)}).catch(s=>{p.error(`Fatal Error requesting API: ${s.message} (${s.cause.code})`),p.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return y(r)}async function K(e,t={}){d.get("access_token")&&(t.Authorization=`Bearer ${d.get("access_token")}`);let o=await fetch(l(e),{headers:t,method:"GET"}).catch(r=>{p.error(`Fatal Error requesting API: ${r.message} (${r.cause.code})`),p.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return y(o)}function l(e){let t=new URL(u.endsWith("/")?u:`${u}/`);return new URL(e,t)}async function y(e){let t=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:t}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:t}}export{K as get,J as post};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import{build as l}from"vite";import c,{resolve as o}from"node:path";import{fileURLToPath as s}from"node:url";import{sync as n}from"rimraf";var m=s(new URL(".",import.meta.url)),i=o(m,"../builder/vite-config.js"),a=o(m,"../builder/vite-entry-server.js");async function v({options:e,logger:r}){r.info(`Building template...
|
|
3
|
+
`),e.clean&&n(c.join(process.cwd(),"dist"));let t="production";e.ssr==="local"&&(t="development",process.env.NODE_ENV=t),e.ssr?(await l({configFile:i,customLogger:r,mode:t,logLevel:e.logLevel,clearScreen:e.clearScreen,build:{ssrManifest:!0,emptyOutDir:!0}}),await l({configFile:i,customLogger:r,mode:t,logLevel:e.logLevel,clearScreen:e.clearScreen,ssr:{target:"webworker"},build:{ssr:a}})):await l({configFile:i,customLogger:r,logLevel:e.logLevel,clearScreen:e.clearScreen,build:{emptyOutDir:!0}})}export{v as buildTemplate};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import I from"chalk";import{confirm as b}from"@inquirer/prompts";import A from"open";var y="enpage-cli";var g=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",u=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",j=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co";var _="oauth/devicecode",h="oauth/token";import{createLogger as x}from"vite";var E="0.0.51";import i from"chalk";function L(t,e,n=!1){let s=x(t==="debug"?"info":t,{prefix:"[enpage]",allowClearScreen:e});return n&&s.info(i.hex("#7270c6").bold(`\u{1F680} Enpage v${E}
|
|
3
|
+
`)),{...s,success:(r,o)=>s.info(i.green(r),o),error:(r,o)=>s.error(i.red(r),o),warn:(r,o)=>s.warn(i.yellow(r),o),warnOnce:(r,o)=>s.warnOnce(i.yellow(r),o),debug:(r,o)=>{t==="debug"&&s.info(i.gray(r),o)}}}var m=L();import v from"conf";import p from"node:path";import k from"node:crypto";import a from"node:fs";import{fileURLToPath as R}from"node:url";import Q from"chalk";var O=R(new URL(".",import.meta.url)),w=N(),c=new v({projectName:y,encryptionKey:w,clearInvalidConfig:!0});function P(){let t=O;for(;t!==p.parse(t).root;){let e=p.join(t,"node_modules");if(a.existsSync(e))return e;t=p.dirname(t)}return null}function N(){let t=P();if(!t)throw new Error("Could not find nearest node_modules directory.");let e=p.join(t,".enpage-tmp");a.existsSync(e)||a.mkdirSync(e,{recursive:!0,mode:448});let n=p.join(e,".enpage-key");if(!a.existsSync(n)){let r=k.randomBytes(32).toString("hex");return a.writeFileSync(n,r,{mode:384,flush:!0}),r}return a.readFileSync(n,"utf8")}async function l(t,e,n={}){c.get("access_token")&&(n.Authorization=`Bearer ${c.get("access_token")}`);let s=await fetch(S(t),{method:"POST",headers:{"Content-Type":e instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...n},body:e instanceof URLSearchParams?e:JSON.stringify(e)}).catch(r=>{m.error(`Fatal Error requesting API: ${r.message} (${r.cause.code})`),m.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return C(s)}function S(t){let e=new URL(u.endsWith("/")?u:`${u}/`);return new URL(t,e)}async function C(t){let e=t.headers.get("content-type")?.startsWith("application/json")?await t.json():await t.text();return t.ok?{isSuccess:!0,isError:!1,status:t.status,statusText:t.statusText,data:e}:{isSuccess:!1,isError:!0,status:t.status,statusText:t.statusText,data:e}}async function D(t,e){for(;;){let n=new URLSearchParams({grant_type:"device_code",device_code:t,client_id:g}),s=await l(h,n),{data:r,isSuccess:o}=s;if(o)return r;if(r.error==="authorization_pending")await new Promise(f=>setTimeout(f,5e3));else return e.error(`Error while polling for login: ${r.error_description??r.error}`),!1}}async function de({options:t,logger:e}){e.info(`Logging in to Enpage...
|
|
4
|
+
`);let{isError:n,data:s}=await l(_,{client_id:g,scope:"profile,templates:publish"});n&&(e.error("Failed to get device code. Please try again."),e.error(`Error: ${s.error_description??s.error}`),process.exit(1));let{verification_uri:r,device_code:o}=s;await b({message:"Would you like to open the login page in your browser?",default:!0}).catch(U=>{process.exit(0)})?A(r):e.info(`
|
|
5
|
+
Please visit the following URL to login:
|
|
6
|
+
${r}
|
|
7
|
+
`),e.info(I.gray(`
|
|
8
|
+
Waiting for login...
|
|
9
|
+
`));let d=await D(o,e);d||(e.error("Login failed. Please try again."),process.exit(1)),c.set({...d,...d.expires_in?{expires_at:Date.now()+d.expires_in*1e3}:{}}),e.info(`Login successful!
|
|
10
|
+
`),process.exitCode=0}export{de as login,D as pollForLogin};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
var i="enpage-cli";var d=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",N=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",g=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co";import p from"conf";import n from"node:path";import a from"node:crypto";import t from"node:fs";import{fileURLToPath as m}from"node:url";import S from"chalk";var _=m(new URL(".",import.meta.url)),u=E(),c=new p({projectName:i,encryptionKey:u,clearInvalidConfig:!0});function f(){let e=_;for(;e!==n.parse(e).root;){let o=n.join(e,"node_modules");if(t.existsSync(o))return o;e=n.dirname(e)}return null}function E(){let e=f();if(!e)throw new Error("Could not find nearest node_modules directory.");let o=n.join(e,".enpage-tmp");t.existsSync(o)||t.mkdirSync(o,{recursive:!0,mode:448});let r=n.join(o,".enpage-key");if(!t.existsSync(r)){let s=a.randomBytes(32).toString("hex");return t.writeFileSync(r,s,{mode:384,flush:!0}),s}return t.readFileSync(r,"utf8")}async function h({options:e,logger:o}){o.info("Logging out fom Enpage..."),c.clear(),o.info(`Done.
|
|
3
|
+
`),process.exit(0)}export{h as logout};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import{resolve as S}from"node:path";import{existsSync as D,readFileSync as ot,writeFileSync as st}from"node:fs";import P from"chalk";function I(){let e;if(process.env.npm_config_user_agent){let t=process.env.npm_config_user_agent.split(" ")[0];e=t.slice(0,t.lastIndexOf("/"))}return e||(console.log("Warning: could not detect package manager"),e="npm"),e}function B(e){return`[${e.error}]${e.error_description?`: ${e.error_description}`:""}`}var W="enpage-cli";var pt=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",w=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",ct=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co",H=10;var q="oauth/userinfo",J="v1/templates";import fe from"conf";import{createLogger as ge}from"vite";var V="0.0.51";import A from"chalk";function me(e,t,r=!1){let o=ge(e==="debug"?"info":e,{prefix:"[enpage]",allowClearScreen:t});return r&&o.info(A.hex("#7270c6").bold(`\u{1F680} Enpage v${V}
|
|
3
|
+
`)),{...o,success:(n,i)=>o.info(A.green(n),i),error:(n,i)=>o.error(A.red(n),i),warn:(n,i)=>o.warn(A.yellow(n),i),warnOnce:(n,i)=>o.warnOnce(A.yellow(n),i),debug:(n,i)=>{e==="debug"&&o.info(A.gray(n),i)}}}var g=me();async function F(e,t,r={}){E.get("access_token")&&(r.Authorization=`Bearer ${E.get("access_token")}`);let o=await fetch(K(e),{method:"POST",headers:{"Content-Type":t instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...r},body:t instanceof URLSearchParams?t:JSON.stringify(t)}).catch(n=>{g.error(`Fatal Error requesting API: ${n.message} (${n.cause.code})`),g.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return Y(o)}async function X(e,t={}){E.get("access_token")&&(t.Authorization=`Bearer ${E.get("access_token")}`);let r=await fetch(K(e),{headers:t,method:"GET"}).catch(o=>{g.error(`Fatal Error requesting API: ${o.message} (${o.cause.code})`),g.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return Y(r)}function K(e){let t=new URL(w.endsWith("/")?w:`${w}/`);return new URL(e,t)}async function Y(e){let t=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:t}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:t}}import U from"node:path";import ye from"node:crypto";import k from"node:fs";import{fileURLToPath as he}from"node:url";import Se from"chalk";var be=he(new URL(".",import.meta.url)),xe=Pe(),E=new fe({projectName:W,encryptionKey:xe,clearInvalidConfig:!0});async function Q(e=!1){let t=E.get("access_token"),r=E.get("expires_at");if(!t)return!1;if(r&&r<Date.now())return console.log("Seems like your token expired..."),!1;if(!e)return!0;let{isSuccess:o}=await X(q);return o}function Z(){let e=E.get("access_token");if(!e){let t=I();throw new Error(`Access token not found. Please run ${Se.cyan(`${t} run enpage:login`)} to authenticate.`)}return e}function Ee(){let e=be;for(;e!==U.parse(e).root;){let t=U.join(e,"node_modules");if(k.existsSync(t))return t;e=U.dirname(e)}return null}function Pe(){let e=Ee();if(!e)throw new Error("Could not find nearest node_modules directory.");let t=U.join(e,".enpage-tmp");k.existsSync(t)||k.mkdirSync(t,{recursive:!0,mode:448});let r=U.join(t,".enpage-key");if(!k.existsSync(r)){let n=ye.randomBytes(32).toString("hex");return k.writeFileSync(r,n,{mode:384,flush:!0}),n}return k.readFileSync(r,"utf8")}import N from"node:path";import j from"node:fs";import Ue from"node:crypto";import Ne from"fast-glob";import oe from"node:http";import je from"node:https";import{pipeline as De}from"node:stream";import re from"chalk";import Ie from"form-data";import*as G from"node:fs";var Oe=/[<>"|?*\n\r\t\f\x00-\x1F]/,we=/(?:^|\/)[*]{2}($|\/)/,ve=248,Te=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ae=e=>typeof e=="string"&&e.length<=ve&&!Oe.test(e),ke=e=>e.split(/\r\n?|\n/);var _e=e=>Te(e)&&Array.isArray(e.patterns)&&Array.isArray(e.sections);var M=(e,t={})=>{let r=t.path;if(_e(e))return e;Ae(e)&&G.existsSync(e)&&(r=e,e=G.readFileSync(e,"utf8"));let o=ke(e),n=new Map,i={sections:[],patterns:[]},p={name:"default",patterns:[]},s=null;for(let a of o){let c=a.trim();if(c.startsWith("#")){let[,u]=/^#+\s*(.*)\s*$/.exec(c)||[];if(s){n.delete(s.name),s.comment=s.comment?`${s.comment}
|
|
4
|
+
${c}`:c,s.name=u?`${s.name.trim()}
|
|
5
|
+
${u.trim()}`:s.name.trim(),n.set(s.name.toLowerCase().trim(),s);continue}p={name:u?.trim()||"",comment:c,patterns:[]},n.set(p.name.toLowerCase(),p),i.sections.push(p),s=p;continue}c!==""&&(p.patterns.push(c),i.patterns.push(c)),s=null}return(t.dedupe===!0||t.unique===!0)&&(i=ee(i,{...t,format:!1})),i.path=r,i.input=Buffer.from(e),i.format=a=>Ce(i,{...t,...a}),i.dedupe=a=>ee(i,{...t,...a}),i.globs=a=>$e(i,{path:r,...t,...a}),i};var ee=(e,t)=>{let r=M(e,{...t,dedupe:!1}),o=new Map,n={sections:[],patterns:[]},i;for(let p of r.sections){let{name:s="",comment:a,patterns:c}=p,u=s.trim().toLowerCase();for(let f of c)n.patterns.includes(f)||n.patterns.push(f);s&&o.has(u)?(i=o.get(u),i.patterns=[...i.patterns,...c]):(i={name:s,comment:a,patterns:c},n.sections.push(i),o.set(u,i))}for(let p of n.sections)p.patterns=[...new Set(p.patterns)];return n},Le=e=>{if(we.test(e))return e;let t=!1;return e.startsWith("/")?(e=e.slice(1),t=!0):e.slice(1,e.length-1).includes("/")&&(t=!0),e+=e.endsWith("/")?"**/":"/**",t?e:`**/${e}`},$e=(e,t={})=>{let r=M(e,t),o=[],n=0,i=r.patterns.concat(t.ignore||[]).concat((t.unignore||[]).map(s=>s.startsWith("!")?s:`!${s}`)),p=(s,a)=>{let c=o[o.length-1],u=s?"unignore":"ignore";c&&c.type===u?c.patterns.includes(a)||c.patterns.push(a):(o.push({type:u,path:t.path||null,patterns:[a],index:n}),n++)};for(let s of i){let a="";s.startsWith("!")&&(s=s.slice(1),a="!"),p(a,s.startsWith("/")?s.slice(1):s),p(a,Le(s))}return o},Re=(e={name:"",patterns:[]})=>{let t=[e.comment||""];return e.patterns?.length&&(t.push(e.patterns.join(`
|
|
6
|
+
`)),t.push("")),t.join(`
|
|
7
|
+
`)},Ce=(e,t={})=>{let r=M(e,t),o=t.formatSection||Re,n=r.sections||r,i=[];for(let p of[].concat(n))i.push(o(p));return i.join(`
|
|
8
|
+
`)};var te=M;import Fe from"p-queue";import Ge from"ora";import{customAlphabet as Me}from"nanoid";var _=class extends Error{constructor(r,o,n){super(`${r}: ${o}`);this.error=r;this.error_description=o;this.filename=n;this.name="UploadError"}},ze={maxDataSize:12*1024*1024,retryAttempts:2,retryDelay:1e3},Be=new oe.Agent({keepAlive:!0,maxSockets:10,keepAliveMsecs:3e3});async function We(e){let t=N.join(e,".gitignore"),o=j.existsSync(t)?te(j.readFileSync(t,"utf-8")).patterns:[];return Ne("**/*",{cwd:e,onlyFiles:!0,dot:!0,absolute:!0,ignore:["node_modules/**",".cache/**","**/.DS_Store",".gitignore",".env",".env.*",".git/**","dist/**",...o]})}async function He(e,t,r,o,n,i,p){let s=async a=>{try{return await qe(e,t,r,o,n,i,p)}catch(c){if(a<p.retryAttempts)return g.warn(`Retrying upload for ${t} (attempt ${a+1})`),await new Promise(u=>setTimeout(u,p.retryDelay)),s(a+1);throw c}};return s(0)}async function qe(e,t,r,o,n,i,p){return new Promise((s,a)=>{let c=j.statSync(e),u=N.basename(e),f=Date.now(),b=new Ie({maxDataSize:p.maxDataSize}),L=j.createReadStream(e),$=0,v=l=>{$+=l.length};L.on("data",v),b.append("file",L,{filename:u,knownLength:c.size});let T={agent:Be,method:"POST",headers:{authorization:`Bearer ${i}`,"x-enpage-template-file-path":t,"x-enpage-template-id":o,...b.getHeaders()}},O=(r.startsWith("https")?je:oe).request(r,T,l=>{let x="";l.on("data",R=>{x+=R}),l.on("end",()=>{let R=Date.now(),ue={fileName:u,fileSize:c.size,uploadDuration:R-f,statusCode:l.statusCode??0,serverResponse:x};if(l.statusCode&&l.statusCode>=200&&l.statusCode<300)n.text=`Uploaded ${t}`,s(ue);else{let C;if(l.headers["content-type"]?.startsWith("application/json")){let z=JSON.parse(x);C=new _(z.error||"unknown_error",z.error_description||"Unknown error occurred",t)}else C=new _("unknown_error",x||"Unknown error occurred",t);n.fail(`Failed to upload ${t} [${C.error}] ${C.error_description}`),a(C)}})});O.on("error",l=>{a(new _("request_error",l.message,t))}),De(b,O,l=>{l&&a(new _("pipeline_error",`Pipeline failed for ${u}: ${l.message}`,t))})})}function Je(e,t,r){r.length>0?(g.error(re.red(`Failed to upload ${r.length} files:`)),r.forEach(o=>{let n=o.reason;g.error(`- ${n.filename}: ${n.error_description} (${n.error})`)})):g.info(re.green(`Uploaded ${t.length} files successfully for template ${e}.
|
|
9
|
+
`))}async function se(e,t,r,o=!1,n={}){let i={...ze,...n},p=new Fe({concurrency:H}),s=await We(t),a=s.length,c={},u=Xe(),f=0;for(let d of s){let O=N.relative(t,d),l=await Ve(d);c[O]=l}o&&(g.info(`Dry run mode enabled. Skipping upload.
|
|
10
|
+
`),g.info("The following files would have been uploaded:"),s.forEach(d=>g.info(`- ${d}`)),process.exit(0));let b=Ge(`Uploading ${a} files...`).start(),L=s.map(d=>{let O=N.resolve(t,d),l=N.relative(t,d),x=`${w}/v1/templates/${e}/upload/${u}`;return p.add(async()=>{let R=await He(O,l,x,e,b,r,i);return f++,R})}),$=await Promise.allSettled(L);b.stop();let v=$.filter(d=>d.status==="fulfilled"),T=$.filter(d=>d.status==="rejected");if(Je(e,v.map(d=>d.value),T),!T.length&&v.length){let d=`${w}/v1/templates/${e}/upload/${u}/finalize`,l=await F(d,{signatures:c});if(l.isError)return g.error(`Failed to finalize upload: ${l.data.error_description} (${l.data.error})`),{filesCount:a,uploadedFiles:v.map(x=>x.value),failedFiles:[],success:!1}}return{filesCount:a,uploadedFiles:v.map(d=>d.value),failedFiles:T,success:T.length===0}}async function Ve(e){let t=await Ue.subtle.digest("SHA-1",j.readFileSync(e));return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Xe(){let e=Me("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",5),t=new Date,r=t.getUTCFullYear(),o=(t.getUTCMonth()+1).toString().padStart(2,"0"),n=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),p=t.getUTCMinutes().toString().padStart(2,"0"),s=t.getUTCSeconds().toString().padStart(2,"0");return`${r}${o}${n}${i}${p}${s}_${e()}`}import le from"node:path";import y from"zod";var ne=y.object({id:y.string().optional(),name:y.string(),description:y.string(),readme:y.record(y.string()).optional(),tags:y.array(y.string()).optional(),author:y.string(),thumbnail:y.string().url().optional(),homepage:y.string().url().optional()});import{Type as m}from"@sinclair/typebox";import{Value as Qt}from"@sinclair/typebox/value";function ie(e){for(let t in e)if(t.startsWith("$"))throw new Error(`Attribute names starting with '$' (like "${t}") are reserved for internal use. Please rename it.`);return m.Object({...Ke,...e},{$id:"attributes"})}var h={string(e,t="",r){return m.String({title:e,default:t,...r})},number(e,t=0,r){return m.Number({title:e,default:t,...r})},boolean(e,t=!1,r){let o={"ui:field":"switch"};return m.Boolean({title:e,default:t,...o,...r})},enum(e,t,r){let o={"ui:field":"enum","ui:display":r.displayAs||"select"},{options:n,displayAs:i,...p}=r;return m.Union(n.map(s=>m.Literal(typeof s=="string"?s:s.value,{title:typeof s=="string"?s:s.title,"ui:icon":typeof s=="string"?void 0:s.icon})),{title:e,default:t,...o,...p})},file(e,t="",r={}){return m.String({title:e,default:t,...r,format:"data-url"})},url(e,t="",r={}){return m.String({title:e,default:t,...r,format:"uri"})},color(e,t="",r){let o={"ui:field":"color"};return m.String({title:e,default:t,...o,...r})},date(e,t=new Date,r={}){return m.String({title:e,default:t.toISOString(),...r,format:"date"})},datetime(e,t=new Date,r={}){return m.String({title:e,default:t.toISOString(),...r,format:"date-time"})},geolocation(e,t,r={}){return m.Object({lat:m.Number({minimum:-90,maximum:90}),lng:m.Number({minimum:-180,maximum:180}),name:m.Optional(m.String({title:"Name"}))},{title:e,default:t,...r})}},Ke={$pageLanguage:h.enum("Page language","en",{options:[{value:"ar",title:"Arabic"},{value:"zh",title:"Chinese"},{value:"cs",title:"Czech"},{value:"nl",title:"Dutch"},{value:"en",title:"English"},{value:"fr",title:"French"},{value:"de",title:"German"},{value:"he",title:"Hebrew"},{value:"hi",title:"Hindi"},{value:"it",title:"Italian"},{value:"ja",title:"Japanese"},{value:"ko",title:"Korean"},{value:"fa",title:"Persian"},{value:"pl",title:"Polish"},{value:"pt",title:"Portuguese"},{value:"ru",title:"Russian"},{value:"es",title:"Spanish"},{value:"tr",title:"Turkish"},{value:"vi",title:"Vietnamese"}],"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pagePath:h.string("Page path","/",{description:"The URL path of the page","ui:group":"location","ui:group:title":"Location","ui:group:order":1,"ui:field":"path"}),$pageTitle:h.string("Page title","Untitled",{"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageDescription:h.string("Page description","",{"ui:widget":"textarea","ui:options":{rows:3,widget:"textarea"},"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageKeywords:h.string("Page keywords","",{"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageLastUpdated:h.datetime("Last updated",void 0,{"ui:hidden":!0}),$pageWidth:h.enum("Page width","max-w-screen-2xl",{options:[{value:"max-w-screen-lg",title:"M",description:"Common for text-heavy content/blog posts"},{value:"max-w-screen-xl",title:"L",description:"Usefull or some landing pages"},{value:"max-w-screen-2xl",title:"XL",description:"Common width"},{value:"max-w-full",title:"Full",description:"Takes the entire space"}],description:"The maximum width of the page. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$pagePaddingVertical:h.enum("Page vertical spacing","20",{options:[{value:"0",title:"None"},{value:"10",title:"S"},{value:"20",title:"M"},{value:"30",title:"L"},{value:"50",title:"XL"}],description:"Vertical spacing. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$pagePaddingHorizontal:h.enum("Page horizontal spacing","20",{options:[{value:"0",title:"None"},{value:"10",title:"S"},{value:"20",title:"M"},{value:"30",title:"L"},{value:"50",title:"XL"}],description:"Horizontal spacing. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$backgroundColor:h.color("Page background color","#ffffff",{"ui:field":"color","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$textColor:h.color("Default text color","#222222",{"ui:field":"color","ui:group":"layout","ui:group:title":"Page Layout & Design","ui:color-type":"page-text"})};import Ye from"node:fs";import{readFile as Qe}from"node:fs/promises";import Ze from"fast-glob";import{fromError as et}from"zod-validation-error";import{basename as ae,dirname as tt,extname as rt}from"node:path";async function pe(e,t=g){Ye.existsSync(e)||(t.error(`\u{1F534} No enpage.config.js found!
|
|
11
|
+
Your project must have an enpage.config.js file in the root directory.
|
|
12
|
+
|
|
13
|
+
`),process.exit(1));let r=await import(e),o=tt(e),n={},i=await Ze(["README.enpage.md","README.enpage.*.md"],{cwd:o,onlyFiles:!0,absolute:!0,caseSensitiveMatch:!1});for(let p of i){let s=ae(p,".md"),a=rt(s),c=(a===".enpage"?"en":a.substring(1)).toLowerCase();t.debug(`Found template readme file (${c}): ${ae(p)}`),n[c]=await Qe(p,"utf-8")}return r.manifest.readme=n,r}function ce(e,t){for(let o in e.datasources)!(e.datasources[o].provider||e.datasources[o].provider==="json")&&!e.datasources[o].sampleData&&(t.error(`\u{1F534} Error: Datasource "${o}" is missing sample data - nothing will be rendered during development! Please check your enpage.config.js file and add a "sampleData" key to your ${o} datasource.`),process.exit(1));e.attributes||(e.attributes=ie({}));let r=ne.safeParse(e.manifest);if(!r.success){t.error(`\u{1F534} Error: template manifest is invalid. Check your call to defineManifest().
|
|
14
|
+
`);let o=et(r.error);t.error(`Hint: ${o.toString()}
|
|
15
|
+
|
|
16
|
+
`),process.exit(1)}return e}async function br({options:e,args:t,logger:r}){if(!await Q(!0)){let f=I();r.error(` ${P.redBright("Error")}: User token not found. Please run ${P.cyan(`${f} run enpage:login`)} to authenticate or set the ${P.cyan("ENPAGE_API_TOKEN")} environment variable.
|
|
17
|
+
`),process.exit(1)}let o=t.length?le.isAbsolute(t[0])?t[0]:S(process.cwd(),t[0]):process.cwd();D(o)||(r.error(` Template directory not found: ${o}. Aborting.
|
|
18
|
+
`),process.exit(1));let n=t.length>1?le.isAbsolute(t[1])?t[1]:S(process.cwd(),t[1]):S(o,"dist");D(n)||(r.error(` Dist directory not found: ${n}.
|
|
19
|
+
Please run 'build' before publishing. Aborting.
|
|
20
|
+
`),process.exit(1)),D(S(o,"enpage.config.js"))||(r.error(` ${P.redBright("Error")}: file enpage.config.js not found in ${o}. Aborting.
|
|
21
|
+
`),process.exit(1));let i=await pe(S(o,"enpage.config.js"),r);ce(i,r);let p=Z(),s=nt(o);s||(r.error(` ${P.redBright("Error")}: package.json file not found in ${o}. Aborting.
|
|
22
|
+
`),process.exit(1));let a=await it(s);if(a||(r.error(` ${P.redBright("Error")}: cannot read/parse package.json file in ${o}. Aborting.
|
|
23
|
+
`),process.exit(1)),!a.enpage?.id){let{data:f,isError:b,status:L}=await F(J,{manifest:i.manifest});b&&(r.error(` ${P.redBright("Error")}: Cannot register template: ${B(f)}
|
|
24
|
+
`),process.exit(1)),a.enpage??={},a.enpage.id=f.template.id;try{e.dryRun||st(s,JSON.stringify(a,null,2))}catch{r.error(` ${P.redBright("Error")}: Cannot update template id in package.json file located in ${o}. Aborting.
|
|
25
|
+
`),process.exit(1)}}let c=a.enpage.id;r.info(`Submitting template to Enpage...
|
|
26
|
+
`),(await se(c,o,p,e.dryRun)).success||(r.error(`
|
|
27
|
+
Upload failed. See details above.
|
|
28
|
+
`),process.exit(1)),r.success(`Template ${c} published.
|
|
29
|
+
`)}function nt(e){return D(S(e,"package.json"))?S(e,"package.json"):D(S(e,"template-package.json"))?S(e,"template-package.json"):!1}function it(e){try{return JSON.parse(ot(e,"utf-8"))}catch{return null}}export{br as publish};
|
|
30
|
+
/*!
|
|
31
|
+
* parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>
|
|
32
|
+
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
33
|
+
* Released under the MIT License.
|
|
34
|
+
*
|
|
35
|
+
* Converted to typescript by Matthias E. <matthias@enpage.co>
|
|
36
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import*as p from"node:fs";var h=/[<>"|?*\n\r\t\f\x00-\x1F]/,P=/(?:^|\/)[*]{2}($|\/)/,G=248,S=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),y=t=>typeof t=="string"&&t.length<=G&&!h.test(t),d=t=>t.split(/\r\n?|\n/),b=t=>t.startsWith("#"),O=t=>S(t)&&Array.isArray(t.patterns)&&Array.isArray(t.sections),$=t=>d(t).map(e=>e.trim()).filter(e=>e!==""&&!b(e)),u=(t,e={})=>{let l=e.path;if(O(t))return t;y(t)&&p.existsSync(t)&&(l=t,t=p.readFileSync(t,"utf8"));let c=d(t),a=new Map,n={sections:[],patterns:[]},o={name:"default",patterns:[]},s=null;for(let r of c){let i=r.trim();if(i.startsWith("#")){let[,g]=/^#+\s*(.*)\s*$/.exec(i)||[];if(s){a.delete(s.name),s.comment=s.comment?`${s.comment}
|
|
3
|
+
${i}`:i,s.name=g?`${s.name.trim()}
|
|
4
|
+
${g.trim()}`:s.name.trim(),a.set(s.name.toLowerCase().trim(),s);continue}o={name:g?.trim()||"",comment:i,patterns:[]},a.set(o.name.toLowerCase(),o),n.sections.push(o),s=o;continue}i!==""&&(o.patterns.push(i),n.patterns.push(i)),s=null}return(e.dedupe===!0||e.unique===!0)&&(n=m(n,{...e,format:!1})),n.path=l,n.input=Buffer.from(t),n.format=r=>x(n,{...e,...r}),n.dedupe=r=>m(n,{...e,...r}),n.globs=r=>A(n,{path:l,...e,...r}),n},k=(t,e)=>u(p.readFileSync(t,"utf8"),e),m=(t,e)=>{let l=u(t,{...e,dedupe:!1}),c=new Map,a={sections:[],patterns:[]},n;for(let o of l.sections){let{name:s="",comment:r,patterns:i}=o,g=s.trim().toLowerCase();for(let f of i)a.patterns.includes(f)||a.patterns.push(f);s&&c.has(g)?(n=c.get(g),n.patterns=[...n.patterns,...i]):(n={name:s,comment:r,patterns:i},a.sections.push(n),c.set(g,n))}for(let o of a.sections)o.patterns=[...new Set(o.patterns)];return a},w=t=>{if(P.test(t))return t;let e=!1;return t.startsWith("/")?(t=t.slice(1),e=!0):t.slice(1,t.length-1).includes("/")&&(e=!0),t+=t.endsWith("/")?"**/":"/**",e?t:`**/${t}`},A=(t,e={})=>{let l=u(t,e),c=[],a=0,n=l.patterns.concat(e.ignore||[]).concat((e.unignore||[]).map(s=>s.startsWith("!")?s:`!${s}`)),o=(s,r)=>{let i=c[c.length-1],g=s?"unignore":"ignore";i&&i.type===g?i.patterns.includes(r)||i.patterns.push(r):(c.push({type:g,path:e.path||null,patterns:[r],index:a}),a++)};for(let s of n){let r="";s.startsWith("!")&&(s=s.slice(1),r="!"),o(r,s.startsWith("/")?s.slice(1):s),o(r,w(s))}return c},R=(t={name:"",patterns:[]})=>{let e=[t.comment||""];return t.patterns?.length&&(e.push(t.patterns.join(`
|
|
5
|
+
`)),e.push("")),e.join(`
|
|
6
|
+
`)},x=(t,e={})=>{let l=u(t,e),c=e.formatSection||R,a=l.sections||l,n=[];for(let o of[].concat(a))n.push(c(o));return n.join(`
|
|
7
|
+
`)};var W=u;export{m as dedupe,W as default,x as format,R as formatSection,A as globs,u as parse,k as parseFile,$ as patterns};
|
|
8
|
+
/*!
|
|
9
|
+
* parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>
|
|
10
|
+
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
11
|
+
* Released under the MIT License.
|
|
12
|
+
*
|
|
13
|
+
* Converted to typescript by Matthias E. <matthias@enpage.co>
|
|
14
|
+
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import O from"node:path";import U from"node:fs";import ge from"node:crypto";import me from"fast-glob";var N="enpage-cli";var be=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",y=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",ke=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co",I=10;import B from"node:http";import fe from"node:https";import{pipeline as ye}from"node:stream";import{createLogger as q}from"vite";var D="0.0.51";import _ from"chalk";function H(e,t,n=!1){let i=q(e==="debug"?"info":e,{prefix:"[enpage]",allowClearScreen:t});return n&&i.info(_.hex("#7270c6").bold(`\u{1F680} Enpage v${D}
|
|
3
|
+
`)),{...i,success:(s,r)=>i.info(_.green(s),r),error:(s,r)=>i.error(_.red(s),r),warn:(s,r)=>i.warn(_.yellow(s),r),warnOnce:(s,r)=>i.warnOnce(_.yellow(s),r),debug:(s,r)=>{e==="debug"&&i.info(_.gray(s),r)}}}var g=H();import z from"chalk";import he from"form-data";import*as A from"node:fs";var X=/[<>"|?*\n\r\t\f\x00-\x1F]/,J=/(?:^|\/)[*]{2}($|\/)/,V=248,K=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Y=e=>typeof e=="string"&&e.length<=V&&!X.test(e),Q=e=>e.split(/\r\n?|\n/);var Z=e=>K(e)&&Array.isArray(e.patterns)&&Array.isArray(e.sections);var C=(e,t={})=>{let n=t.path;if(Z(e))return e;Y(e)&&A.existsSync(e)&&(n=e,e=A.readFileSync(e,"utf8"));let i=Q(e),s=new Map,r={sections:[],patterns:[]},c={name:"default",patterns:[]},o=null;for(let a of i){let p=a.trim();if(p.startsWith("#")){let[,u]=/^#+\s*(.*)\s*$/.exec(p)||[];if(o){s.delete(o.name),o.comment=o.comment?`${o.comment}
|
|
4
|
+
${p}`:p,o.name=u?`${o.name.trim()}
|
|
5
|
+
${u.trim()}`:o.name.trim(),s.set(o.name.toLowerCase().trim(),o);continue}c={name:u?.trim()||"",comment:p,patterns:[]},s.set(c.name.toLowerCase(),c),r.sections.push(c),o=c;continue}p!==""&&(c.patterns.push(p),r.patterns.push(p)),o=null}return(t.dedupe===!0||t.unique===!0)&&(r=G(r,{...t,format:!1})),r.path=n,r.input=Buffer.from(e),r.format=a=>re(r,{...t,...a}),r.dedupe=a=>G(r,{...t,...a}),r.globs=a=>te(r,{path:n,...t,...a}),r};var G=(e,t)=>{let n=C(e,{...t,dedupe:!1}),i=new Map,s={sections:[],patterns:[]},r;for(let c of n.sections){let{name:o="",comment:a,patterns:p}=c,u=o.trim().toLowerCase();for(let h of p)s.patterns.includes(h)||s.patterns.push(h);o&&i.has(u)?(r=i.get(u),r.patterns=[...r.patterns,...p]):(r={name:o,comment:a,patterns:p},s.sections.push(r),i.set(u,r))}for(let c of s.sections)c.patterns=[...new Set(c.patterns)];return s},ee=e=>{if(J.test(e))return e;let t=!1;return e.startsWith("/")?(e=e.slice(1),t=!0):e.slice(1,e.length-1).includes("/")&&(t=!0),e+=e.endsWith("/")?"**/":"/**",t?e:`**/${e}`},te=(e,t={})=>{let n=C(e,t),i=[],s=0,r=n.patterns.concat(t.ignore||[]).concat((t.unignore||[]).map(o=>o.startsWith("!")?o:`!${o}`)),c=(o,a)=>{let p=i[i.length-1],u=o?"unignore":"ignore";p&&p.type===u?p.patterns.includes(a)||p.patterns.push(a):(i.push({type:u,path:t.path||null,patterns:[a],index:s}),s++)};for(let o of r){let a="";o.startsWith("!")&&(o=o.slice(1),a="!"),c(a,o.startsWith("/")?o.slice(1):o),c(a,ee(o))}return i},se=(e={name:"",patterns:[]})=>{let t=[e.comment||""];return e.patterns?.length&&(t.push(e.patterns.join(`
|
|
6
|
+
`)),t.push("")),t.join(`
|
|
7
|
+
`)},re=(e,t={})=>{let n=C(e,t),i=t.formatSection||se,s=n.sections||n,r=[];for(let c of[].concat(s))r.push(i(c));return r.join(`
|
|
8
|
+
`)};var j=C;import Se from"p-queue";import Ee from"ora";import{customAlphabet as Pe}from"nanoid";import oe from"conf";import L from"node:path";import ne from"node:crypto";import w from"node:fs";import{fileURLToPath as ie}from"node:url";import He from"chalk";var ae=ie(new URL(".",import.meta.url)),ce=le(),v=new oe({projectName:N,encryptionKey:ce,clearInvalidConfig:!0});function pe(){let e=ae;for(;e!==L.parse(e).root;){let t=L.join(e,"node_modules");if(w.existsSync(t))return t;e=L.dirname(e)}return null}function le(){let e=pe();if(!e)throw new Error("Could not find nearest node_modules directory.");let t=L.join(e,".enpage-tmp");w.existsSync(t)||w.mkdirSync(t,{recursive:!0,mode:448});let n=L.join(t,".enpage-key");if(!w.existsSync(n)){let s=ne.randomBytes(32).toString("hex");return w.writeFileSync(n,s,{mode:384,flush:!0}),s}return w.readFileSync(n,"utf8")}async function F(e,t,n={}){v.get("access_token")&&(n.Authorization=`Bearer ${v.get("access_token")}`);let i=await fetch(ue(e),{method:"POST",headers:{"Content-Type":t instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...n},body:t instanceof URLSearchParams?t:JSON.stringify(t)}).catch(s=>{g.error(`Fatal Error requesting API: ${s.message} (${s.cause.code})`),g.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return de(i)}function ue(e){let t=new URL(y.endsWith("/")?y:`${y}/`);return new URL(e,t)}async function de(e){let t=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:t}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:t}}var x=class extends Error{constructor(n,i,s){super(`${n}: ${i}`);this.error=n;this.error_description=i;this.filename=s;this.name="UploadError"}},_e={maxDataSize:12*1024*1024,retryAttempts:2,retryDelay:1e3},we=new B.Agent({keepAlive:!0,maxSockets:10,keepAliveMsecs:3e3});async function xe(e){let t=O.join(e,".gitignore"),i=U.existsSync(t)?j(U.readFileSync(t,"utf-8")).patterns:[];return me("**/*",{cwd:e,onlyFiles:!0,dot:!0,absolute:!0,ignore:["node_modules/**",".cache/**","**/.DS_Store",".gitignore",".env",".env.*",".git/**","dist/**",...i]})}async function Te(e,t,n,i,s,r,c){let o=async a=>{try{return await Re(e,t,n,i,s,r,c)}catch(p){if(a<c.retryAttempts)return g.warn(`Retrying upload for ${t} (attempt ${a+1})`),await new Promise(u=>setTimeout(u,c.retryDelay)),o(a+1);throw p}};return o(0)}async function Re(e,t,n,i,s,r,c){return new Promise((o,a)=>{let p=U.statSync(e),u=O.basename(e),h=Date.now(),S=new he({maxDataSize:c.maxDataSize}),b=U.createReadStream(e),k=0,E=l=>{k+=l.length};b.on("data",E),S.append("file",b,{filename:u,knownLength:p.size});let P={agent:we,method:"POST",headers:{authorization:`Bearer ${r}`,"x-enpage-template-file-path":t,"x-enpage-template-id":i,...S.getHeaders()}},f=(n.startsWith("https")?fe:B).request(n,P,l=>{let m="";l.on("data",T=>{m+=T}),l.on("end",()=>{let T=Date.now(),W={fileName:u,fileSize:p.size,uploadDuration:T-h,statusCode:l.statusCode??0,serverResponse:m};if(l.statusCode&&l.statusCode>=200&&l.statusCode<300)s.text=`Uploaded ${t}`,o(W);else{let R;if(l.headers["content-type"]?.startsWith("application/json")){let $=JSON.parse(m);R=new x($.error||"unknown_error",$.error_description||"Unknown error occurred",t)}else R=new x("unknown_error",m||"Unknown error occurred",t);s.fail(`Failed to upload ${t} [${R.error}] ${R.error_description}`),a(R)}})});f.on("error",l=>{a(new x("request_error",l.message,t))}),ye(S,f,l=>{l&&a(new x("pipeline_error",`Pipeline failed for ${u}: ${l.message}`,t))})})}function Le(e,t,n){n.length>0?(g.error(z.red(`Failed to upload ${n.length} files:`)),n.forEach(i=>{let s=i.reason;g.error(`- ${s.filename}: ${s.error_description} (${s.error})`)})):g.info(z.green(`Uploaded ${t.length} files successfully for template ${e}.
|
|
9
|
+
`))}async function mt(e,t,n,i=!1,s={}){let r={..._e,...s},c=new Se({concurrency:I}),o=await xe(t),a=o.length,p={},u=Ue(),h=0;for(let d of o){let f=O.relative(t,d),l=await Oe(d);p[f]=l}i&&(g.info(`Dry run mode enabled. Skipping upload.
|
|
10
|
+
`),g.info("The following files would have been uploaded:"),o.forEach(d=>g.info(`- ${d}`)),process.exit(0));let S=Ee(`Uploading ${a} files...`).start(),b=o.map(d=>{let f=O.resolve(t,d),l=O.relative(t,d),m=`${y}/v1/templates/${e}/upload/${u}`;return c.add(async()=>{let T=await Te(f,l,m,e,S,n,r);return h++,T})}),k=await Promise.allSettled(b);S.stop();let E=k.filter(d=>d.status==="fulfilled"),P=k.filter(d=>d.status==="rejected");if(Le(e,E.map(d=>d.value),P),!P.length&&E.length){let d=`${y}/v1/templates/${e}/upload/${u}/finalize`,l=await F(d,{signatures:p});if(l.isError)return g.error(`Failed to finalize upload: ${l.data.error_description} (${l.data.error})`),{filesCount:a,uploadedFiles:E.map(m=>m.value),failedFiles:[],success:!1}}return{filesCount:a,uploadedFiles:E.map(d=>d.value),failedFiles:P,success:P.length===0}}async function Oe(e){let t=await ge.subtle.digest("SHA-1",U.readFileSync(e));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}function Ue(){let e=Pe("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",5),t=new Date,n=t.getUTCFullYear(),i=(t.getUTCMonth()+1).toString().padStart(2,"0"),s=t.getUTCDate().toString().padStart(2,"0"),r=t.getUTCHours().toString().padStart(2,"0"),c=t.getUTCMinutes().toString().padStart(2,"0"),o=t.getUTCSeconds().toString().padStart(2,"0");return`${n}${i}${s}${r}${c}${o}_${e()}`}export{mt as uploadTemplate};
|
|
11
|
+
/*!
|
|
12
|
+
* parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>
|
|
13
|
+
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
14
|
+
* Released under the MIT License.
|
|
15
|
+
*
|
|
16
|
+
* Converted to typescript by Matthias E. <matthias@enpage.co>
|
|
17
|
+
*/
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
var _="enpage-cli",E=5e3,o=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",t=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",e=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co",N=10,I="oauth/devicecode",p="oauth/token",s="oauth/userinfo",A="v1/templates";export{t as API_BASE_URL,A as API_ENDPOINT_REGISTER_TEMPLATE,o as CLI_LOGIN_CLIENT_ID,E as CLI_LOGIN_POLL_INTERVAL,_ as CLI_PROJECT_NAME,N as DEFAULT_UPLOAD_MAX_CONCURRENCY,e as FRONTEND_BASE_URL,I as OAUTH_ENDPOINT_DEVICE_CODE,p as OAUTH_ENDPOINT_TOKEN,s as OAUTH_ENDPOINT_USER_INFO};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
3
|
+
import{program as C}from"commander";import{resolve as S}from"node:path";import{existsSync as F,readFileSync as ht,writeFileSync as bt}from"node:fs";import v from"chalk";function G(){let e;if(process.env.npm_config_user_agent){let t=process.env.npm_config_user_agent.split(" ")[0];e=t.slice(0,t.lastIndexOf("/"))}return e||(console.log("Warning: could not detect package manager"),e="npm"),e}function K(e){return`[${e.error}]${e.error_description?`: ${e.error_description}`:""}`}var Y="enpage-cli";var W=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",w=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",kt=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co",Q=10,Z="oauth/devicecode",ee="oauth/token",te="oauth/userinfo",re="v1/templates";import Ae from"conf";import{createLogger as Le}from"vite";var oe="0.0.51";import L from"chalk";function H(e,t,r=!1){let o=Le(e==="debug"?"info":e,{prefix:"[enpage]",allowClearScreen:t});return r&&o.info(L.hex("#7270c6").bold(`\u{1F680} Enpage v${oe}
|
|
4
|
+
`)),{...o,success:(s,i)=>o.info(L.green(s),i),error:(s,i)=>o.error(L.red(s),i),warn:(s,i)=>o.warn(L.yellow(s),i),warnOnce:(s,i)=>o.warnOnce(L.yellow(s),i),debug:(s,i)=>{e==="debug"&&o.info(L.gray(s),i)}}}var m=H();async function P(e,t,r={}){f.get("access_token")&&(r.Authorization=`Bearer ${f.get("access_token")}`);let o=await fetch(se(e),{method:"POST",headers:{"Content-Type":t instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...r},body:t instanceof URLSearchParams?t:JSON.stringify(t)}).catch(s=>{m.error(`Fatal Error requesting API: ${s.message} (${s.cause.code})`),m.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return ie(o)}async function ne(e,t={}){f.get("access_token")&&(t.Authorization=`Bearer ${f.get("access_token")}`);let r=await fetch(se(e),{headers:t,method:"GET"}).catch(o=>{m.error(`Fatal Error requesting API: ${o.message} (${o.cause.code})`),m.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return ie(r)}function se(e){let t=new URL(w.endsWith("/")?w:`${w}/`);return new URL(e,t)}async function ie(e){let t=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:t}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:t}}import N from"node:path";import ke from"node:crypto";import A from"node:fs";import{fileURLToPath as Ce}from"node:url";import Re from"chalk";var $e=Ce(new URL(".",import.meta.url)),Ue=Ne(),f=new Ae({projectName:Y,encryptionKey:Ue,clearInvalidConfig:!0});async function ae(e=!1){let t=f.get("access_token"),r=f.get("expires_at");if(!t)return!1;if(r&&r<Date.now())return console.log("Seems like your token expired..."),!1;if(!e)return!0;let{isSuccess:o}=await ne(te);return o}function pe(){let e=f.get("access_token");if(!e){let t=G();throw new Error(`Access token not found. Please run ${Re.cyan(`${t} run enpage:login`)} to authenticate.`)}return e}function De(){let e=$e;for(;e!==N.parse(e).root;){let t=N.join(e,"node_modules");if(A.existsSync(t))return t;e=N.dirname(e)}return null}function Ne(){let e=De();if(!e)throw new Error("Could not find nearest node_modules directory.");let t=N.join(e,".enpage-tmp");A.existsSync(t)||A.mkdirSync(t,{recursive:!0,mode:448});let r=N.join(t,".enpage-key");if(!A.existsSync(r)){let s=ke.randomBytes(32).toString("hex");return A.writeFileSync(r,s,{mode:384,flush:!0}),s}return A.readFileSync(r,"utf8")}import j from"node:path";import I from"node:fs";import Je from"node:crypto";import Xe from"fast-glob";import de from"node:http";import Ke from"node:https";import{pipeline as Ye}from"node:stream";import ue from"chalk";import Qe from"form-data";import*as M from"node:fs";var je=/[<>"|?*\n\r\t\f\x00-\x1F]/,Ie=/(?:^|\/)[*]{2}($|\/)/,Fe=248,Ge=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Me=e=>typeof e=="string"&&e.length<=Fe&&!je.test(e),Be=e=>e.split(/\r\n?|\n/);var ze=e=>Ge(e)&&Array.isArray(e.patterns)&&Array.isArray(e.sections);var B=(e,t={})=>{let r=t.path;if(ze(e))return e;Me(e)&&M.existsSync(e)&&(r=e,e=M.readFileSync(e,"utf8"));let o=Be(e),s=new Map,i={sections:[],patterns:[]},p={name:"default",patterns:[]},n=null;for(let a of o){let c=a.trim();if(c.startsWith("#")){let[,u]=/^#+\s*(.*)\s*$/.exec(c)||[];if(n){s.delete(n.name),n.comment=n.comment?`${n.comment}
|
|
5
|
+
${c}`:c,n.name=u?`${n.name.trim()}
|
|
6
|
+
${u.trim()}`:n.name.trim(),s.set(n.name.toLowerCase().trim(),n);continue}p={name:u?.trim()||"",comment:c,patterns:[]},s.set(p.name.toLowerCase(),p),i.sections.push(p),n=p;continue}c!==""&&(p.patterns.push(c),i.patterns.push(c)),n=null}return(t.dedupe===!0||t.unique===!0)&&(i=ce(i,{...t,format:!1})),i.path=r,i.input=Buffer.from(e),i.format=a=>Ve(i,{...t,...a}),i.dedupe=a=>ce(i,{...t,...a}),i.globs=a=>He(i,{path:r,...t,...a}),i};var ce=(e,t)=>{let r=B(e,{...t,dedupe:!1}),o=new Map,s={sections:[],patterns:[]},i;for(let p of r.sections){let{name:n="",comment:a,patterns:c}=p,u=n.trim().toLowerCase();for(let y of c)s.patterns.includes(y)||s.patterns.push(y);n&&o.has(u)?(i=o.get(u),i.patterns=[...i.patterns,...c]):(i={name:n,comment:a,patterns:c},s.sections.push(i),o.set(u,i))}for(let p of s.sections)p.patterns=[...new Set(p.patterns)];return s},We=e=>{if(Ie.test(e))return e;let t=!1;return e.startsWith("/")?(e=e.slice(1),t=!0):e.slice(1,e.length-1).includes("/")&&(t=!0),e+=e.endsWith("/")?"**/":"/**",t?e:`**/${e}`},He=(e,t={})=>{let r=B(e,t),o=[],s=0,i=r.patterns.concat(t.ignore||[]).concat((t.unignore||[]).map(n=>n.startsWith("!")?n:`!${n}`)),p=(n,a)=>{let c=o[o.length-1],u=n?"unignore":"ignore";c&&c.type===u?c.patterns.includes(a)||c.patterns.push(a):(o.push({type:u,path:t.path||null,patterns:[a],index:s}),s++)};for(let n of i){let a="";n.startsWith("!")&&(n=n.slice(1),a="!"),p(a,n.startsWith("/")?n.slice(1):n),p(a,We(n))}return o},qe=(e={name:"",patterns:[]})=>{let t=[e.comment||""];return e.patterns?.length&&(t.push(e.patterns.join(`
|
|
7
|
+
`)),t.push("")),t.join(`
|
|
8
|
+
`)},Ve=(e,t={})=>{let r=B(e,t),o=t.formatSection||qe,s=r.sections||r,i=[];for(let p of[].concat(s))i.push(o(p));return i.join(`
|
|
9
|
+
`)};var le=B;import Ze from"p-queue";import et from"ora";import{customAlphabet as tt}from"nanoid";var k=class extends Error{constructor(r,o,s){super(`${r}: ${o}`);this.error=r;this.error_description=o;this.filename=s;this.name="UploadError"}},rt={maxDataSize:12*1024*1024,retryAttempts:2,retryDelay:1e3},ot=new de.Agent({keepAlive:!0,maxSockets:10,keepAliveMsecs:3e3});async function nt(e){let t=j.join(e,".gitignore"),o=I.existsSync(t)?le(I.readFileSync(t,"utf-8")).patterns:[];return Xe("**/*",{cwd:e,onlyFiles:!0,dot:!0,absolute:!0,ignore:["node_modules/**",".cache/**","**/.DS_Store",".gitignore",".env",".env.*",".git/**","dist/**",...o]})}async function st(e,t,r,o,s,i,p){let n=async a=>{try{return await it(e,t,r,o,s,i,p)}catch(c){if(a<p.retryAttempts)return m.warn(`Retrying upload for ${t} (attempt ${a+1})`),await new Promise(u=>setTimeout(u,p.retryDelay)),n(a+1);throw c}};return n(0)}async function it(e,t,r,o,s,i,p){return new Promise((n,a)=>{let c=I.statSync(e),u=j.basename(e),y=Date.now(),O=new Qe({maxDataSize:p.maxDataSize}),R=I.createReadStream(e),$=0,_=l=>{$+=l.length};R.on("data",_),O.append("file",R,{filename:u,knownLength:c.size});let T={agent:ot,method:"POST",headers:{authorization:`Bearer ${i}`,"x-enpage-template-file-path":t,"x-enpage-template-id":o,...O.getHeaders()}},x=(r.startsWith("https")?Ke:de).request(r,T,l=>{let E="";l.on("data",U=>{E+=U}),l.on("end",()=>{let U=Date.now(),_e={fileName:u,fileSize:c.size,uploadDuration:U-y,statusCode:l.statusCode??0,serverResponse:E};if(l.statusCode&&l.statusCode>=200&&l.statusCode<300)s.text=`Uploaded ${t}`,n(_e);else{let D;if(l.headers["content-type"]?.startsWith("application/json")){let X=JSON.parse(E);D=new k(X.error||"unknown_error",X.error_description||"Unknown error occurred",t)}else D=new k("unknown_error",E||"Unknown error occurred",t);s.fail(`Failed to upload ${t} [${D.error}] ${D.error_description}`),a(D)}})});x.on("error",l=>{a(new k("request_error",l.message,t))}),Ye(O,x,l=>{l&&a(new k("pipeline_error",`Pipeline failed for ${u}: ${l.message}`,t))})})}function at(e,t,r){r.length>0?(m.error(ue.red(`Failed to upload ${r.length} files:`)),r.forEach(o=>{let s=o.reason;m.error(`- ${s.filename}: ${s.error_description} (${s.error})`)})):m.info(ue.green(`Uploaded ${t.length} files successfully for template ${e}.
|
|
10
|
+
`))}async function me(e,t,r,o=!1,s={}){let i={...rt,...s},p=new Ze({concurrency:Q}),n=await nt(t),a=n.length,c={},u=ct(),y=0;for(let d of n){let x=j.relative(t,d),l=await pt(d);c[x]=l}o&&(m.info(`Dry run mode enabled. Skipping upload.
|
|
11
|
+
`),m.info("The following files would have been uploaded:"),n.forEach(d=>m.info(`- ${d}`)),process.exit(0));let O=et(`Uploading ${a} files...`).start(),R=n.map(d=>{let x=j.resolve(t,d),l=j.relative(t,d),E=`${w}/v1/templates/${e}/upload/${u}`;return p.add(async()=>{let U=await st(x,l,E,e,O,r,i);return y++,U})}),$=await Promise.allSettled(R);O.stop();let _=$.filter(d=>d.status==="fulfilled"),T=$.filter(d=>d.status==="rejected");if(at(e,_.map(d=>d.value),T),!T.length&&_.length){let d=`${w}/v1/templates/${e}/upload/${u}/finalize`,l=await P(d,{signatures:c});if(l.isError)return m.error(`Failed to finalize upload: ${l.data.error_description} (${l.data.error})`),{filesCount:a,uploadedFiles:_.map(E=>E.value),failedFiles:[],success:!1}}return{filesCount:a,uploadedFiles:_.map(d=>d.value),failedFiles:T,success:T.length===0}}async function pt(e){let t=await Je.subtle.digest("SHA-1",I.readFileSync(e));return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function ct(){let e=tt("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",5),t=new Date,r=t.getUTCFullYear(),o=(t.getUTCMonth()+1).toString().padStart(2,"0"),s=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),p=t.getUTCMinutes().toString().padStart(2,"0"),n=t.getUTCSeconds().toString().padStart(2,"0");return`${r}${o}${s}${i}${p}${n}_${e()}`}import Se from"node:path";import h from"zod";var ge=h.object({id:h.string().optional(),name:h.string(),description:h.string(),readme:h.record(h.string()).optional(),tags:h.array(h.string()).optional(),author:h.string(),thumbnail:h.string().url().optional(),homepage:h.string().url().optional()});import{Type as g}from"@sinclair/typebox";import{Value as Sr}from"@sinclair/typebox/value";function fe(e){for(let t in e)if(t.startsWith("$"))throw new Error(`Attribute names starting with '$' (like "${t}") are reserved for internal use. Please rename it.`);return g.Object({...lt,...e},{$id:"attributes"})}var b={string(e,t="",r){return g.String({title:e,default:t,...r})},number(e,t=0,r){return g.Number({title:e,default:t,...r})},boolean(e,t=!1,r){let o={"ui:field":"switch"};return g.Boolean({title:e,default:t,...o,...r})},enum(e,t,r){let o={"ui:field":"enum","ui:display":r.displayAs||"select"},{options:s,displayAs:i,...p}=r;return g.Union(s.map(n=>g.Literal(typeof n=="string"?n:n.value,{title:typeof n=="string"?n:n.title,"ui:icon":typeof n=="string"?void 0:n.icon})),{title:e,default:t,...o,...p})},file(e,t="",r={}){return g.String({title:e,default:t,...r,format:"data-url"})},url(e,t="",r={}){return g.String({title:e,default:t,...r,format:"uri"})},color(e,t="",r){let o={"ui:field":"color"};return g.String({title:e,default:t,...o,...r})},date(e,t=new Date,r={}){return g.String({title:e,default:t.toISOString(),...r,format:"date"})},datetime(e,t=new Date,r={}){return g.String({title:e,default:t.toISOString(),...r,format:"date-time"})},geolocation(e,t,r={}){return g.Object({lat:g.Number({minimum:-90,maximum:90}),lng:g.Number({minimum:-180,maximum:180}),name:g.Optional(g.String({title:"Name"}))},{title:e,default:t,...r})}},lt={$pageLanguage:b.enum("Page language","en",{options:[{value:"ar",title:"Arabic"},{value:"zh",title:"Chinese"},{value:"cs",title:"Czech"},{value:"nl",title:"Dutch"},{value:"en",title:"English"},{value:"fr",title:"French"},{value:"de",title:"German"},{value:"he",title:"Hebrew"},{value:"hi",title:"Hindi"},{value:"it",title:"Italian"},{value:"ja",title:"Japanese"},{value:"ko",title:"Korean"},{value:"fa",title:"Persian"},{value:"pl",title:"Polish"},{value:"pt",title:"Portuguese"},{value:"ru",title:"Russian"},{value:"es",title:"Spanish"},{value:"tr",title:"Turkish"},{value:"vi",title:"Vietnamese"}],"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pagePath:b.string("Page path","/",{description:"The URL path of the page","ui:group":"location","ui:group:title":"Location","ui:group:order":1,"ui:field":"path"}),$pageTitle:b.string("Page title","Untitled",{"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageDescription:b.string("Page description","",{"ui:widget":"textarea","ui:options":{rows:3,widget:"textarea"},"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageKeywords:b.string("Page keywords","",{"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageLastUpdated:b.datetime("Last updated",void 0,{"ui:hidden":!0}),$pageWidth:b.enum("Page width","max-w-screen-2xl",{options:[{value:"max-w-screen-lg",title:"M",description:"Common for text-heavy content/blog posts"},{value:"max-w-screen-xl",title:"L",description:"Usefull or some landing pages"},{value:"max-w-screen-2xl",title:"XL",description:"Common width"},{value:"max-w-full",title:"Full",description:"Takes the entire space"}],description:"The maximum width of the page. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$pagePaddingVertical:b.enum("Page vertical spacing","20",{options:[{value:"0",title:"None"},{value:"10",title:"S"},{value:"20",title:"M"},{value:"30",title:"L"},{value:"50",title:"XL"}],description:"Vertical spacing. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$pagePaddingHorizontal:b.enum("Page horizontal spacing","20",{options:[{value:"0",title:"None"},{value:"10",title:"S"},{value:"20",title:"M"},{value:"30",title:"L"},{value:"50",title:"XL"}],description:"Horizontal spacing. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$backgroundColor:b.color("Page background color","#ffffff",{"ui:field":"color","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$textColor:b.color("Default text color","#222222",{"ui:field":"color","ui:group":"layout","ui:group:title":"Page Layout & Design","ui:color-type":"page-text"})};import ut from"node:fs";import{readFile as dt}from"node:fs/promises";import mt from"fast-glob";import{fromError as gt}from"zod-validation-error";import{basename as ye,dirname as ft,extname as yt}from"node:path";async function he(e,t=m){ut.existsSync(e)||(t.error(`\u{1F534} No enpage.config.js found!
|
|
12
|
+
Your project must have an enpage.config.js file in the root directory.
|
|
13
|
+
|
|
14
|
+
`),process.exit(1));let r=await import(e),o=ft(e),s={},i=await mt(["README.enpage.md","README.enpage.*.md"],{cwd:o,onlyFiles:!0,absolute:!0,caseSensitiveMatch:!1});for(let p of i){let n=ye(p,".md"),a=yt(n),c=(a===".enpage"?"en":a.substring(1)).toLowerCase();t.debug(`Found template readme file (${c}): ${ye(p)}`),s[c]=await dt(p,"utf-8")}return r.manifest.readme=s,r}function be(e,t){for(let o in e.datasources)!(e.datasources[o].provider||e.datasources[o].provider==="json")&&!e.datasources[o].sampleData&&(t.error(`\u{1F534} Error: Datasource "${o}" is missing sample data - nothing will be rendered during development! Please check your enpage.config.js file and add a "sampleData" key to your ${o} datasource.`),process.exit(1));e.attributes||(e.attributes=fe({}));let r=ge.safeParse(e.manifest);if(!r.success){t.error(`\u{1F534} Error: template manifest is invalid. Check your call to defineManifest().
|
|
15
|
+
`);let o=gt(r.error);t.error(`Hint: ${o.toString()}
|
|
16
|
+
|
|
17
|
+
`),process.exit(1)}return e}async function Oe({options:e,args:t,logger:r}){if(!await ae(!0)){let y=G();r.error(` ${v.redBright("Error")}: User token not found. Please run ${v.cyan(`${y} run enpage:login`)} to authenticate or set the ${v.cyan("ENPAGE_API_TOKEN")} environment variable.
|
|
18
|
+
`),process.exit(1)}let o=t.length?Se.isAbsolute(t[0])?t[0]:S(process.cwd(),t[0]):process.cwd();F(o)||(r.error(` Template directory not found: ${o}. Aborting.
|
|
19
|
+
`),process.exit(1));let s=t.length>1?Se.isAbsolute(t[1])?t[1]:S(process.cwd(),t[1]):S(o,"dist");F(s)||(r.error(` Dist directory not found: ${s}.
|
|
20
|
+
Please run 'build' before publishing. Aborting.
|
|
21
|
+
`),process.exit(1)),F(S(o,"enpage.config.js"))||(r.error(` ${v.redBright("Error")}: file enpage.config.js not found in ${o}. Aborting.
|
|
22
|
+
`),process.exit(1));let i=await he(S(o,"enpage.config.js"),r);be(i,r);let p=pe(),n=St(o);n||(r.error(` ${v.redBright("Error")}: package.json file not found in ${o}. Aborting.
|
|
23
|
+
`),process.exit(1));let a=await Ot(n);if(a||(r.error(` ${v.redBright("Error")}: cannot read/parse package.json file in ${o}. Aborting.
|
|
24
|
+
`),process.exit(1)),!a.enpage?.id){let{data:y,isError:O,status:R}=await P(re,{manifest:i.manifest});O&&(r.error(` ${v.redBright("Error")}: Cannot register template: ${K(y)}
|
|
25
|
+
`),process.exit(1)),a.enpage??={},a.enpage.id=y.template.id;try{e.dryRun||bt(n,JSON.stringify(a,null,2))}catch{r.error(` ${v.redBright("Error")}: Cannot update template id in package.json file located in ${o}. Aborting.
|
|
26
|
+
`),process.exit(1)}}let c=a.enpage.id;r.info(`Submitting template to Enpage...
|
|
27
|
+
`),(await me(c,o,p,e.dryRun)).success||(r.error(`
|
|
28
|
+
Upload failed. See details above.
|
|
29
|
+
`),process.exit(1)),r.success(`Template ${c} published.
|
|
30
|
+
`)}function St(e){return F(S(e,"package.json"))?S(e,"package.json"):F(S(e,"template-package.json"))?S(e,"template-package.json"):!1}function Ot(e){try{return JSON.parse(ht(e,"utf-8"))}catch{return null}}import Et from"chalk";import{confirm as vt}from"@inquirer/prompts";import xt from"open";async function wt(e,t){for(;;){let r=new URLSearchParams({grant_type:"device_code",device_code:e,client_id:W}),o=await P(ee,r),{data:s,isSuccess:i}=o;if(i)return s;if(s.error==="authorization_pending")await new Promise(p=>setTimeout(p,5e3));else return t.error(`Error while polling for login: ${s.error_description??s.error}`),!1}}async function Ee({options:e,logger:t}){t.info(`Logging in to Enpage...
|
|
31
|
+
`);let{isError:r,data:o}=await P(Z,{client_id:W,scope:"profile,templates:publish"});r&&(t.error("Failed to get device code. Please try again."),t.error(`Error: ${o.error_description??o.error}`),process.exit(1));let{verification_uri:s,device_code:i}=o;await vt({message:"Would you like to open the login page in your browser?",default:!0}).catch(a=>{process.exit(0)})?xt(s):t.info(`
|
|
32
|
+
Please visit the following URL to login:
|
|
33
|
+
${s}
|
|
34
|
+
`),t.info(Et.gray(`
|
|
35
|
+
Waiting for login...
|
|
36
|
+
`));let n=await wt(i,t);n||(t.error("Login failed. Please try again."),process.exit(1)),f.set({...n,...n.expires_in?{expires_at:Date.now()+n.expires_in*1e3}:{}}),t.info(`Login successful!
|
|
37
|
+
`),process.exitCode=0}import{build as q}from"vite";import Pt,{resolve as ve}from"node:path";import{fileURLToPath as _t}from"node:url";import{sync as Tt}from"rimraf";var xe=_t(new URL(".",import.meta.url)),V=ve(xe,"../builder/vite-config.js"),Lt=ve(xe,"../builder/vite-entry-server.js");async function we({options:e,logger:t}){t.info(`Building template...
|
|
38
|
+
`),e.clean&&Tt(Pt.join(process.cwd(),"dist"));let r="production";e.ssr==="local"&&(r="development",process.env.NODE_ENV=r),e.ssr?(await q({configFile:V,customLogger:t,mode:r,logLevel:e.logLevel,clearScreen:e.clearScreen,build:{ssrManifest:!0,emptyOutDir:!0}}),await q({configFile:V,customLogger:t,mode:r,logLevel:e.logLevel,clearScreen:e.clearScreen,ssr:{target:"webworker"},build:{ssr:Lt}})):await q({configFile:V,customLogger:t,logLevel:e.logLevel,clearScreen:e.clearScreen,build:{emptyOutDir:!0}})}async function Pe({options:e,logger:t}){t.info("Logging out fom Enpage..."),f.clear(),t.info(`Done.
|
|
39
|
+
`),process.exit(0)}var J;C.name("enpage").option("-l, --logLevel <level>","[string] info | warn | error | silent | debug").option("--clearScreen","[boolean] allow/disable clear screen when logging").option("--dry-run","[boolean] run command without making changes").hook("preAction",e=>{J=H(e.optsWithGlobals().logLevel,e.optsWithGlobals().clearScreen,!0),process.removeAllListeners("warning"),process.on("warning",t=>{t.name==="DeprecationWarning"&&t.message.includes("util.isArray")||J.warnOnce(`Warning: ${t.name} - ${t.message}`)})});C.command("build").description("Build template").option("--ssr [type]",`Enable server side rendering.
|
|
40
|
+
Pass --ssr to generate a SSR-enabled build.
|
|
41
|
+
Pass --ssr=local to generate a SSR-enabled build that can be tested locally.`,Boolean,!1).option("--no-clean","Don't clean directory before buidling").action(function(){we(z(this))});C.command("publish").description("Publish a template to Enpage").argument("[directory]","Directory to publish").option("--no-check","Don't check for required files").action(function(){Oe(z(this))});C.command("login").description("Login to Enpage").action(function(){Ee(z(this))});C.command("logout").description("Logout from Enpage").action(function(){Pe(z(this))});C.parse();function z(e){return{options:e.optsWithGlobals(),args:e.args,logger:J}}
|
|
42
|
+
/*!
|
|
43
|
+
* parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>
|
|
44
|
+
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
45
|
+
* Released under the MIT License.
|
|
46
|
+
*
|
|
47
|
+
* Converted to typescript by Matthias E. <matthias@enpage.co>
|
|
48
|
+
*/
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
var g="enpage-cli";var w=process.env.PUBLIC_ENPAGE_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",d=process.env.PUBLIC_ENPAGE_API_BASE_URL??"https://api.enpage.co",I=process.env.PUBLIC_ENPAGE_FRONTEND_BASE_URL??"https://enpage.co";var m="oauth/userinfo";import L from"conf";import{createLogger as E}from"vite";var l="0.0.51";import i from"chalk";function _(e,t,o=!1){let s=E(e==="debug"?"info":e,{prefix:"[enpage]",allowClearScreen:t});return o&&s.info(i.hex("#7270c6").bold(`\u{1F680} Enpage v${l}
|
|
3
|
+
`)),{...s,success:(r,n)=>s.info(i.green(r),n),error:(r,n)=>s.error(i.red(r),n),warn:(r,n)=>s.warn(i.yellow(r),n),warnOnce:(r,n)=>s.warnOnce(i.yellow(r),n),debug:(r,n)=>{e==="debug"&&s.info(i.gray(r),n)}}}var u=_();async function f(e,t={}){a.get("access_token")&&(t.Authorization=`Bearer ${a.get("access_token")}`);let o=await fetch(x(e),{headers:t,method:"GET"}).catch(s=>{u.error(`Fatal Error requesting API: ${s.message} (${s.cause.code})`),u.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return T(o)}function x(e){let t=new URL(d.endsWith("/")?d:`${d}/`);return new URL(e,t)}async function T(e){let t=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:t}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:t}}import c from"node:path";import k from"node:crypto";import p from"node:fs";import{fileURLToPath as R}from"node:url";function y(){let e;if(process.env.npm_config_user_agent){let t=process.env.npm_config_user_agent.split(" ")[0];e=t.slice(0,t.lastIndexOf("/"))}return e||(console.log("Warning: could not detect package manager"),e="npm"),e}import O from"chalk";var v=R(new URL(".",import.meta.url)),P=N(),a=new L({projectName:g,encryptionKey:P,clearInvalidConfig:!0});async function Q(e=!1){let t=a.get("access_token"),o=a.get("expires_at");if(!t)return!1;if(o&&o<Date.now())return console.log("Seems like your token expired..."),!1;if(!e)return!0;let{isSuccess:s}=await f(m);return s}function Z(){let e=a.get("access_token");if(!e){let t=y();throw new Error(`Access token not found. Please run ${O.cyan(`${t} run enpage:login`)} to authenticate.`)}return e}function S(){let e=v;for(;e!==c.parse(e).root;){let t=c.join(e,"node_modules");if(p.existsSync(t))return t;e=c.dirname(e)}return null}function N(){let e=S();if(!e)throw new Error("Could not find nearest node_modules directory.");let t=c.join(e,".enpage-tmp");p.existsSync(t)||p.mkdirSync(t,{recursive:!0,mode:448});let o=c.join(t,".enpage-key");if(!p.existsSync(o)){let r=k.randomBytes(32).toString("hex");return p.writeFileSync(o,r,{mode:384,flush:!0}),r}return p.readFileSync(o,"utf8")}export{a as accessStore,Z as getTokenOrThrow,Q as isLoggedIn};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
function n(){let r;if(process.env.npm_config_user_agent){let e=process.env.npm_config_user_agent.split(" ")[0];r=e.slice(0,e.lastIndexOf("/"))}return r||(console.log("Warning: could not detect package manager"),r="npm"),r}function t(r){return`[${r.error}]${r.error_description?`: ${r.error_description}`:""}`}export{t as formatAPIError,n as getPackageManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"package.json":{"bytes":4563,"imports":[]},"src/node/shared/logger.ts":{"bytes":1411,"imports":[{"path":"vite","kind":"import-statement","external":true},{"path":"package.json","kind":"import-statement","original":"../../../package.json"},{"path":"chalk","kind":"import-statement","external":true}],"format":"esm"},"src/node/cli/constants.ts":{"bytes":705,"imports":[],"format":"esm"},"src/node/cli/utils.ts":{"bytes":638,"imports":[],"format":"esm"},"src/node/cli/store.ts":{"bytes":2489,"imports":[{"path":"src/node/cli/constants.ts","kind":"import-statement","original":"./constants"},{"path":"conf","kind":"import-statement","external":true},{"path":"src/node/cli/api.ts","kind":"import-statement","original":"./api"},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"src/node/cli/utils.ts","kind":"import-statement","original":"./utils"},{"path":"chalk","kind":"import-statement","external":true}],"format":"esm"},"src/node/cli/api.ts":{"bytes":3038,"imports":[{"path":"src/node/shared/logger.ts","kind":"import-statement","original":"../shared/logger"},{"path":"src/node/cli/constants.ts","kind":"import-statement","original":"./constants"},{"path":"src/node/cli/store.ts","kind":"import-statement","original":"./store"}],"format":"esm"},"src/node/cli/commands/publish/parse-gitignore.ts":{"bytes":8164,"imports":[{"path":"node:fs","kind":"import-statement","external":true}],"format":"esm"},"src/node/cli/commands/publish/uploader.ts":{"bytes":9822,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"fast-glob","kind":"import-statement","external":true},{"path":"src/node/cli/constants.ts","kind":"import-statement","original":"../../constants"},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:https","kind":"import-statement","external":true},{"path":"node:stream","kind":"import-statement","external":true},{"path":"src/node/shared/logger.ts","kind":"import-statement","original":"~/node/shared/logger"},{"path":"chalk","kind":"import-statement","external":true},{"path":"form-data","kind":"import-statement","external":true},{"path":"src/node/cli/commands/publish/parse-gitignore.ts","kind":"import-statement","original":"./parse-gitignore"},{"path":"p-queue","kind":"import-statement","external":true},{"path":"ora","kind":"import-statement","external":true},{"path":"nanoid","kind":"import-statement","external":true},{"path":"src/node/cli/api.ts","kind":"import-statement","original":"../../api"}],"format":"esm"},"src/shared/manifest.ts":{"bytes":605,"imports":[{"path":"zod","kind":"import-statement","external":true}],"format":"esm"},"src/shared/attributes.ts":{"bytes":8687,"imports":[{"path":"@sinclair/typebox","kind":"import-statement","external":true},{"path":"@sinclair/typebox/value","kind":"import-statement","external":true}],"format":"esm"},"src/node/shared/config.ts":{"bytes":2877,"imports":[{"path":"src/shared/manifest.ts","kind":"import-statement","original":"~/shared/manifest"},{"path":"src/shared/attributes.ts","kind":"import-statement","original":"~/shared/attributes"},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"fast-glob","kind":"import-statement","external":true},{"path":"src/node/shared/logger.ts","kind":"import-statement","original":"./logger"},{"path":"zod-validation-error","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/node/cli/commands/publish/cmd-publish.ts":{"bytes":4446,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"src/node/cli/utils.ts","kind":"import-statement","original":"../../utils"},{"path":"src/node/cli/store.ts","kind":"import-statement","original":"../../store"},{"path":"src/node/cli/commands/publish/uploader.ts","kind":"import-statement","original":"./uploader"},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/node/cli/api.ts","kind":"import-statement","original":"../../api"},{"path":"src/node/cli/constants.ts","kind":"import-statement","original":"../../constants"},{"path":"src/node/shared/config.ts","kind":"import-statement","original":"~/node/shared/config"}],"format":"esm"},"src/node/cli/commands/login/cmd-login.ts":{"bytes":3162,"imports":[{"path":"chalk","kind":"import-statement","external":true},{"path":"@inquirer/prompts","kind":"import-statement","external":true},{"path":"open","kind":"import-statement","external":true},{"path":"src/node/cli/constants.ts","kind":"import-statement","original":"../../constants"},{"path":"src/node/cli/api.ts","kind":"import-statement","original":"../../api"},{"path":"src/node/cli/store.ts","kind":"import-statement","original":"../../store"}],"format":"esm"},"src/node/cli/commands/build/cmd-build.ts":{"bytes":1576,"imports":[{"path":"vite","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"rimraf","kind":"import-statement","external":true}],"format":"esm"},"src/node/cli/commands/logout/cmd-logout.ts":{"bytes":309,"imports":[{"path":"src/node/cli/store.ts","kind":"import-statement","original":"../../store"}],"format":"esm"},"src/node/cli/program.ts":{"bytes":2449,"imports":[{"path":"commander","kind":"import-statement","external":true},{"path":"src/node/cli/commands/publish/cmd-publish.ts","kind":"import-statement","original":"./commands/publish/cmd-publish"},{"path":"src/node/cli/commands/login/cmd-login.ts","kind":"import-statement","original":"./commands/login/cmd-login"},{"path":"src/node/cli/commands/build/cmd-build.ts","kind":"import-statement","original":"./commands/build/cmd-build"},{"path":"src/node/shared/logger.ts","kind":"import-statement","original":"../shared/logger"},{"path":"src/node/cli/commands/logout/cmd-logout.ts","kind":"import-statement","original":"./commands/logout/cmd-logout"}],"format":"esm"},"src/node/cli/types.ts":{"bytes":740,"imports":[],"format":"esm"}},"outputs":{"dist/node/cli/api.js":{"imports":[{"path":"vite","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"conf","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true}],"exports":["get","post"],"entryPoint":"src/node/cli/api.ts","inputs":{"src/node/shared/logger.ts":{"bytesInOutput":424},"package.json":{"bytesInOutput":15},"src/node/cli/constants.ts":{"bytesInOutput":240},"src/node/cli/store.ts":{"bytesInOutput":752},"src/node/cli/api.ts":{"bytesInOutput":1190}},"bytes":2747},"dist/node/cli/constants.js":{"imports":[],"exports":["API_BASE_URL","API_ENDPOINT_REGISTER_TEMPLATE","CLI_LOGIN_CLIENT_ID","CLI_LOGIN_POLL_INTERVAL","CLI_PROJECT_NAME","DEFAULT_UPLOAD_MAX_CONCURRENCY","FRONTEND_BASE_URL","OAUTH_ENDPOINT_DEVICE_CODE","OAUTH_ENDPOINT_TOKEN","OAUTH_ENDPOINT_USER_INFO"],"entryPoint":"src/node/cli/constants.ts","inputs":{"src/node/cli/constants.ts":{"bytesInOutput":320}},"bytes":704},"dist/node/cli/program.js":{"imports":[{"path":"commander","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"conf","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"fast-glob","kind":"import-statement","external":true},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:https","kind":"import-statement","external":true},{"path":"node:stream","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"form-data","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"p-queue","kind":"import-statement","external":true},{"path":"ora","kind":"import-statement","external":true},{"path":"nanoid","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"zod","kind":"import-statement","external":true},{"path":"@sinclair/typebox","kind":"import-statement","external":true},{"path":"@sinclair/typebox/value","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"fast-glob","kind":"import-statement","external":true},{"path":"zod-validation-error","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"@inquirer/prompts","kind":"import-statement","external":true},{"path":"open","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"rimraf","kind":"import-statement","external":true}],"exports":[],"entryPoint":"src/node/cli/program.ts","inputs":{"src/node/cli/program.ts":{"bytesInOutput":1331},"src/node/cli/commands/publish/cmd-publish.ts":{"bytesInOutput":2037},"src/node/cli/utils.ts":{"bytesInOutput":309},"src/node/cli/constants.ts":{"bytesInOutput":322},"src/node/cli/store.ts":{"bytesInOutput":1162},"src/node/shared/logger.ts":{"bytesInOutput":427},"package.json":{"bytesInOutput":16},"src/node/cli/api.ts":{"bytesInOutput":1197},"src/node/cli/commands/publish/uploader.ts":{"bytesInOutput":4152},"src/node/cli/commands/publish/parse-gitignore.ts":{"bytesInOutput":2395},"src/shared/manifest.ts":{"bytesInOutput":270},"src/shared/attributes.ts":{"bytesInOutput":4155},"src/node/shared/config.ts":{"bytesInOutput":1362},"src/node/cli/commands/login/cmd-login.ts":{"bytesInOutput":1172},"src/node/cli/commands/build/cmd-build.ts":{"bytesInOutput":834},"src/node/cli/commands/logout/cmd-logout.ts":{"bytesInOutput":119}},"bytes":21605},"dist/node/cli/store.js":{"imports":[{"path":"conf","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true}],"exports":["accessStore","getTokenOrThrow","isLoggedIn"],"entryPoint":"src/node/cli/store.ts","inputs":{"src/node/cli/constants.ts":{"bytesInOutput":263},"src/node/cli/store.ts":{"bytesInOutput":1142},"src/node/shared/logger.ts":{"bytesInOutput":424},"package.json":{"bytesInOutput":15},"src/node/cli/api.ts":{"bytesInOutput":690},"src/node/cli/utils.ts":{"bytesInOutput":222}},"bytes":2917},"dist/node/cli/types.js":{"imports":[],"exports":[],"entryPoint":"src/node/cli/types.ts","inputs":{"src/node/cli/types.ts":{"bytesInOutput":0}},"bytes":98},"dist/node/cli/utils.js":{"imports":[],"exports":["formatAPIError","getPackageManager"],"entryPoint":"src/node/cli/utils.ts","inputs":{"src/node/cli/utils.ts":{"bytesInOutput":309}},"bytes":459},"dist/node/shared/config.js":{"imports":[{"path":"zod","kind":"import-statement","external":true},{"path":"@sinclair/typebox","kind":"import-statement","external":true},{"path":"@sinclair/typebox/value","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"fast-glob","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"zod-validation-error","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"exports":["loadConfigFromJsFile","loadConfigFromManifestFile","validateTemplateConfig"],"entryPoint":"src/node/shared/config.ts","inputs":{"src/shared/manifest.ts":{"bytesInOutput":269},"src/shared/attributes.ts":{"bytesInOutput":4151},"src/node/shared/config.ts":{"bytesInOutput":1532},"src/node/shared/logger.ts":{"bytesInOutput":424},"package.json":{"bytesInOutput":15}},"bytes":6584},"dist/node/shared/logger.js":{"imports":[{"path":"vite","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true}],"exports":["createLogger","logger"],"entryPoint":"src/node/shared/logger.ts","inputs":{"src/node/shared/logger.ts":{"bytesInOutput":424},"package.json":{"bytesInOutput":15}},"bytes":576},"dist/node/cli/commands/build/cmd-build.js":{"imports":[{"path":"vite","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"rimraf","kind":"import-statement","external":true}],"exports":["buildTemplate"],"entryPoint":"src/node/cli/commands/build/cmd-build.ts","inputs":{"src/node/cli/commands/build/cmd-build.ts":{"bytesInOutput":819}},"bytes":945},"dist/node/cli/commands/login/cmd-login.js":{"imports":[{"path":"chalk","kind":"import-statement","external":true},{"path":"@inquirer/prompts","kind":"import-statement","external":true},{"path":"open","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"conf","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true}],"exports":["login","pollForLogin"],"entryPoint":"src/node/cli/commands/login/cmd-login.ts","inputs":{"src/node/cli/commands/login/cmd-login.ts":{"bytesInOutput":1163},"src/node/cli/constants.ts":{"bytesInOutput":281},"src/node/shared/logger.ts":{"bytesInOutput":424},"package.json":{"bytesInOutput":15},"src/node/cli/store.ts":{"bytesInOutput":752},"src/node/cli/api.ts":{"bytesInOutput":851}},"bytes":3623},"dist/node/cli/commands/logout/cmd-logout.js":{"imports":[{"path":"conf","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true}],"exports":["logout"],"entryPoint":"src/node/cli/commands/logout/cmd-logout.ts","inputs":{"src/node/cli/constants.ts":{"bytesInOutput":240},"src/node/cli/store.ts":{"bytesInOutput":752},"src/node/cli/commands/logout/cmd-logout.ts":{"bytesInOutput":118}},"bytes":1229},"dist/node/cli/commands/publish/cmd-publish.js":{"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"conf","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"fast-glob","kind":"import-statement","external":true},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:https","kind":"import-statement","external":true},{"path":"node:stream","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"form-data","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"p-queue","kind":"import-statement","external":true},{"path":"ora","kind":"import-statement","external":true},{"path":"nanoid","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"zod","kind":"import-statement","external":true},{"path":"@sinclair/typebox","kind":"import-statement","external":true},{"path":"@sinclair/typebox/value","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"fast-glob","kind":"import-statement","external":true},{"path":"zod-validation-error","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"exports":["publish"],"entryPoint":"src/node/cli/commands/publish/cmd-publish.ts","inputs":{"src/node/cli/commands/publish/cmd-publish.ts":{"bytesInOutput":2034},"src/node/cli/utils.ts":{"bytesInOutput":309},"src/node/cli/constants.ts":{"bytesInOutput":287},"src/node/cli/store.ts":{"bytesInOutput":1158},"src/node/shared/logger.ts":{"bytesInOutput":428},"package.json":{"bytesInOutput":15},"src/node/cli/api.ts":{"bytesInOutput":1190},"src/node/cli/commands/publish/uploader.ts":{"bytesInOutput":4152},"src/node/cli/commands/publish/parse-gitignore.ts":{"bytesInOutput":2395},"src/shared/manifest.ts":{"bytesInOutput":270},"src/shared/attributes.ts":{"bytesInOutput":4155},"src/node/shared/config.ts":{"bytesInOutput":1362}},"bytes":18102},"dist/node/cli/commands/publish/parse-gitignore.js":{"imports":[{"path":"node:fs","kind":"import-statement","external":true}],"exports":["dedupe","default","format","formatSection","globs","parse","parseFile","patterns"],"entryPoint":"src/node/cli/commands/publish/parse-gitignore.ts","inputs":{"src/node/cli/commands/publish/parse-gitignore.ts":{"bytesInOutput":2471}},"bytes":2911},"dist/node/cli/commands/publish/uploader.js":{"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"fast-glob","kind":"import-statement","external":true},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:https","kind":"import-statement","external":true},{"path":"node:stream","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"form-data","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"p-queue","kind":"import-statement","external":true},{"path":"ora","kind":"import-statement","external":true},{"path":"nanoid","kind":"import-statement","external":true},{"path":"conf","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true}],"exports":["uploadTemplate"],"entryPoint":"src/node/cli/commands/publish/uploader.ts","inputs":{"src/node/cli/commands/publish/uploader.ts":{"bytesInOutput":4143},"src/node/cli/constants.ts":{"bytesInOutput":247},"src/node/shared/logger.ts":{"bytesInOutput":424},"package.json":{"bytesInOutput":15},"src/node/cli/commands/publish/parse-gitignore.ts":{"bytesInOutput":2377},"src/node/cli/store.ts":{"bytesInOutput":767},"src/node/cli/api.ts":{"bytesInOutput":855}},"bytes":9182}}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import n from"zod";var f=n.object({id:n.string().optional(),name:n.string(),description:n.string(),readme:n.record(n.string()).optional(),tags:n.array(n.string()).optional(),author:n.string(),thumbnail:n.string().url().optional(),homepage:n.string().url().optional()});import{Type as o}from"@sinclair/typebox";import{Value as C}from"@sinclair/typebox/value";function y(e){for(let t in e)if(t.startsWith("$"))throw new Error(`Attribute names starting with '$' (like "${t}") are reserved for internal use. Please rename it.`);return o.Object({...O,...e},{$id:"attributes"})}var p={string(e,t="",i){return o.String({title:e,default:t,...i})},number(e,t=0,i){return o.Number({title:e,default:t,...i})},boolean(e,t=!1,i){let r={"ui:field":"switch"};return o.Boolean({title:e,default:t,...r,...i})},enum(e,t,i){let r={"ui:field":"enum","ui:display":i.displayAs||"select"},{options:s,displayAs:a,...d}=i;return o.Union(s.map(l=>o.Literal(typeof l=="string"?l:l.value,{title:typeof l=="string"?l:l.title,"ui:icon":typeof l=="string"?void 0:l.icon})),{title:e,default:t,...r,...d})},file(e,t="",i={}){return o.String({title:e,default:t,...i,format:"data-url"})},url(e,t="",i={}){return o.String({title:e,default:t,...i,format:"uri"})},color(e,t="",i){let r={"ui:field":"color"};return o.String({title:e,default:t,...r,...i})},date(e,t=new Date,i={}){return o.String({title:e,default:t.toISOString(),...i,format:"date"})},datetime(e,t=new Date,i={}){return o.String({title:e,default:t.toISOString(),...i,format:"date-time"})},geolocation(e,t,i={}){return o.Object({lat:o.Number({minimum:-90,maximum:90}),lng:o.Number({minimum:-180,maximum:180}),name:o.Optional(o.String({title:"Name"}))},{title:e,default:t,...i})}},O={$pageLanguage:p.enum("Page language","en",{options:[{value:"ar",title:"Arabic"},{value:"zh",title:"Chinese"},{value:"cs",title:"Czech"},{value:"nl",title:"Dutch"},{value:"en",title:"English"},{value:"fr",title:"French"},{value:"de",title:"German"},{value:"he",title:"Hebrew"},{value:"hi",title:"Hindi"},{value:"it",title:"Italian"},{value:"ja",title:"Japanese"},{value:"ko",title:"Korean"},{value:"fa",title:"Persian"},{value:"pl",title:"Polish"},{value:"pt",title:"Portuguese"},{value:"ru",title:"Russian"},{value:"es",title:"Spanish"},{value:"tr",title:"Turkish"},{value:"vi",title:"Vietnamese"}],"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pagePath:p.string("Page path","/",{description:"The URL path of the page","ui:group":"location","ui:group:title":"Location","ui:group:order":1,"ui:field":"path"}),$pageTitle:p.string("Page title","Untitled",{"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageDescription:p.string("Page description","",{"ui:widget":"textarea","ui:options":{rows:3,widget:"textarea"},"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageKeywords:p.string("Page keywords","",{"ui:group":"meta","ui:group:title":"Meta tags / SEO"}),$pageLastUpdated:p.datetime("Last updated",void 0,{"ui:hidden":!0}),$pageWidth:p.enum("Page width","max-w-screen-2xl",{options:[{value:"max-w-screen-lg",title:"M",description:"Common for text-heavy content/blog posts"},{value:"max-w-screen-xl",title:"L",description:"Usefull or some landing pages"},{value:"max-w-screen-2xl",title:"XL",description:"Common width"},{value:"max-w-full",title:"Full",description:"Takes the entire space"}],description:"The maximum width of the page. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$pagePaddingVertical:p.enum("Page vertical spacing","20",{options:[{value:"0",title:"None"},{value:"10",title:"S"},{value:"20",title:"M"},{value:"30",title:"L"},{value:"50",title:"XL"}],description:"Vertical spacing. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$pagePaddingHorizontal:p.enum("Page horizontal spacing","20",{options:[{value:"0",title:"None"},{value:"10",title:"S"},{value:"20",title:"M"},{value:"30",title:"L"},{value:"50",title:"XL"}],description:"Horizontal spacing. Desktop only.",displayAs:"button-group","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$backgroundColor:p.color("Page background color","#ffffff",{"ui:field":"color","ui:group":"layout","ui:group:title":"Page Layout & Design"}),$textColor:p.color("Default text color","#222222",{"ui:field":"color","ui:group":"layout","ui:group:title":"Page Layout & Design","ui:color-type":"page-text"})};import g from"node:fs";import{readFile as S}from"node:fs/promises";import k from"fast-glob";import{createLogger as L}from"vite";var h="0.0.51";import u from"chalk";function w(e,t,i=!1){let r=L(e==="debug"?"info":e,{prefix:"[enpage]",allowClearScreen:t});return i&&r.info(u.hex("#7270c6").bold(`\u{1F680} Enpage v${h}
|
|
3
|
+
`)),{...r,success:(s,a)=>r.info(u.green(s),a),error:(s,a)=>r.error(u.red(s),a),warn:(s,a)=>r.warn(u.yellow(s),a),warnOnce:(s,a)=>r.warnOnce(u.yellow(s),a),debug:(s,a)=>{e==="debug"&&r.info(u.gray(s),a)}}}var v=w();import{fromError as E}from"zod-validation-error";import{basename as b,dirname as A,extname as j}from"node:path";async function K(e,t=v){g.existsSync(e)||(t.error(`\u{1F534} No enpage.config.js found!
|
|
4
|
+
Your project must have an enpage.config.js file in the root directory.
|
|
5
|
+
|
|
6
|
+
`),process.exit(1));let i=await import(e),r=A(e),s={},a=await k(["README.enpage.md","README.enpage.*.md"],{cwd:r,onlyFiles:!0,absolute:!0,caseSensitiveMatch:!1});for(let d of a){let l=b(d,".md"),m=j(l),c=(m===".enpage"?"en":m.substring(1)).toLowerCase();t.debug(`Found template readme file (${c}): ${b(d)}`),s[c]=await S(d,"utf-8")}return i.manifest.readme=s,i}function W(e,t){return g.existsSync(e)||(t.error(`\u{1F534} No enpage.manifest.json found!
|
|
7
|
+
You may want to 'build' your template.
|
|
8
|
+
|
|
9
|
+
`),process.exit(1)),JSON.parse(g.readFileSync(e,"utf-8"))}function Y(e,t){for(let r in e.datasources)!(e.datasources[r].provider||e.datasources[r].provider==="json")&&!e.datasources[r].sampleData&&(t.error(`\u{1F534} Error: Datasource "${r}" is missing sample data - nothing will be rendered during development! Please check your enpage.config.js file and add a "sampleData" key to your ${r} datasource.`),process.exit(1));e.attributes||(e.attributes=y({}));let i=f.safeParse(e.manifest);if(!i.success){t.error(`\u{1F534} Error: template manifest is invalid. Check your call to defineManifest().
|
|
10
|
+
`);let r=E(i.error);t.error(`Hint: ${r.toString()}
|
|
11
|
+
|
|
12
|
+
`),process.exit(1)}return e}export{K as loadConfigFromJsFile,W as loadConfigFromManifestFile,Y as validateTemplateConfig};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import{createLogger as d}from"vite";var i="0.0.51";import o from"chalk";function c(r,p,a=!1){let t=d(r==="debug"?"info":r,{prefix:"[enpage]",allowClearScreen:p});return a&&t.info(o.hex("#7270c6").bold(`\u{1F680} Enpage v${i}
|
|
3
|
+
`)),{...t,success:(e,s)=>t.info(o.green(e),s),error:(e,s)=>t.error(o.red(e),s),warn:(e,s)=>t.warn(o.yellow(e),s),warnOnce:(e,s)=>t.warnOnce(o.yellow(e),s),debug:(e,s)=>{r==="debug"&&t.info(o.gray(e),s)}}}var h=c();export{c as createLogger,h as logger};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! Enpage - Copyright (C) 2024 Flippable - https://github.com/enpage/enpage/blob/main/LICENSE */
|
|
2
|
+
import p from"ajv";import c from"ajv-formats";var t=new p({useDefaults:!0});c(t,["date-time","time","date","email","hostname","ipv4","ipv6","uri","uri-reference","uuid","uri-template","json-pointer","relative-json-pointer","regex"]);t.addFormat("date-object",{validate:e=>e instanceof Date&&!Number.isNaN(e.getTime()),async:!1});function j(e){return!e||e.length===0?"Unknown validation error":e.map(r=>{let{instancePath:n,message:a,params:i}=r,o=n||"root",s=Object.entries(i||{}).map(([m,u])=>`${m}: ${u}`).join(", ");return`${o} ${a} (${s})`}).join("; ")}export{t as ajv,j as serializeAjvErrors};
|