Git Product home page Git Product logo

cuetorials.com's Issues

Compose spec import error

Following the Convert JSON Schema with the current compose schema (as of this commit), cue import raises the following error:

% cue import -f -p compose -l '#ComposeSpec:' compose-spec.json

constraint not allowed because type object is excluded:
    ./compose-spec.json:471:11

The offending JSON Schema section is below, specifically the "patternProperties": {"^x-": {}}.

    "development": {
      "id": "#/definitions/development",
      "type": ["object", "null"],
      "properties": {
        "watch": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["path", "action"],
            "properties": {
              "ignore": {"type": "array", "items": {"type": "string"}},
              "path": {"type": "string"},
              "action": {"type": "string", "enum": ["rebuild", "sync", "sync+restart"]},
              "target": {"type": "string"}
            }
          },
          "additionalProperties": false,
          "patternProperties": {"^x-": {}}
        }
      }

Removing that line (and the comma on the line above) worked around the issue. I'm not sure what a more correct fix would be.

Combine, minify, hash website assets

Hugo has some helpers to combine, minify, and create files named with their hashes. This should help with loading, both size and caching issues on updates.

Question - How do you encode to JSON from evaluated cue value?

Hi ๐Ÿ‘‹

Thanks very much for this tutorial repo. Really useful for implementing cue's features, with Go.

I have a (probably) basic question. I have been able to load and evaluate a cue value. How do I encode it to JSON? I am unable to find specific references to this in cue's source as well. I am sure I am missing something.

Any help would be highly appreciated. Thank you :)

AnyOf Pattern doesn't work when fields are optional and array

import "list"

#test: this={
	a?:        [...string]
	b?:        string
	c?:        string
	#AnyOfABC: true & list.MinItems([ for label, val in this if list.Contains(["a", "b", "c"], label) {label}], 1)
}
{
	"a": ["bar"],
	"b": "foo"
}
cue eval -c ./test.cue ./testany.json -d "#test"
#test.#AnyOfABC: conflicting values false and true:
    ./test.cue:7:13
    ./test.cue:7:20

changing from array a to string works or changing the array field from optional to default works as well. This is slightly outside of the content of the page, bug a simple derivative.

Font(s) not loading

For some time now my browsers started to reject loading the truetype font embedded on the site.

On Chrome I get this error in the console:

Refused to load the font 'data:font/truetype;charset=utf-8;base64,d09GRgABAAAAAL...' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.

The site looks like this:
Screenshot 2022-03-31 at 15 47 43

I don't get any similar logs on Firefox, but the site looks the same there too.

Contributors Page

We should have a page on the website to thank all those who have contributed, if they wish to have their name listed.

Let's make it the last menu item.

Bounded recursion example breaks on cue 0.6

The bounded recursion function works for cue 0.5, but breaks on cue 0.6. To reproduce.

To reproduce the issue, take the following cue code (copied from the website, presented here as one block for easy of reproducibility):

package r

import "list"

#RecurseN: {
	// this is the bound on our recursion
	#maxiter: uint | *4

	// This is the function list element
	// we generate this to simulate recursion
	#funcFactory: {
		#next: _
		#func: _
	}

	// this is our "recursion unrolling"
	for k, v in list.Range(0, #maxiter, 1) {
		// this is where we build up our indexed functions and the references between them
		#funcs: "\(k)": (#funcFactory & {#next: #funcs["\(k+1)"]}).#func
	}

	// our final value needs to be null
	#funcs: "\(#maxiter)": null

	// we embed the head of the list so that the values
	// we write this into can be used like other CUE "functions"
	#funcs["0"]
}

#DepthF: {
	#next: _
	#func: {
		#in:    _
		#basic: int | number | string | bytes | null
		out: {
			// if we have a basic type, we are at a leaf, depth is 1
			if (#in & #basic) != _|_ {1}

			// if we are not a basic type, then we are 1 + the max of children
			if (#in & #basic) == _|_ {
				// this is our "recursion" for each child
				let depths = [ for k, v in #in {(#next & {#in: v}).out}]
				list.Max(depths) + 1
			}
		}
	}
}

#Depth: #RecurseN & {#maxiter: 11, #funcFactory: #DepthF}

tree: {
	a: {
		foo: "bar"
		a: b: c: "d"
	}
	cow: "moo"
}

d: #Depth & {#in: tree}

and run (with recur.cue containing the above):

$ cue export --out json recur.cue

with cue 0.5, the result will be:

{
    "tree": {
        "a": {
            "foo": "bar",
            "a": {
                "b": {
                    "c": "d"
                }
            }
        },
        "cow": "moo"
    },
    "d": {
        "out": 5
    }
}

with cue 0.6 (or 0.7.1), the result errors:

d: cannot add field #maxiter: was already used:
    ./recur.cue:49:22

if I remove the #maxiter field, I get a result, but out is now missing:

{
    "tree": {
        "a": {
            "foo": "bar",
            "a": {
                "b": {
                    "c": "d"
                }
            }
        },
        "cow": "moo"
    },
    "d": {}
}

Not sure why any of this happens to be honest, haven't been able to find this issue or a lead anywhere.

Script to list files which need translation

Goal: make it easy for translators to see which files are new or have changed since and need updating / translating.

It should be easy to write a script which uses git to determine which content/*.md files are older than their english counterpart.

Either-or Fields Pattern not referencing definition

Was the pattern meant to look like this? It seems to be missing #Thing for either thing1 or thing2

#First: {
	foo: string
}

#Other: {
	msg: string
}

#Either: #First | #Other

#Thing: {
	name: string
	#Either
}

thing1: #Thing & {
	name: "thing1"
	foo:  "bar"
}

thing2: #Thing & {
	name: "thing2"
	msg:  "hello"
}


Building Up Values Example Broken

Hi,

The Building Up Values example on https://cuetorials.com/overview/foundations/ doesn't work:

โฏ cat building-up.cue 
#Base: {
	name: string
	kind: string
	... // so it can be extended
}
#Meta: {
	// string and a semver regex
	version: string & =~"^v[0-9]+\\.[0-9]+\\.[0-9]+$"
	// list of strings
	labels: [...string]
}

#Permissions: {
	role: string
	public: bool | *false
}

// Building up a schema using a conjunction and embedding
#Schema: #Base & {
	// "embed" meta and permissions
	#Meta
	#Permissions
	// with no '...' this is final
}

value: #Schema & {
	name: "app"
	kind: "deploy"
	version: "v1.0.42"
	labels: ["server", "prod"]
	role: "backend"
	// public: false  (by default)
}

โฏ cue export building-up.cue
#Schema: field not allowed: kind:
    ./building-up.cue:3:2
    ./building-up.cue:6:8
    ./building-up.cue:13:15
    ./building-up.cue:19:10
    ./building-up.cue:19:18
    ./building-up.cue:21:2
    ./building-up.cue:22:2
#Schema: field not allowed: name:
    ./building-up.cue:2:2
    ./building-up.cue:6:8
    ./building-up.cue:13:15
    ./building-up.cue:19:10
    ./building-up.cue:19:18
    ./building-up.cue:21:2
    ./building-up.cue:22:2
value: field not allowed: kind:
    ./building-up.cue:3:2
    ./building-up.cue:6:8
    ./building-up.cue:13:15
    ./building-up.cue:19:10
    ./building-up.cue:19:18
    ./building-up.cue:21:2
    ./building-up.cue:22:2
    ./building-up.cue:26:8
    ./building-up.cue:28:2
value: field not allowed: name:
    ./building-up.cue:2:2
    ./building-up.cue:6:8
    ./building-up.cue:13:15
    ./building-up.cue:19:10
    ./building-up.cue:19:18
    ./building-up.cue:21:2
    ./building-up.cue:22:2
    ./building-up.cue:26:8
    ./building-up.cue:27:2

โฏ cue version
cue version 0.4.0 linux/amd64

I could get it to work by moving #Base inside of the definition, but that's doing something different.

Walkthroughs missing?

Hello ๐Ÿ‘‹ , thanks for cuetorials.com, for several topics I find it better/simpler than the original Cue docs ๐Ÿ‘

In the walkthrough section I came across this empty page:

image

It's https://cuetorials.com/walkthroughs/kubernetes/helm/, i.e. https://github.com/hofstadter-io/cuetorials.com/blob/055f33e6d9fc99401009d9995b3a1c5b40a324e1/content/walkthroughs/kubernetes/helm.md, which appears empty.

But the others also don't seem to be correct, for example I was expecting a walkthrough on https://cuetorials.com/walkthroughs/building-a-cue-powered-tool/self-driving-desktop/, but there's no walkthrough.

invalid string: invalid string: invalid whitespace

Hello

I'm trying to gently modify the basic cue example, but often get the below .

The command I'm running is cue cmd -t "name=bob" gen-todos

gen.templates.contents: invalid string: invalid string: invalid whitespace:
    ./first.cue:27:14

This error comes up when modifying what should be considered plain text, within """.

For example:

contents: """
			
			{{ range $T := .I -}}
			
			model {{ $T.name }} {
				id	      Int      @id @default(autoincrement())
				createdAt DateTime @default(now())
                published Boolean  @default(true)			
			}
			{{ end }}
			"""

Oddly, the following code does NOT error:

contents: """
			
			{{ range $T := .I -}}
			
			model {{ $T.name }} {
				id	      Int      @id @default(autoincrement())
				createdAt DateTime @default(now())		
			}
			{{ end }}
			"""

Chinese Edition

These are all the path of the site.
If you want to contribute in Chinese translation work, please claim one of them and pull request all the pages under the one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.