UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

2 lines (1 loc) 1.52 kB
import{a as u,c as h,g as c}from"./chunk-VPRTJUIN.js";var v=h((w,l)=>{"use strict";c();var{builtinModules:f}=u("module"),d=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$"),p=["node_modules","favicon.ico"];function g(n){var t=[],e=[];if(n===null)return e.push("name cannot be null"),r(t,e);if(n===void 0)return e.push("name cannot be undefined"),r(t,e);if(typeof n!="string")return e.push("name must be a string"),r(t,e);if(n.length||e.push("name length must be greater than zero"),n.match(/^\./)&&e.push("name cannot start with a period"),n.match(/^_/)&&e.push("name cannot start with an underscore"),n.trim()!==n&&e.push("name cannot contain leading or trailing spaces"),p.forEach(function(s){n.toLowerCase()===s&&e.push(s+" is a blacklisted name")}),f.includes(n.toLowerCase())&&t.push(n+" is a core module name"),n.length>214&&t.push("name can no longer contain more than 214 characters"),n.toLowerCase()!==n&&t.push("name can no longer contain capital letters"),/[~'!()*]/.test(n.split("/").slice(-1)[0])&&t.push(`name can no longer contain special characters ("~'!()*")`),encodeURIComponent(n)!==n){var a=n.match(d);if(a){var i=a[1],o=a[2];if(encodeURIComponent(i)===i&&encodeURIComponent(o)===o)return r(t,e)}e.push("name can only contain URL-friendly characters")}return r(t,e)}var r=function(n,t){var e={validForNewPackages:t.length===0&&n.length===0,validForOldPackages:t.length===0,warnings:n,errors:t};return e.warnings.length||delete e.warnings,e.errors.length||delete e.errors,e};l.exports=g});export{v as a};